Skip to content
Show commit message of current line in Emacs
Emacs Lisp Shell
Branch: master
Clone or download
Latest commit 9379411 Dec 1, 2019


Show Version Control Software (VCS) commit message of current line.

This package is an extended and actively maintained version of the emacs-git-messenger.


  • Support Git/Mercurial/Subversion/Perforce without setup
  • Anything is configurable
  • Easy to write a plugin support new VCS



It’s recommended to install from


You only need run M-x vc-msg-show and follow the hint.

If Git is used and partial of the line is selected, the correct commit for the selected text is displayed.



Current VCS is detected automatically. If you need force the VCS type (Perforce, for example), it’s only one liner (setq vc-msg-force-vcs "p4").

You can add hook to vc-msg-hook,

(defun vc-msg-hook-setup (vcs-type commit-info)
  ;; copy commit id to clipboard
  (message (format "%s\n%s\n%s\n%s"
                   (plist-get commit-info :id)
                   (plist-get commit-info :author)
                   (plist-get commit-info :author-time)
                   (plist-get commit-info :author-summary))))
(add-hook 'vc-msg-hook 'vc-msg-hook-setup)



Perforce is detected automatically. You don’t need any manual setup.

But if you use Windows version of Perforce CLI in Cygwin Emacs, we provide the variable vc-msg-p4-file-to-url to convert file path to ULR so Emacs and Perforce CLI could communicate the file location correctly,

(setq vc-msg-p4-file-to-url '(".*/proj1" "//depot/development/proj1"))

Support third party VCS

Here is sample minimum code:

(defun vc-msg-myvcs-execute (file line-num)
  (let* ((cmd (format "myvcs blame %s %s" line-num file))
    (plist-put commit-info :id "abde")
    (plist-put commit-info :author "Chen Bin")
    (plist-put commit-info :author-time "2012-07-04")
    (plist-put commit-info :summary "2012-07-04")

(defun vc-msg-myvcs-format (commit-info)
  (format "%s\n%s\n%s\n%s"
          (plist-get commit-info :id)
          (plist-get commit-info :author)
          (plist-get commit-info :author-time)
          (plist-get commit-info :author-summary)))

(defcustom vc-msg-myvcs-extra nil
  :type '(repeat sexp)
  :group 'vc-msg)

;; setup plugin matrix
(add-to-list 'vcs-msg-plugins
             '(:type "myvcs"
               :execute vc-msg-myvcs-execute
               :format vc-msg-myvcs-format
               :extra vc-msg-myvcs-extra))

;; detect myvcs automatically
(add-to-list 'vc-msg-known-vcs
             '("myvcs" . ".myvcs"))

You can also use vc-msg-git.el as a fully functional sample.

Running hook after commit is displayed

Hook vc-msg-show-code-hook is a hook after commit is displayed.

Here is sample code:

(defun vc-msg-show-code-setup ()
  ;; use `ffip-diff-mode' from package find-file-in-project
(add-hook 'vc-msg-show-code-hook 'vc-msg-show-code-setup)

Integration with other Git client (Magit, for example)

You can run vc-msg-show from magit blame buffer any time and you can trigger any magit command from this program out of the box.

You could also use magit show the code of commit,

Here is configuration to use magit-find-file and magit-show-commit,

(eval-after-load 'vc-msg-git
     ;; show code of commit
     (setq vc-msg-git-show-commit-function 'magit-show-commit)
     ;; open file of certain revision
     (push '("m"
             (lambda ()
               (let* ((info vc-msg-previous-commit-info)
                      (git-dir (locate-dominating-file default-directory ".git")))
                 (magit-find-file (plist-get info :id )
                                  (concat git-dir (plist-get info :filename))))))


If vc-msg-git-show-commit-function is customized by the user, vc-msg-show-code-hook will be ignored.

You can also customize vc-msg-get-current-file-function, vc-msg-get-line-num-function, vc-msg-get-version-function to before calling vc-msg-show.

You can’t perform that action at this time.