feature/version-control: refactor
This commit is contained in:
parent
ea128027e9
commit
df4ce8616d
2 changed files with 28 additions and 21 deletions
|
@ -41,27 +41,7 @@
|
||||||
;; showing revision details in the minibuffer, show them in
|
;; showing revision details in the minibuffer, show them in
|
||||||
;; `header-line-format', which has better visibility.
|
;; `header-line-format', which has better visibility.
|
||||||
(setq git-timemachine-show-minibuffer-details nil)
|
(setq git-timemachine-show-minibuffer-details nil)
|
||||||
|
(add-hook 'git-timemachine-mode-hook #'+vcs|init-header-line)
|
||||||
(defun +vcs|toggle-header-line ()
|
|
||||||
(if git-timemachine-mode
|
|
||||||
(+vcs*update-header-line)
|
|
||||||
(setq-local header-line-format nil)))
|
|
||||||
|
|
||||||
(defun +vcs*update-header-line (&rest _)
|
|
||||||
(when (and git-timemachine-mode git-timemachine-revision)
|
|
||||||
(let* ((revision git-timemachine-revision)
|
|
||||||
(date-relative (nth 3 revision))
|
|
||||||
(date-full (nth 4 revision))
|
|
||||||
(author (if git-timemachine-show-author (concat (nth 6 revision) ": ") ""))
|
|
||||||
(sha-or-subject (if (eq git-timemachine-minibuffer-detail 'commit) (car revision) (nth 5 revision))))
|
|
||||||
(setq-local
|
|
||||||
header-line-format
|
|
||||||
(format "%s%s [%s (%s)]"
|
|
||||||
(propertize author 'face 'git-timemachine-minibuffer-author-face)
|
|
||||||
(propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face)
|
|
||||||
date-full date-relative)))))
|
|
||||||
|
|
||||||
(add-hook 'git-timemachine-mode-hook #'+vcs|toggle-header-line)
|
|
||||||
(advice-add #'git-timemachine-show-revision :after #'+vcs*update-header-line)
|
(advice-add #'git-timemachine-show-revision :after #'+vcs*update-header-line)
|
||||||
|
|
||||||
;; Force evil to rehash keybindings for the current state
|
;; Force evil to rehash keybindings for the current state
|
||||||
|
|
|
@ -28,3 +28,30 @@ repository root."
|
||||||
(if-let (root (+vcs-root))
|
(if-let (root (+vcs-root))
|
||||||
(browse-url (concat root "/issues"))
|
(browse-url (concat root "/issues"))
|
||||||
(user-error "No git root found!")))
|
(user-error "No git root found!")))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +vcs|init-header-line ()
|
||||||
|
"Toggle the git-timemachine header-line on activate. Use this on
|
||||||
|
`git-timemachine-mode-hook'."
|
||||||
|
(if git-timemachine-mode
|
||||||
|
(+vcs*update-header-line)
|
||||||
|
(setq-local header-line-format nil)))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +vcs*update-header-line (&rest _)
|
||||||
|
"Show revision details in the header-line, instead of the minibuffer.
|
||||||
|
|
||||||
|
Sometimes I forget `git-timemachine' is enabled in a buffer. Putting info into,
|
||||||
|
putting them in `header-line-format' has better visibility."
|
||||||
|
(when (and git-timemachine-mode git-timemachine-revision)
|
||||||
|
(let* ((revision git-timemachine-revision)
|
||||||
|
(date-relative (nth 3 revision))
|
||||||
|
(date-full (nth 4 revision))
|
||||||
|
(author (if git-timemachine-show-author (concat (nth 6 revision) ": ") ""))
|
||||||
|
(sha-or-subject (if (eq git-timemachine-minibuffer-detail 'commit) (car revision) (nth 5 revision))))
|
||||||
|
(setq-local
|
||||||
|
header-line-format
|
||||||
|
(format "%s%s [%s (%s)]"
|
||||||
|
(propertize author 'face 'git-timemachine-minibuffer-author-face)
|
||||||
|
(propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face)
|
||||||
|
date-full date-relative)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue