git: remove all popup key binding for magit-dispatch-popup

The `SPC g` command prefix was to much overloaded for actions which
are already available in discoverable manner in magit. So I decided to
remove all the actions reachable from magit-dispatch-popup from `SPC g`.
magit-dispatch-popup is available under `SPC g m`. This increases the
key binding sequences but OTHO it makes everythings consistent (same
key sequence behind `SPC g s` and `SPC g m`) and we prefer consistency.

This refactoring free up a lot of precious key bindings we can use for
commands that are not available in Magit.
This commit is contained in:
syl20bnr 2016-07-04 22:35:05 -04:00
parent 3f54fa7832
commit b92daec7cf
3 changed files with 82 additions and 112 deletions

View File

@ -20,7 +20,7 @@
- [[#commit-message-editing-buffer][Commit message editing buffer]]
- [[#interactive-rebase-buffer][Interactive rebase buffer]]
- [[#quick-guide-for-recurring-use-cases-in-magit][Quick guide for recurring use cases in Magit]]
- [[#git-flow][Git-Flow]]
- [[#git-flow-1][Git-Flow]]
- [[#git-time-machine][Git time machine]]
* Description
@ -106,32 +106,17 @@ Git commands (start with ~g~):
| Key Binding | Description |
|-------------+-----------------------------------------------------|
| ~SPC g >~ | show submodule prompt |
| ~SPC g A~ | show cherry-pick prompt |
| ~SPC g b~ | open a =magit= blame |
| ~SPC g B~ | quit =magit= blame |
| ~SPC g c~ | commit changes |
| ~SPC g C~ | checkout branches |
| ~SPC g d~ | show diff prompt |
| ~SPC g D~ | show diff against current head |
| ~SPC g e~ | show ediff comparison |
| ~SPC g E~ | show ediff against current head |
| ~SPC g f~ | show fetch prompt |
| ~SPC g F~ | show pull prompt |
| ~SPC g H c~ | clear highlights |
| ~SPC g H h~ | highlight regions by age of commits |
| ~SPC g H t~ | highlight regions by last updated time |
| ~SPC g i~ | git init a given directory |
| ~SPC g I~ | open =helm-gitignore= |
| ~SPC g l~ | open a =magit= log |
| ~SPC g L~ | display the log for a file |
| ~SPC g r~ | show rebase prompt |
| ~SPC g P~ | show push prompt |
| ~SPC g s~ | open a =magit= status window |
| ~SPC g S~ | stage current file |
| ~SPC g m~ | display the last commit message of the current line |
| ~SPC g m~ | magit dispatch popup |
| ~SPC g M~ | display the last commit message of the current line |
| ~SPC g t~ | launch the git time machine |
| ~SPC g U~ | unstage current file |
| ~SPC g x~ | show reset prompt |
- Highlight by age of commit or last update time is provided by
[[https://github.com/syohex/emacs-smeargle][smeargle]].
@ -141,7 +126,8 @@ Git commands (start with ~g~):
** Magit
Spacemacs uses [[http://magit.vc/][magit]] to manage Git repositories.
To open a =status buffer=, type in a buffer of a Git repository: ~SPC g s~
To open a =status buffer=, type in a buffer of a Git repository: ~SPC g s~.
The central key binding hub of Magit is available on ~SPC g m~.
Spacemacs uses [[https://github.com/justbur/evil-magit][evil-magit]] for key bindings in magit buffers (unless your editing
style is set to emacs, in which case you get the default magit bindings), which

View File

@ -0,0 +1,62 @@
;;; funcs.el --- Colors Layer functions File
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
;; magit
(defun spacemacs/magit-toggle-whitespace ()
"Toggle whitespace in `magit-diff-mode'."
(interactive)
(if (member "-w" (if (derived-mode-p 'magit-diff-mode)
magit-refresh-args
magit-diff-section-arguments))
(spacemacs//magit-dont-ignore-whitespace)
(spacemacs//magit-ignore-whitespace)))
(defun spacemacs//magit-ignore-whitespace ()
"Ignore whitespace in `magit-diff-mode'"
(add-to-list (if (derived-mode-p 'magit-diff-mode)
'magit-refresh-args 'magit-diff-section-arguments) "-w")
(magit-refresh))
(defun spacemacs//magit-dont-ignore-whitespace ()
"Don't ignore whitespace in `magit-diff-mode'"
(setq magit-diff-options
(remove "-w"
(if (derived-mode-p 'magit-diff-mode)
magit-refresh-args
magit-diff-section-arguments))) (magit-refresh))
(defun spacemacs//fullscreen-magit (buffer)
"Display Magit status buffer in fullscreen."
(if (or
;; the original should stay alive, so we can't go fullscreen
magit-display-buffer-noselect
;; don't go fullscreen for certain magit buffers if current
;; buffer is a magit buffer (we're conforming to
;; `magit-display-buffer-traditional')
(and (derived-mode-p 'magit-mode)
(not (memq (with-current-buffer buffer major-mode)
'(magit-process-mode
magit-revision-mode
magit-diff-mode
magit-stash-mode
magit-status-mode)))))
;; open buffer according to original magit rules
(magit-display-buffer-traditional buffer)
;; open buffer in fullscreen
(delete-other-windows)
;; make sure the window isn't dedicated, otherwise
;; `set-window-buffer' throws an error
(set-window-dedicated-p nil nil)
(set-window-buffer nil buffer)
;; return buffer's window
(get-buffer-window buffer)))

View File

@ -45,12 +45,8 @@
(defun git/init-git-messenger ()
(use-package git-messenger
:defer t
:init
(spacemacs/set-leader-keys
"gm" 'git-messenger:popup-message)
:config
(define-key git-messenger-map [escape] 'git-messenger:popup-close)
))
:init (spacemacs/set-leader-keys "gM" 'git-messenger:popup-message)
:config (define-key git-messenger-map [escape] 'git-messenger:popup-close)))
(defun git/init-git-timemachine ()
(use-package git-timemachine
@ -59,10 +55,8 @@
:init
(spacemacs/set-leader-keys
"gt" 'spacemacs/time-machine-transient-state/body)
:config
(progn
(spacemacs|define-transient-state time-machine
:title "Git Timemachine Transient State"
:doc "
@ -96,17 +90,7 @@
(defun git/init-magit ()
(use-package magit
:commands (magit-blame-mode
magit-cherry-pick-popup
magit-commit-popup
magit-diff-popup
magit-fetch-popup
magit-log-popup
magit-pull-popup
magit-push-popup
magit-rebase-popup
magit-status
magit-submodule-popup)
:defer t
:init
(progn
(setq magit-completing-read-function
@ -119,35 +103,18 @@
;; See: https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-via-https
(when (eq window-system 'w32)
(setenv "GIT_ASKPASS" "git-gui--askpass"))
(defun spacemacs/magit-diff-head ()
"Execute `magit-diff' against current HEAD."
(interactive)
(magit-diff "HEAD"))
;; key bindings
(spacemacs/declare-prefix "gd" "diff")
(spacemacs/set-leader-keys
"g>" 'magit-submodule-popup
"gA" 'magit-cherry-pick-popup
"gb" 'spacemacs/git-blame-micro-state
"gc" 'magit-commit-popup
"gC" 'magit-checkout
"gd" 'magit-diff-popup
"gD" 'spacemacs/magit-diff-head
"ge" 'magit-ediff-compare
"gE" 'magit-ediff-show-working-tree
"gf" 'magit-fetch-popup
"gF" 'magit-pull-popup
"gi" 'magit-init
"gl" 'magit-log-popup
"gL" 'magit-log-buffer-file
"gr" 'magit-rebase-popup
"gP" 'magit-push-popup
"gm" 'magit-dispatch-popup
"gs" 'magit-status
"gS" 'magit-stage-file
"gU" 'magit-unstage-file
"gx" 'magit-reset-popup)
"gU" 'magit-unstage-file)
;; transient state
;; TODO use transient state instead of old micro-state, IIRC we continue
;; to use micro-state because of the re-entry keyword :on-enter which is
;; not available in transient state
(spacemacs|define-micro-state git-blame
:title "Git Blame Transient State"
:doc "
@ -359,35 +326,7 @@ Press [_b_] again to blame further in the history, [_q_] to go up or quit."
:bindings
,refresh-key 'magit-refresh
,refresh-all-key 'magit-refresh-all))))
;; full screen magit-status
(when git-magit-status-fullscreen
(setq magit-display-buffer-function
(lambda (buffer)
(if (or
;; the original should stay alive, so we can't go fullscreen
magit-display-buffer-noselect
;; don't go fullscreen for certain magit buffers if current
;; buffer is a magit buffer (we're conforming to
;; `magit-display-buffer-traditional')
(and (derived-mode-p 'magit-mode)
(not (memq (with-current-buffer buffer major-mode)
'(magit-process-mode
magit-revision-mode
magit-diff-mode
magit-stash-mode
magit-status-mode)))))
;; open buffer according to original magit rules
(magit-display-buffer-traditional buffer)
;; open buffer in fullscreen
(delete-other-windows)
;; make sure the window isn't dedicated, otherwise
;; `set-window-buffer' throws an error
(set-window-dedicated-p nil nil)
(set-window-buffer nil buffer)
;; return buffer's window
(get-buffer-window buffer)))))
;; confirm/abort
(when dotspacemacs-major-mode-leader-key
(add-hook 'with-editor-mode-hook 'evil-normalize-keymaps)
(let ((mm-key dotspacemacs-major-mode-leader-key))
@ -397,29 +336,12 @@ Press [_b_] again to blame further in the history, [_q_] to go up or quit."
(concat mm-key "a") 'with-editor-cancel
(concat mm-key "c") 'with-editor-finish
(concat mm-key "k") 'with-editor-cancel))))
;; whitespace
(defun magit-toggle-whitespace ()
(interactive)
(if (member "-w" (if (derived-mode-p 'magit-diff-mode)
magit-refresh-args
magit-diff-section-arguments))
(magit-dont-ignore-whitespace)
(magit-ignore-whitespace)))
(defun magit-ignore-whitespace ()
(interactive)
(add-to-list (if (derived-mode-p 'magit-diff-mode)
'magit-refresh-args 'magit-diff-section-arguments) "-w")
(magit-refresh))
(defun magit-dont-ignore-whitespace ()
(interactive)
(setq magit-diff-options
(remove "-w"
(if (derived-mode-p 'magit-diff-mode)
magit-refresh-args
magit-diff-section-arguments))) (magit-refresh))
(define-key magit-status-mode-map (kbd "C-S-w")
'magit-toggle-whitespace))))
'spacemacs/magit-toggle-whitespace)
;; full screen magit-status
(when git-magit-status-fullscreen
(setq magit-display-buffer-function 'spacemacs//fullscreen-magit)))))
(defun git/init-magit-gitflow ()
(use-package magit-gitflow