Use Eldoc with Magit.

Use Eldoc to display information about the commit at point.
This commit is contained in:
tastytea 2021-06-21 23:46:50 +02:00
parent 7136b79f92
commit 06c354a217
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 26 additions and 2 deletions

View File

@ -16,9 +16,31 @@
(use-package magit
:unless slow-computer
:after (keychain-environment)
:after (keychain-environment eldoc)
:custom ((magit-diff-refine-hunk 'all)
(magit-process-finish-apply-ansi-colors t))
:config (progn
;; https://tsdh.org/posts/2021-06-21-using-eldoc-with-magit.html
(defun my/magit-eldoc-for-commit ()
(let ((commit (magit-commit-at-point)))
(when commit
(with-temp-buffer
(magit-git-insert "show"
"--format=format:%an <%ae>, %ai (%ar)%n%b"
(format "--stat=%d" (window-width))
commit)
(goto-char (point-min))
(put-text-property (point-min)
(line-end-position)
'face 'bold)
(buffer-string)))))
(defun my/magit-eldoc-setup ()
(add-function :before-until (local 'eldoc-documentation-function)
#'my/magit-eldoc-for-commit)
(eldoc-mode 1))
(eldoc-add-command 'magit-next-line)
(eldoc-add-command 'magit-previous-line))
:bind (("C-x g" . nil) ; Disable default.
("C-c g" . magit-status)
("C-c M-g" . magit-dispatch)
@ -31,7 +53,9 @@
("C-<down>" . magit-section-forward-sibling)
("C-<up>" . magit-section-backward-sibling)))
:hook ((after-save . magit-after-save-refresh-status)
(magit-mode . keychain-refresh-environment)))
(magit-mode . keychain-refresh-environment)
(magit-status-mode . my/magit-eldoc-setup)
(magit-log-mode . my/magit-eldoc-setup)))
;; Use libgit rather than git.
(use-package magit-libgit