Show Version Control Software (VCS) commit message of current line.
This package is an extended and actively maintained version of the emacs-git-messenger.
- The correct commit for the user selected text is located by a new algorithm (Git only)
- Support Git/Mercurial/Subversion/Perforce without setup
- Anything is configurable
- Users can easily add support for new VCS
It’s recommended to install from http://melpa.org/.
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
(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)) commit-info) (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") 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.
Running hook after commit is displayed
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 (ffip-diff-mode)) (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
(eval-after-load 'vc-msg-git '(progn ;; show code of commit (setq vc-msg-git-show-commit-function 'magit-show-commit) ;; open file of certain revision (push '("m" "[m]agit-find-file" (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)))))) vc-msg-git-extra)))
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-version-function to before calling
Integration with git-link
git-link provides “Interactive Emacs functions that create URLs for files and commits in GitHub/Bitbucket/GitLab/… repositories.” This package is not dependent on git-link. But if git-link is installed, a new menu item to copy the git link is displayed.