git-blame.el: Use eldoc-mode to display current commit.
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
Quoted 1 line
From
4bbd50ab1ae26ca154c20d140edfa187c9124959Mon Sep 17 00:00:00 2001
From: Nikolaj Schumacher <[email protected]>
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(-)
contrib/emacs/git-blame.el +11 -16
@@ -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
Signature · 1 line
1.5.5.3
Quoted 2 lines · Nikolaj Schumacher
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.
Signature · 1 line
David Kågedal