Show commit message of current line in Emacs
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.elpaignore
.travis.yml
Cask
LICENSE
README.org
screenshot-nq8.png
vc-msg-git.el
vc-msg-hg.el
vc-msg-p4.el
vc-msg-sdk.el
vc-msg-svn.el
vc-msg.el

README.org

vc-msg v0.0.4

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

Features:

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

https://raw.githubusercontent.com/redguardtoo/vc-msg/master/screenshot-nq8.png

INSTALL

It’s recommended to install from http://melpa.org/.

Usage

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

The current VCS will be detected automatically. If for some reason you need force the VCS type (Perforce, for example), it’s just 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)

Tips

Perforce

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 alien VCS

Here is sample minimum code:

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

(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
  "whatever."
  :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.

vc-msg-show-code-hook

Hook `vc-msg-show-code-hook’ is hook after code of certain commit is displayed.

Here is sample code:

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