Skip to content

Commit 05f5ba6

Browse files
committed
Merge branch 'lm/git-blame-el' into maint
* 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
2 parents 125f643 + 32663b2 commit 05f5ba6

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

contrib/emacs/git-blame.el

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,16 @@ See also function `git-blame-mode'."
337337
(defvar in-blame-filter nil)
338338

339339
(defun git-blame-filter (proc str)
340-
(save-excursion
341-
(set-buffer (process-buffer proc))
342-
(goto-char (process-mark proc))
343-
(insert-before-markers str)
344-
(goto-char 0)
345-
(unless in-blame-filter
346-
(let ((more t)
347-
(in-blame-filter t))
348-
(while more
349-
(setq more (git-blame-parse)))))))
340+
(with-current-buffer (process-buffer proc)
341+
(save-excursion
342+
(goto-char (process-mark proc))
343+
(insert-before-markers str)
344+
(goto-char (point-min))
345+
(unless in-blame-filter
346+
(let ((more t)
347+
(in-blame-filter t))
348+
(while more
349+
(setq more (git-blame-parse))))))))
350350

351351
(defun git-blame-parse ()
352352
(cond ((looking-at "\\([0-9a-f]\\{40\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)\n")
@@ -385,32 +385,33 @@ See also function `git-blame-mode'."
385385
info))))
386386

387387
(defun git-blame-create-overlay (info start-line num-lines)
388-
(save-excursion
389-
(set-buffer git-blame-file)
390-
(let ((inhibit-point-motion-hooks t)
391-
(inhibit-modification-hooks t))
392-
(goto-line start-line)
393-
(let* ((start (point))
394-
(end (progn (forward-line num-lines) (point)))
395-
(ovl (make-overlay start end))
396-
(hash (car info))
397-
(spec `((?h . ,(substring hash 0 6))
398-
(?H . ,hash)
399-
(?a . ,(git-blame-get-info info 'author))
400-
(?A . ,(git-blame-get-info info 'author-mail))
401-
(?c . ,(git-blame-get-info info 'committer))
402-
(?C . ,(git-blame-get-info info 'committer-mail))
403-
(?s . ,(git-blame-get-info info 'summary)))))
404-
(push ovl git-blame-overlays)
405-
(overlay-put ovl 'git-blame info)
406-
(overlay-put ovl 'help-echo
407-
(format-spec git-blame-mouseover-format spec))
408-
(if git-blame-use-colors
409-
(overlay-put ovl 'face (list :background
410-
(cdr (assq 'color (cdr info))))))
411-
(overlay-put ovl 'line-prefix
412-
(propertize (format-spec git-blame-prefix-format spec)
413-
'face 'git-blame-prefix-face))))))
388+
(with-current-buffer git-blame-file
389+
(save-excursion
390+
(let ((inhibit-point-motion-hooks t)
391+
(inhibit-modification-hooks t))
392+
(goto-char (point-min))
393+
(forward-line (1- start-line))
394+
(let* ((start (point))
395+
(end (progn (forward-line num-lines) (point)))
396+
(ovl (make-overlay start end))
397+
(hash (car info))
398+
(spec `((?h . ,(substring hash 0 6))
399+
(?H . ,hash)
400+
(?a . ,(git-blame-get-info info 'author))
401+
(?A . ,(git-blame-get-info info 'author-mail))
402+
(?c . ,(git-blame-get-info info 'committer))
403+
(?C . ,(git-blame-get-info info 'committer-mail))
404+
(?s . ,(git-blame-get-info info 'summary)))))
405+
(push ovl git-blame-overlays)
406+
(overlay-put ovl 'git-blame info)
407+
(overlay-put ovl 'help-echo
408+
(format-spec git-blame-mouseover-format spec))
409+
(if git-blame-use-colors
410+
(overlay-put ovl 'face (list :background
411+
(cdr (assq 'color (cdr info))))))
412+
(overlay-put ovl 'line-prefix
413+
(propertize (format-spec git-blame-prefix-format spec)
414+
'face 'git-blame-prefix-face)))))))
414415

415416
(defun git-blame-add-info (info key value)
416417
(nconc info (list (cons (intern key) value))))

0 commit comments

Comments
 (0)