Highlighting of sha and graph in log buffer.
This commit is contained in:
parent
e38987412d
commit
2ec5ee71f1
1 changed files with 79 additions and 41 deletions
118
magit.el
118
magit.el
|
@ -175,6 +175,27 @@ Many Magit faces inherit from this one by default."
|
||||||
"Face for lines in a diff that have been deleted."
|
"Face for lines in a diff that have been deleted."
|
||||||
:group 'magit)
|
:group 'magit)
|
||||||
|
|
||||||
|
(defface magit-log-graph
|
||||||
|
'((((class color) (background light))
|
||||||
|
:foreground "grey11")
|
||||||
|
(((class color) (background dark))
|
||||||
|
:foreground "grey30"))
|
||||||
|
"Face for the graph element of the log output."
|
||||||
|
:group 'magit)
|
||||||
|
|
||||||
|
(defface magit-log-sha1
|
||||||
|
'((((class color) (background light))
|
||||||
|
:foreground "firebrick")
|
||||||
|
(((class color) (background dark))
|
||||||
|
:foreground "OrangeRed"))
|
||||||
|
"Face for the sha1 element of the log output."
|
||||||
|
:group 'magit)
|
||||||
|
|
||||||
|
(defface magit-log-message
|
||||||
|
'((t))
|
||||||
|
"Face for the message element of the log output."
|
||||||
|
:group 'magit)
|
||||||
|
|
||||||
(defface magit-item-highlight
|
(defface magit-item-highlight
|
||||||
'((((class color) (background light))
|
'((((class color) (background light))
|
||||||
:background "gray95")
|
:background "gray95")
|
||||||
|
@ -1805,50 +1826,67 @@ Please see the manual for a complete description of Magit.
|
||||||
|
|
||||||
;;; Logs and Commits
|
;;; Logs and Commits
|
||||||
|
|
||||||
(defun magit-parse-log-ref (refname)
|
(defvar magit-log-oneline-re
|
||||||
"Return shortened and propertized version of full REFNAME, like
|
(concat
|
||||||
\"refs/remotes/origin/master\"."
|
"^\\([_\\*|/ ]+\\)" ; graph (1)
|
||||||
(let ((face 'magit-log-head-label))
|
"\\(?:"
|
||||||
(cond ((string-match "^\\(tag: +\\)?refs/tags/\\(.+\\)" refname)
|
"\\([0-9a-fA-F]\\{40\\}\\) " ; sha1 (2)
|
||||||
(setq refname (match-string 2 refname)
|
"\\(?:\\((.+)\\) \\)?" ; refs (3)
|
||||||
face 'magit-log-tag-label))
|
"\\(.*\\)" ; msg (4)
|
||||||
((string-match "^refs/remotes/\\(.+\\)" refname)
|
"\\)?$")
|
||||||
(setq refname (match-string 1 refname)))
|
"Regexp used to extract elements of git log output with
|
||||||
((string-match "[^/]+$" refname)
|
--pretty=oneline.")
|
||||||
(setq refname (match-string 0 refname))))
|
|
||||||
(propertize refname 'face face)))
|
|
||||||
|
|
||||||
(defun magit-parse-log-refs (refstring)
|
(defvar magit-present-log-line-function 'magit-present-log-line
|
||||||
"Parse REFSTRING annotation from `git log --decorate'
|
"The function to use when generating a log line. It takes four
|
||||||
output (for example: \"refs/remotes/origin/master,
|
args: CHART, SHA1, REFS and MESSAGE. The function must return a
|
||||||
refs/heads/master\") and return prettified string for displaying
|
string which will represent the log line.")
|
||||||
in log buffer."
|
|
||||||
(mapconcat 'identity
|
(defun magit-present-log-line (chart sha1 refs message)
|
||||||
(mapcar 'magit-parse-log-ref
|
"The default log line generator."
|
||||||
(remove-if (lambda (refname)
|
(let* ((ref-re "\\(?:tag: \\)?refs/\\(?:tags\\|remotes\\|heads\\)/\\(.+\\)")
|
||||||
(string-match "/HEAD$" refname))
|
(string-refs
|
||||||
(reverse (split-string refstring ", *" t))))
|
(when refs
|
||||||
" - "))
|
(concat (mapconcat
|
||||||
|
(lambda (r)
|
||||||
|
(propertize
|
||||||
|
(if (string-match ref-re r)
|
||||||
|
(match-string 1 r)
|
||||||
|
r)
|
||||||
|
'face 'magit-log-head-label))
|
||||||
|
refs
|
||||||
|
" ")
|
||||||
|
" "))))
|
||||||
|
(concat
|
||||||
|
(propertize chart 'face 'magit-log-graph)
|
||||||
|
(when sha1
|
||||||
|
(propertize (substring sha1 0 8) 'face 'magit-log-sha1))
|
||||||
|
" "
|
||||||
|
string-refs
|
||||||
|
(when message
|
||||||
|
(propertize message 'face 'magit-log-message)))))
|
||||||
|
|
||||||
(defun magit-wash-log-line ()
|
(defun magit-wash-log-line ()
|
||||||
(if (and (search-forward-regexp "[0-9a-fA-F]\\{40\\}" (line-end-position) t)
|
(beginning-of-line)
|
||||||
(goto-char (match-beginning 0))
|
(let ((line-re magit-log-oneline-re))
|
||||||
(not (looking-back "commit ")))
|
(cond
|
||||||
(let ((commit (match-string-no-properties 0)))
|
((looking-at magit-log-oneline-re)
|
||||||
(delete-region (match-beginning 0) (match-end 0))
|
(let ((chart (match-string 1))
|
||||||
(fixup-whitespace)
|
(sha1 (match-string 2))
|
||||||
(goto-char (line-beginning-position))
|
(msg (match-string 4))
|
||||||
(when (search-forward-regexp "^[|*\\/ ]+\\((\\(tag:.+?\\|refs/.+?\\))\\)"
|
(refs (when (match-string 3)
|
||||||
(line-end-position) t)
|
(split-string (match-string 3) "[(), ]" t))))
|
||||||
(let ((refstring (match-string-no-properties 2)))
|
(delete-region (point-at-bol) (point-at-eol))
|
||||||
(delete-region (match-beginning 1) (match-end 1))
|
(insert (magit-present-log-line chart sha1 refs msg))
|
||||||
(insert (magit-parse-log-refs refstring)))
|
(goto-char (point-at-bol))
|
||||||
(goto-char (line-beginning-position)))
|
(if sha1
|
||||||
(magit-with-section commit 'commit
|
(magit-with-section sha1 'commit
|
||||||
(magit-set-section-info commit)
|
(magit-set-section-info sha1)
|
||||||
(forward-line)))
|
|
||||||
(forward-line))
|
(forward-line))
|
||||||
t)
|
(forward-line))))
|
||||||
|
(t
|
||||||
|
(forward-line)))
|
||||||
|
t))
|
||||||
|
|
||||||
(defun magit-wash-log ()
|
(defun magit-wash-log ()
|
||||||
(let ((magit-old-top-section nil))
|
(let ((magit-old-top-section nil))
|
||||||
|
|
Loading…
Add table
Reference in a new issue