{"thread":{"id":"14223","subject":"[PATCH/RFC] git-blame.el: Use eldoc-mode to display current commit.","startedAt":"2008-06-30T09:57:48Z","lastAt":"2008-06-30T10:47:48Z","messageCount":2,"participants":["Nikolaj Schumacher","David Kågedal"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"81735","messageId":"m2ej6fz1lv.fsf@nschum.de","threadId":"14223","inReplyTo":null,"subject":"[PATCH/RFC] git-blame.el: Use eldoc-mode to display current commit.","fromName":"Nikolaj Schumacher","fromEmail":"n_schumacher@web.de","sentAt":"2008-06-30T09:57:48Z","receivedAt":"2008-06-30T09:57:48Z","isPatch":true,"sender":{"key":"n_schumacher@web.de","avatar":null},"body":"I think this is a better way to display the current commit.  However,\nI'm not sure whether to rely on eldoc, or create my own timer.\n\nregards,\nNikolaj Schumacher\n\n\n>From 4bbd50ab1ae26ca154c20d140edfa187c9124959 Mon Sep 17 00:00:00 2001\nFrom: Nikolaj Schumacher <git@nschum.de>\nDate: Mon, 30 Jun 2008 11:44:46 +0200\nSubject: [PATCH] git-blame.el: Use eldoc-mode to display current commit.\n\nPreviously, the current commit was displayed on every point movement using\ntext properties.  These properties stick to copied text, so that an error is\nthrown once it is pasted in a different buffer.  Additionally, there is no\nway to turn them off.  Using a configurable timer solves these problems.\nSince eldoc already provides such functionality, hand off the work to it.\n---\n contrib/emacs/git-blame.el |   27 +++++++++++----------------\n 1 files changed, 11 insertions(+), 16 deletions(-)\n\ndiff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el\nindex 9f92cd2..c13e445 100644\n--- a/contrib/emacs/git-blame.el\n+++ b/contrib/emacs/git-blame.el\n@@ -40,7 +40,7 @@\n ;; turn it on while viewing a file, the editor buffer will be updated by\n ;; setting the background of individual lines to a color that reflects\n ;; which commit it comes from.  And when you move around the buffer, a\n-;; one-line summary will be shown in the echo area.\n+;; one-line summary will be shown in the echo area if `eldoc-mode' is on.\n \n ;;; Installation:\n ;;\n@@ -195,6 +195,7 @@ See also function `git-blame-mode'.\"\n       (setq git-blame-colors git-blame-light-colors)))\n   (setq git-blame-cache (make-hash-table :test 'equal))\n   (setq git-blame-mode t)\n+  (setq eldoc-documentation-function 'git-blame-identify)\n   (git-blame-run))\n \n (defun git-blame-mode-off ()\n@@ -354,15 +355,7 @@ See also function `git-blame-mode'.\"\n             (overlay-put ovl 'git-blame info)\n             (overlay-put ovl 'help-echo hash)\n             (overlay-put ovl 'face (list :background\n-                                         (cdr (assq 'color (nthcdr 5 info)))))\n-            ;; the point-entered property doesn't seem to work in overlays\n-            ;;(overlay-put ovl 'point-entered\n-            ;;             `(lambda (x y) (git-blame-identify ,hash)))\n-            (let ((modified (buffer-modified-p)))\n-              (put-text-property (if (= start 1) start (1- start)) (1- end)\n-                                 'point-entered\n-                                 `(lambda (x y) (git-blame-identify ,hash)))\n-              (set-buffer-modified-p modified))))\n+                                         (cdr (assq 'color (nthcdr 5 info)))))))\n         (setq num-lines (1- num-lines))))))\n \n (defun git-blame-add-info (key value)\n@@ -383,14 +376,16 @@ See also function `git-blame-mode'.\"\n                   hash)\n     (buffer-substring (point-min) (1- (point-max)))))\n \n-(defvar git-blame-last-identification nil)\n-(make-variable-buffer-local 'git-blame-last-identification)\n (defun git-blame-identify (&optional hash)\n   (interactive)\n-  (let ((info (gethash (or hash (git-blame-current-commit)) git-blame-cache)))\n-    (when (and info (not (eq info git-blame-last-identification)))\n-      (message \"%s\" (nth 4 info))\n-      (setq git-blame-last-identification info))))\n+  (condition-case err\n+      (let ((info (nth 4 (gethash (or hash (git-blame-current-commit))\n+                                  git-blame-cache))))\n+        (when info\n+          (when (interactive-p)\n+            (message \"%s\" info))\n+          info))\n+    (error nil)))\n \n ;; (defun git-blame-after-save ()\n ;;   (when git-blame-mode\n-- \n1.5.5.3\n"},{"id":"81742","messageId":"87myl3fbcb.fsf@lysator.liu.se","threadId":"14223","inReplyTo":"m2ej6fz1lv.fsf@nschum.de","subject":"Re: [PATCH/RFC] git-blame.el: Use eldoc-mode to display current commit.","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2008-06-30T10:47:48Z","receivedAt":"2008-06-30T10:47:48Z","isPatch":true,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Nikolaj Schumacher <n_schumacher@web.de> writes:\n\n> I think this is a better way to display the current commit.  However,\n> I'm not sure whether to rely on eldoc, or create my own timer.\n\nYes, maybe it is better to use a timer. But you should definitively\ncreate a new timer, it isn't hard.\n\n-- \nDavid Kågedal\n"}]}