git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] git-blame.el: Use eldoc-mode to display current commit.
@ 2008-06-30  9:57 Nikolaj Schumacher
  2008-06-30 10:47 ` David Kågedal
  0 siblings, 1 reply; 2+ messages in thread
From: Nikolaj Schumacher @ 2008-06-30  9:57 UTC (permalink / raw)
  To: git; +Cc: David Kågedal

I think this is a better way to display the current commit.  However,
I'm not sure whether to rely on eldoc, or create my own timer.

regards,
Nikolaj Schumacher


>From 4bbd50ab1ae26ca154c20d140edfa187c9124959 Mon Sep 17 00:00:00 2001
From: Nikolaj Schumacher <git@nschum.de>
Date: Mon, 30 Jun 2008 11:44:46 +0200
Subject: [PATCH] git-blame.el: Use eldoc-mode to display current commit.

Previously, the current commit was displayed on every point movement using
text properties.  These properties stick to copied text, so that an error is
thrown once it is pasted in a different buffer.  Additionally, there is no
way to turn them off.  Using a configurable timer solves these problems.
Since eldoc already provides such functionality, hand off the work to it.
---
 contrib/emacs/git-blame.el |   27 +++++++++++----------------
 1 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
index 9f92cd2..c13e445 100644
--- a/contrib/emacs/git-blame.el
+++ b/contrib/emacs/git-blame.el
@@ -40,7 +40,7 @@
 ;; turn it on while viewing a file, the editor buffer will be updated by
 ;; setting the background of individual lines to a color that reflects
 ;; which commit it comes from.  And when you move around the buffer, a
-;; one-line summary will be shown in the echo area.
+;; one-line summary will be shown in the echo area if `eldoc-mode' is on.
 
 ;;; Installation:
 ;;
@@ -195,6 +195,7 @@ See also function `git-blame-mode'."
       (setq git-blame-colors git-blame-light-colors)))
   (setq git-blame-cache (make-hash-table :test 'equal))
   (setq git-blame-mode t)
+  (setq eldoc-documentation-function 'git-blame-identify)
   (git-blame-run))
 
 (defun git-blame-mode-off ()
@@ -354,15 +355,7 @@ See also function `git-blame-mode'."
             (overlay-put ovl 'git-blame info)
             (overlay-put ovl 'help-echo hash)
             (overlay-put ovl 'face (list :background
-                                         (cdr (assq 'color (nthcdr 5 info)))))
-            ;; the point-entered property doesn't seem to work in overlays
-            ;;(overlay-put ovl 'point-entered
-            ;;             `(lambda (x y) (git-blame-identify ,hash)))
-            (let ((modified (buffer-modified-p)))
-              (put-text-property (if (= start 1) start (1- start)) (1- end)
-                                 'point-entered
-                                 `(lambda (x y) (git-blame-identify ,hash)))
-              (set-buffer-modified-p modified))))
+                                         (cdr (assq 'color (nthcdr 5 info)))))))
         (setq num-lines (1- num-lines))))))
 
 (defun git-blame-add-info (key value)
@@ -383,14 +376,16 @@ See also function `git-blame-mode'."
                   hash)
     (buffer-substring (point-min) (1- (point-max)))))
 
-(defvar git-blame-last-identification nil)
-(make-variable-buffer-local 'git-blame-last-identification)
 (defun git-blame-identify (&optional hash)
   (interactive)
-  (let ((info (gethash (or hash (git-blame-current-commit)) git-blame-cache)))
-    (when (and info (not (eq info git-blame-last-identification)))
-      (message "%s" (nth 4 info))
-      (setq git-blame-last-identification info))))
+  (condition-case err
+      (let ((info (nth 4 (gethash (or hash (git-blame-current-commit))
+                                  git-blame-cache))))
+        (when info
+          (when (interactive-p)
+            (message "%s" info))
+          info))
+    (error nil)))
 
 ;; (defun git-blame-after-save ()
 ;;   (when git-blame-mode
-- 
1.5.5.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH/RFC] git-blame.el: Use eldoc-mode to display current commit.
  2008-06-30  9:57 [PATCH/RFC] git-blame.el: Use eldoc-mode to display current commit Nikolaj Schumacher
@ 2008-06-30 10:47 ` David Kågedal
  0 siblings, 0 replies; 2+ messages in thread
From: David Kågedal @ 2008-06-30 10:47 UTC (permalink / raw)
  To: git, Nikolaj Schumacher

Nikolaj Schumacher <n_schumacher@web.de> writes:

> I think this is a better way to display the current commit.  However,
> I'm not sure whether to rely on eldoc, or create my own timer.

Yes, maybe it is better to use a timer. But you should definitively
create a new timer, it isn't hard.

-- 
David Kågedal

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-30 11:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-30  9:57 [PATCH/RFC] git-blame.el: Use eldoc-mode to display current commit Nikolaj Schumacher
2008-06-30 10:47 ` David Kågedal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).