git-messenger

about | blog | config | notes | github

1. Git-Messenger: Emacs Port of git-messenger.vim

git-messenger is a simple package that provides a popup display for the Git commit message at the current line of an GNU/Emacs buffer.

2. Package Install

Let's ensure that Magit is properly setup as we'll configure git-messenger to use it instead of Git directly.

(require 'init-magit)

Now we can load up the package

(use-package git-messenger)

Configure the popup to show a little more detail (Commit ID, Author)

(setq git-messenger:show-detail t)

Don't display output from the shell command but rather output directly from Magit.

(setq git-messenger:use-magit-popup t)

Unfortunately, git-messenger also displays PGP signatures of the commit message.

(defun zamlz/git-messenger-commit-msg-gpg-fix-hook (msg)
  (with-temp-buffer
    (insert msg)
    (goto-char (point-min))
    (when (search-forward "-----BEGIN PGP SIGNATURE-----" nil t)
      (let ((start (line-beginning-position)))
        (when (search-forward "-----END PGP SIGNATURE-----" nil t)
          (delete-region start (point)))
        (message (buffer-substring-no-properties (point-min) (point-max)))
        (setq git-messenger:last-message
              (buffer-substring-no-properties (point-min) (point-max)))))))

(add-hook 'git-messenger:before-popup-hook 'zamlz/git-messenger-commit-msg-gpg-fix-hook)

Don't forget to provide the module.

(provide 'init-git-messenger)

Created: 2021-11-13

Emacs 26.1 (Org mode 9.5)