Merge branch 'lm/git-blame-el'

eLisp fixes for a contrib/ script.

* lm/git-blame-el:
  git-blame.el: Do not use bare 0 to mean (point-min)
  git-blame.el: Use with-current-buffer where appropriate
  git-blame.el: Do not use goto-line in lisp code
This commit is contained in:
Junio C Hamano 2012-06-25 11:25:12 -07:00
commit 6a7f2b2396

View File

@ -337,16 +337,16 @@ See also function `git-blame-mode'."
(defvar in-blame-filter nil) (defvar in-blame-filter nil)
(defun git-blame-filter (proc str) (defun git-blame-filter (proc str)
(with-current-buffer (process-buffer proc)
(save-excursion (save-excursion
(set-buffer (process-buffer proc))
(goto-char (process-mark proc)) (goto-char (process-mark proc))
(insert-before-markers str) (insert-before-markers str)
(goto-char 0) (goto-char (point-min))
(unless in-blame-filter (unless in-blame-filter
(let ((more t) (let ((more t)
(in-blame-filter t)) (in-blame-filter t))
(while more (while more
(setq more (git-blame-parse))))))) (setq more (git-blame-parse))))))))
(defun git-blame-parse () (defun git-blame-parse ()
(cond ((looking-at "\\([0-9a-f]\\{40\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)\n") (cond ((looking-at "\\([0-9a-f]\\{40\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)\n")
@ -385,11 +385,12 @@ See also function `git-blame-mode'."
info)))) info))))
(defun git-blame-create-overlay (info start-line num-lines) (defun git-blame-create-overlay (info start-line num-lines)
(with-current-buffer git-blame-file
(save-excursion (save-excursion
(set-buffer git-blame-file)
(let ((inhibit-point-motion-hooks t) (let ((inhibit-point-motion-hooks t)
(inhibit-modification-hooks t)) (inhibit-modification-hooks t))
(goto-line start-line) (goto-char (point-min))
(forward-line (1- start-line))
(let* ((start (point)) (let* ((start (point))
(end (progn (forward-line num-lines) (point))) (end (progn (forward-line num-lines) (point)))
(ovl (make-overlay start end)) (ovl (make-overlay start end))
@ -410,7 +411,7 @@ See also function `git-blame-mode'."
(cdr (assq 'color (cdr info)))))) (cdr (assq 'color (cdr info))))))
(overlay-put ovl 'line-prefix (overlay-put ovl 'line-prefix
(propertize (format-spec git-blame-prefix-format spec) (propertize (format-spec git-blame-prefix-format spec)
'face 'git-blame-prefix-face)))))) 'face 'git-blame-prefix-face)))))))
(defun git-blame-add-info (info key value) (defun git-blame-add-info (info key value)
(nconc info (list (cons (intern key) value)))) (nconc info (list (cons (intern key) value))))