# vc-msg **Repository Path**: redguardtoo/vc-msg ## Basic Information - **Project Name**: vc-msg - **Description**: Show commit message of current line in Emacs - **Primary Language**: Emacs Lisp - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-05 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README * vc-msg [[http://melpa.org/#/vc-msg][file:http://melpa.org/packages/vc-msg-badge.svg]] [[http://stable.melpa.org/#/vc-msg][file:http://stable.melpa.org/packages/vc-msg-badge.svg]] Show Version Control Software (VCS) commit message of current line. This package is an extended and actively maintained version of the [[https://github.com/syohex/emacs-git-messenger][emacs-git-messenger]]. Features: - Support Git/Mercurial/Subversion/Perforce without setup - Anything is configurable - Easy to write a plugin support new VCS [[file:image/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. If Git is used and partial of the line is selected, the *correct commit for the selected text* is displayed. [[file:image/vc-msg-good.png]] [[file:image/vc-msg-bad.png]] 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=, #+begin_src elisp (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) #+end_src * 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, #+begin_src elisp (setq vc-msg-p4-file-to-url '(".*/proj1" "//depot/development/proj1")) #+end_src ** Support third party VCS Here is sample minimum code: #+begin_src elisp (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")) #+end_src 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: #+begin_src elisp (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) #+end_src ** 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=, #+begin_src elisp (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))) #+end_src [[file:image/magit-and-vc-msg.png]] 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=.