feature/version-control: show revision info in header-line rather than minibuffer
This commit is contained in:
parent
74af73afd0
commit
74372b71ec
1 changed files with 38 additions and 8 deletions
|
@ -31,18 +31,48 @@
|
||||||
(def-package! browse-at-remote
|
(def-package! browse-at-remote
|
||||||
:commands (browse-at-remote browse-at-remote-get-url))
|
:commands (browse-at-remote browse-at-remote-get-url))
|
||||||
|
|
||||||
|
|
||||||
(def-package! git-timemachine
|
(def-package! git-timemachine
|
||||||
:commands (git-timemachine git-timemachine-toggle)
|
:commands (git-timemachine git-timemachine-toggle)
|
||||||
:config
|
:config
|
||||||
(add-hook! 'git-timemachine-mode-hook #'evil-force-normal-state)
|
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
|
||||||
|
;; showing revision details in the minibuffer, show them in
|
||||||
|
;; `header-line-format', which is always visible.
|
||||||
|
(setq git-timemachine-show-minibuffer-details nil)
|
||||||
|
|
||||||
|
(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)
|
||||||
|
|
||||||
|
;; Force evil to rehash keybindings for the current state
|
||||||
|
(add-hook 'git-timemachine-mode-hook #'evil-force-normal-state)
|
||||||
(map! :map git-timemachine-mode-map
|
(map! :map git-timemachine-mode-map
|
||||||
:nv "p" 'git-timemachine-show-previous-revision
|
:nv "p" #'git-timemachine-show-previous-revision
|
||||||
:nv "n" 'git-timemachine-show-next-revision
|
:nv "n" #'git-timemachine-show-next-revision
|
||||||
:nv "g" 'git-timemachine-show-nth-revision
|
:nv "g" #'git-timemachine-show-nth-revision
|
||||||
:nv "q" 'git-timemachine-quit
|
:nv "q" #'git-timemachine-quit
|
||||||
:nv "w" 'git-timemachine-kill-abbreviated-revision
|
:nv "w" #'git-timemachine-kill-abbreviated-revision
|
||||||
:nv "W" 'git-timemachine-kill-revision
|
:nv "W" #'git-timemachine-kill-revision
|
||||||
:nv "b" 'git-timemachine-blame))
|
:nv "b" #'git-timemachine-blame))
|
||||||
|
|
||||||
|
|
||||||
(def-package! magit
|
(def-package! magit
|
||||||
:commands magit-status
|
:commands magit-status
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue