Skip to content

Instantly share code, notes, and snippets.

@afrepues
Created October 16, 2013 17:48
Show Gist options
  • Save afrepues/7011919 to your computer and use it in GitHub Desktop.
Save afrepues/7011919 to your computer and use it in GitHub Desktop.
Magit customizations
;;
;; Magit customizations
;;
(setq vc-follow-symlinks t)
(setq magit-log-show-gpg-status t)
(setq magit-log-show-author-date nil)
(setq magit-status-tags-line-subject 'tag)
(define-key global-map [f9]
'(lambda ()
(interactive)
(magit-status (magit-read-top-dir nil))))
(defconst magit-git-log-graph-chars
"*|-/\\"
"The characters used by git for the graph of git log.")
(defconst *magit-git-log-graph-chars-regex*
(regexp-opt (mapcar 'string
(string-to-list magit-git-log-graph-chars)))
"Regular expression matching the graph chars output by git.")
(defcustom magit-log-graph-chars "●│─╱╲"
"Characters used to re-draw the git-log's graph in the log buffer.
Taken from egg-custom.el.
https://github.com/bogolisk/egg/blob/master/egg-custom.el")
;; Other chars:
;; ◉
(defun test-magit-translate-graph-chars ()
(magit-translate-graph "* /"))
(defun magit-translate-graph (graph)
"Translate the graphs from "
(save-match-data
(while (string-match *magit-git-log-graph-chars-regex* graph)
(let* ((properties (text-properties-at (match-beginning 0) graph))
(char-pos (search (match-string-no-properties 0 graph)
magit-git-log-graph-chars))
(new-char (string (aref magit-log-graph-chars char-pos))))
(when properties
(set-text-properties 0 1 properties new-char))
(setq graph (replace-match new-char t t graph))
))
graph))
(defun my:magit-present-log-line (line)
"A log line generator that put some nice graph characters."
(let* ((graph (magit-log-line-chart line))
(pretty-line (make-magit-log-line
:chart (when graph
(magit-translate-graph graph))
:sha1 (magit-log-line-sha1 line)
:author (magit-log-line-author line)
:date (magit-log-line-date line)
:gpg (magit-log-line-gpg line)
:msg (magit-log-line-msg line)
:refs (magit-log-line-refs line)))
)
(magit-present-log-line pretty-line)))
;; XXX: Reimplement analyzing parents, a la git-forest.
;; XXX: Is the parents information in the text-properties??
;; XXX: Show vertial ellipsis (⋮) for branches that don't start at bottom?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment