From 8009e1bf5038fbfe0e1ae4695726033b6e763308 Mon Sep 17 00:00:00 2001 From: denin Date: Mon, 22 Feb 2016 21:18:48 +0300 Subject: [PATCH] evilify vc-* buffers --- .../version-control/README.org | 112 ++++++++++++++++-- .../+source-control/version-control/funcs.el | 4 + .../version-control/packages.el | 83 ++++++++++++- 3 files changed, 191 insertions(+), 8 deletions(-) diff --git a/layers/+source-control/version-control/README.org b/layers/+source-control/version-control/README.org index 4b1ee4a8f..b6f08bab4 100644 --- a/layers/+source-control/version-control/README.org +++ b/layers/+source-control/version-control/README.org @@ -8,8 +8,14 @@ - [[#configuration][Configuration]] - [[#differences-between-margin-programs][Differences between margin programs]] - [[#key-bindings][Key Bindings]] + - [[#vc-directory-buffer-commands][VC Directory buffer commands]] + - [[#commit-message-editing-buffer][Commit message editing buffer]] + - [[#diff-buffer][Diff buffer]] + - [[#log-view-buffer][Log view buffer]] + - [[#annotation-buffer][Annotation buffer]] - [[#version-control-transient-state][Version Control Transient-state]] - [[#smerge-mode-transient-state][Smerge Mode Transient-state]] + - [[#toggles][Toggles]] * Description This layers adds general configuration for [[http://www.gnu.org/software/emacs/manual/html_node/emacs/Version-Control.html][Emacs VC]]. @@ -64,14 +70,100 @@ one over the other: | Dired support | X | | | * Key Bindings +VC commands: -| Key Binding | Description | -|-------------+---------------------------------| -| ~SPC g .~ | version control transient-state | -| ~SPC g r~ | smerge mode transient-state | -| ~SPC T d~ | toggle diff margins | -| ~SPC T C-d~ | toggle diff margins globally | -| ~SPC g h o~ | browser at remote | +| Key Binding | Description | +|-------------+--------------------------------------------------------| +| ~SPC g .~ | version control transient-state | +| ~SPC g r~ | smerge mode transient-state | +| ~SPC g h o~ | browser at remote | +| ~SPC g v =~ | open a hunk under the point in the diff buffer | +| ~SPC g v D~ | compare the entire working tree with head | +| ~SPC g v e~ | show diff against current head using ediff | +| ~SPC g v g~ | visually annotate the current file | +| ~SPC g v d~ | open the VC Directory buffer | +| ~SPC g v +~ | update the working copy | +| ~SPC g v i~ | register (add) into a version control system | +| ~SPC g v u~ | revert working copy to their repository contents | +| ~SPC g v l~ | list the change log | +| ~SPC g v L~ | list the change log for the current VC controlled tree | +| ~SPC g v v~ | do the next logical VC operation (=vc-next-action=) | +| ~SPC g v I~ | ignore file (=vc-ignore=) | +| ~SPC g v r~ | resolve conflicts in file | + +** VC Directory buffer commands +You can hit ~SPC pv~ from the current project to open the VC Directory buffer, +or use ~SPC g v d~ for specifying a root directory. +Then you may mark (=m= key) files you are interested in, to form a fileset. +Most commands described above are applicable to filesets too. +To some of them are given shortcuts: + +| Key | Description | +|-----+-----------------------------------| +| ~=~ | compare selected files with head | +| ~c~ | open a =commit message buffer= | +| ~l~ | list changes | +| ~a~ | annotate selected files | +| ~i~ | add into a version control system | +| ~r~ | refresh directory view | +| ~E~ | ignore file under cursor | + +Navigation and interaction commands in the VC Directory buffer: + +| Key Bindings | Description | +|-----------------+--------------------| +| ~j~ or ~M-n~ | next file | +| ~k~ or ~M-p~ | previous file | +| ~gj~ or ~TAB~ | next directory | +| ~gk~ or ~S-TAB~ | previous directory | +| ~m~ | mark a file | +| ~u~ | unmark a file | + +** Commit message editing buffer +In a commit message buffer press ~C-c C-c~ to commit the changes with the entered message. +Pressing ~C-c C-k~ will discard the commit message and close this buffer. + + +** Diff buffer + +| Key Bindings | Description | +|------------------------+------------------------------------------------| +| ~C-j~ or ~M-n~ | next hunk | +| ~C-k~ or ~M-p~ | previous hunk | +| ~gj~ or ~J~ or ~TAB~ | next file | +| ~gk~ or ~K~ or ~S-TAB~ | previous file | +| ~a~ | apply a hunk | +| ~r~ | revert a hunk | +| ~S~ | split the current hunk at point into two hunks | +| ~D~ | kill a hunk | +| ~u~ | undo killing or splitting | + + +** Log view buffer + +| Key Bindings | Description | +|------------------------+----------------------------------------------------------------------------| +| ~C-j~ or ~M-n~ | next message | +| ~C-k~ or ~M-p~ | previous message | +| ~gj~ or ~J~ or ~TAB~ | next file | +| ~gk~ or ~K~ or ~S-TAB~ | previous file | +| ~f~ or ~ENTER~ | visit the version at point | +| ~d~ | display a diff between the revision at point and the next earlier revision | +| ~o~ | use for jumping to links | +| ~H~ | toggle hiding of the full message | + +** Annotation buffer + +| Key Bindings | Description | +|--------------+--------------------------------------------------------------------------------| +| ~J~ | visit the annotation of the revision after this one | +| ~K~ | visit the annotation of the revision previous to this one | +| ~L~ | Visit the log of the revision at line | +| ~H~ | toggle whether or not the annotation is visible | +| ~a~ | visit the annotation of the revision identified in the current line | +| ~p~ | visit the annotation of the revision before the revision at line | +| ~d~ | display the diff between the current line’s revision and the previous revision | +| ~f~ | show in a buffer the file revision indicated by the current line | ** Version Control Transient-state @@ -113,3 +205,9 @@ one over the other: | ~SPC g r u~ | Undo | | ~SPC g r r~ | Smerge refine | | ~SPC g r q~ | Quit transient state | + +** Toggles +| Key Binding | Description | +|-------------+------------------------------| +| ~SPC T d~ | toggle diff margins | +| ~SPC T C-d~ | toggle diff margins globally | diff --git a/layers/+source-control/version-control/funcs.el b/layers/+source-control/version-control/funcs.el index c71487f3b..6c4cf2b2a 100644 --- a/layers/+source-control/version-control/funcs.el +++ b/layers/+source-control/version-control/funcs.el @@ -9,6 +9,10 @@ ;; ;;; License: GPLv3 +(defun spacemacs/diff-mode-revert-hunk () + (interactive) + (diff-apply-hunk t)) + (defun spacemacs/vcs-next-hunk () (interactive) (let ((current-prefix-arg t)) diff --git a/layers/+source-control/version-control/packages.el b/layers/+source-control/version-control/packages.el index 0d1f4857f..b3cf1d8a7 100644 --- a/layers/+source-control/version-control/packages.el +++ b/layers/+source-control/version-control/packages.el @@ -12,6 +12,7 @@ (setq version-control-packages '( browse-at-remote + (vc :location built-in) diff-mode diff-hl evil-unimpaired @@ -22,14 +23,94 @@ (smerge-mode :location built-in) )) +(defun version-control/init-vc () + (use-package vc + :defer t + :init + (spacemacs/declare-prefix "gv" "version-control") + :config + (progn + (spacemacs/set-leader-keys + "gvv" 'vc-next-action + "gvg" 'vc-annotate + "gvD" 'vc-root-diff + "gve" 'vc-ediff + "gvd" 'vc-dir + "gv+" 'vc-update + "gvi" 'vc-register + "gvu" 'vc-revert + "gvl" 'vc-print-log + "gvL" 'vc-print-root-log + "gvI" 'vc-ignore + "gvr" 'vc-resolve-conflicts) + + (evilified-state-evilify vc-dir-mode vc-dir-mode-map + "j" 'vc-dir-next-line + (kbd "M-n") 'vc-dir-next-line + "k" 'vc-dir-previous-line + (kbd "M-p") 'vc-dir-previous-line + "gj" 'vc-dir-next-directory + (kbd "") 'vc-dir-next-directory + "gk" 'vc-dir-previous-directory + (kbd "") 'vc-dir-previous-directory + "l" 'vc-print-log + "c" 'vc-next-action + "a" 'vc-annotate + "r" 'vc-dir-refresh + "E" 'vc-dir-ignore) + + (evilified-state-evilify log-view-mode log-view-mode-map + (kbd "M-n") 'log-view-msg-next + (kbd "M-p") 'log-view-msg-prev + (kbd "C-j") 'log-view-msg-next + (kbd "C-k") 'log-view-msg-prev + "J" 'log-view-file-next + (kbd "") 'log-view-file-next + "gj" 'log-view-file-next + "K" 'log-view-file-prev + "gk" 'log-view-file-prev + (kbd "") 'log-view-file-prev + (kbd "") 'log-view-find-revision + "H" 'log-view-toggle-entry-display + "o" 'ace-link-woman) + (evilified-state-evilify vc-svn-log-view-mode vc-svn-log-view-mode-map) + (evilified-state-evilify vc-git-log-view-mode vc-git-log-view-mode-map) + (evilified-state-evilify vc-hg-log-view-mode vc-git-log-view-mode-map) + (evilified-state-evilify vc-annotate-mode vc-annotate-mode-map + "J" 'vc-annotate-next-revision + "K" 'vc-annotate-prev-revision + "L" 'vc-annotate-show-log-revision-at-line + "H" 'vc-annotate-toggle-annotation-visibility + "a" 'vc-annotate-revision-at-line + "p" 'vc-annotate-revision-previous-to-line)))) + + (defun version-control/init-diff-mode () (use-package diff-mode - :defer t)) + :defer t + :config + (evilified-state-evilify diff-mode diff-mode-map + (kbd "C-j") 'diff-hunk-next + (kbd "C-k") 'diff-hunk-prev + (kbd "M-n") 'diff-hunk-next + (kbd "M-p") 'diff-hunk-prev + "J" 'diff-file-next + (kbd "") 'diff-file-next + "gj" 'diff-file-next + "K" 'diff-file-prev + (kbd "") 'diff-file-prev + "gk" 'diff-file-prev + "a" 'diff-apply-hunk + "r" 'spacemacs/diff-mode-revert-hunk + "S" 'diff-split-hunk + "D" 'diff-hunk-kill + "u" 'diff-undo))) (defun version-control/init-diff-hl () (use-package diff-hl :init (progn + (spacemacs/set-leader-keys "gv=" 'diff-hl-diff-goto-hunk) (setq diff-hl-side 'left) (when (eq version-control-diff-tool 'diff-hl) (when (configuration-layer/package-used-p 'magit)