feature/version-control: fix git-timemachine headerline
On first invokation of git-timemachine the headerline isn't visible until you jump to another revision. This fix ensures it's visible from the start.
This commit is contained in:
parent
63924df639
commit
9b41423537
2 changed files with 16 additions and 28 deletions
|
@ -69,9 +69,8 @@
|
||||||
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
|
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
|
||||||
;; 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 t)
|
||||||
(add-hook 'git-timemachine-mode-hook #'+vcs|init-header-line)
|
(advice-add #'git-timemachine--show-minibuffer-details :override #'+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
|
||||||
(add-hook 'git-timemachine-mode-hook #'evil-force-normal-state))
|
(add-hook 'git-timemachine-mode-hook #'evil-force-normal-state))
|
||||||
|
|
|
@ -32,12 +32,20 @@ repository root."
|
||||||
(user-error "No git root found!")))
|
(user-error "No git root found!")))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +vcs|init-header-line ()
|
(defun +vcs*update-header-line (revision)
|
||||||
"Toggle the git-timemachine header-line on activate. Use this on
|
"Show revision details in the header-line, instead of the minibuffer.
|
||||||
`git-timemachine-mode-hook'."
|
|
||||||
(if git-timemachine-mode
|
Sometimes I forget `git-timemachine' is enabled in a buffer. Putting revision
|
||||||
(+vcs*update-header-line)
|
info in the `header-line-format' is a good indication."
|
||||||
(setq-local header-line-format nil)))
|
(let* ((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 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))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +vcs|enable-smerge-mode-maybe ()
|
(defun +vcs|enable-smerge-mode-maybe ()
|
||||||
|
@ -49,22 +57,3 @@ repository root."
|
||||||
(when (and (featurep 'hydra)
|
(when (and (featurep 'hydra)
|
||||||
+vcs-auto-hydra-smerge)
|
+vcs-auto-hydra-smerge)
|
||||||
(+hydra-smerge/body)))))
|
(+hydra-smerge/body)))))
|
||||||
|
|
||||||
;;;###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