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:
commit
6a7f2b2396
@ -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)
|
||||||
(save-excursion
|
(with-current-buffer (process-buffer proc)
|
||||||
(set-buffer (process-buffer proc))
|
(save-excursion
|
||||||
(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,32 +385,33 @@ 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)
|
||||||
(save-excursion
|
(with-current-buffer git-blame-file
|
||||||
(set-buffer git-blame-file)
|
(save-excursion
|
||||||
(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))
|
||||||
(let* ((start (point))
|
(forward-line (1- start-line))
|
||||||
(end (progn (forward-line num-lines) (point)))
|
(let* ((start (point))
|
||||||
(ovl (make-overlay start end))
|
(end (progn (forward-line num-lines) (point)))
|
||||||
(hash (car info))
|
(ovl (make-overlay start end))
|
||||||
(spec `((?h . ,(substring hash 0 6))
|
(hash (car info))
|
||||||
(?H . ,hash)
|
(spec `((?h . ,(substring hash 0 6))
|
||||||
(?a . ,(git-blame-get-info info 'author))
|
(?H . ,hash)
|
||||||
(?A . ,(git-blame-get-info info 'author-mail))
|
(?a . ,(git-blame-get-info info 'author))
|
||||||
(?c . ,(git-blame-get-info info 'committer))
|
(?A . ,(git-blame-get-info info 'author-mail))
|
||||||
(?C . ,(git-blame-get-info info 'committer-mail))
|
(?c . ,(git-blame-get-info info 'committer))
|
||||||
(?s . ,(git-blame-get-info info 'summary)))))
|
(?C . ,(git-blame-get-info info 'committer-mail))
|
||||||
(push ovl git-blame-overlays)
|
(?s . ,(git-blame-get-info info 'summary)))))
|
||||||
(overlay-put ovl 'git-blame info)
|
(push ovl git-blame-overlays)
|
||||||
(overlay-put ovl 'help-echo
|
(overlay-put ovl 'git-blame info)
|
||||||
(format-spec git-blame-mouseover-format spec))
|
(overlay-put ovl 'help-echo
|
||||||
(if git-blame-use-colors
|
(format-spec git-blame-mouseover-format spec))
|
||||||
(overlay-put ovl 'face (list :background
|
(if git-blame-use-colors
|
||||||
(cdr (assq 'color (cdr info))))))
|
(overlay-put ovl 'face (list :background
|
||||||
(overlay-put ovl 'line-prefix
|
(cdr (assq 'color (cdr info))))))
|
||||||
(propertize (format-spec git-blame-prefix-format spec)
|
(overlay-put ovl 'line-prefix
|
||||||
'face 'git-blame-prefix-face))))))
|
(propertize (format-spec git-blame-prefix-format spec)
|
||||||
|
'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))))
|
||||||
|
Loading…
Reference in New Issue
Block a user