Skip to content

Commit

Permalink
layers: Transition to new key bindings functions
Browse files Browse the repository at this point in the history
Removes dependence on evil-leader centralizing control over the method
of key binding in core-keybindings.el
  • Loading branch information
justbur authored and TheBB committed Nov 21, 2015
1 parent ee6a486 commit 9befd20
Show file tree
Hide file tree
Showing 94 changed files with 1,496 additions and 1,515 deletions.
4 changes: 2 additions & 2 deletions layers/+config-files/ansible/funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
(defun ansible/ansible-doc-maybe-enable ()
(when (ansible/ansible-should-enable?)
(ansible-doc-mode 1)
(evil-leader/set-key-for-mode 'yaml-mode
"ma?" 'ansible-doc)))
(spacemacs/set-leader-keys-for-major-mode 'yaml-mode
"a?" 'ansible-doc)))
4 changes: 2 additions & 2 deletions layers/+config-files/dockerfile/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
:defer t
:config
(progn
(evil-leader/set-key-for-mode 'dockerfile-mode
"mcb" 'dockerfile-build-buffer
(spacemacs/set-leader-keys-for-major-mode 'dockerfile-mode
"cb" 'dockerfile-build-buffer
)))
)
22 changes: 11 additions & 11 deletions layers/+config-files/puppet/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
:defer t
:init
(progn
(evil-leader/set-key-for-mode 'puppet-mode
"m{" 'beginning-of-defun
"m}" 'end-of-defun
"m$" 'puppet-interpolate
"ma" 'puppet-align-block
"m'" 'puppet-toggle-string-quotes
"m;" 'puppet-clear-string
"mj" 'imenu
"mc" 'puppet-apply
"mv" 'puppet-validate
"ml" 'puppet-lint
(spacemacs/set-leader-keys-for-major-mode 'puppet-mode
"{" 'beginning-of-defun
"}" 'end-of-defun
"$" 'puppet-interpolate
"a" 'puppet-align-block
"'" 'puppet-toggle-string-quotes
";" 'puppet-clear-string
"j" 'imenu
"c" 'puppet-apply
"v" 'puppet-validate
"l" 'puppet-lint
))))

(defun puppet/post-init-company ()
Expand Down
2 changes: 1 addition & 1 deletion layers/+config-files/salt/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(defun salt/init-salt-mode ()
(use-package salt-mode
:defer t
:config (evil-leader/set-key-for-mode 'salt-mode "mpb" 'mmm-parse-buffer)))
:config (spacemacs/set-leader-keys-for-major-mode 'salt-mode "pb" 'mmm-parse-buffer)))

(defun salt/pre-init-smartparens ()
(add-hook 'salt-mode-hook 'smartparens-mode)
Expand Down
36 changes: 18 additions & 18 deletions layers/+distribution/spacemacs-base/keybindings.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@
;; ---------------------------------------------------------------------------

;; Universal argument ---------------------------------------------------------
(evil-leader/set-key "u" 'universal-argument)
(spacemacs/set-leader-keys "u" 'universal-argument)
(when (memq dotspacemacs-editing-style '(vim hybrid))
(define-key universal-argument-map
(kbd (concat dotspacemacs-leader-key " u"))
'universal-argument-more))
;; shell command -------------------------------------------------------------
(evil-leader/set-key "!" 'shell-command)
(spacemacs/set-leader-keys "!" 'shell-command)
;; applications ---------------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"ac" 'calc-dispatch
"ad" 'dired
"ap" 'proced
"au" 'undo-tree-visualize)
;; buffers --------------------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"bd" 'kill-this-buffer
"TAB" 'spacemacs/alternate-buffer
"bh" 'spacemacs/home
Expand All @@ -84,7 +84,7 @@
"bY" 'spacemacs/copy-whole-buffer-to-clipboard
"bw" 'read-only-mode)
;; Cycling settings -----------------------------------------------------------
(evil-leader/set-key "Tn" 'spacemacs/cycle-spacemacs-theme)
(spacemacs/set-leader-keys "Tn" 'spacemacs/cycle-spacemacs-theme)
;; describe functions ---------------------------------------------------------
(defmacro spacemacs||set-helm-key (keys func)
"Define a key bindings for FUNC using KEYS.
Expand All @@ -97,27 +97,27 @@ Ensure that helm is required before calling FUNC."
(interactive)
(require 'helm)
(call-interactively ',func))
(evil-leader/set-key ,keys ',func-name))))
(spacemacs/set-leader-keys ,keys ',func-name))))
(spacemacs||set-helm-key "hdb" describe-bindings)
(spacemacs||set-helm-key "hdc" describe-char)
(spacemacs||set-helm-key "hdf" describe-function)
(spacemacs||set-helm-key "hdk" describe-key)
(spacemacs||set-helm-key "hdm" describe-mode)
(spacemacs||set-helm-key "hdp" describe-package)
(evil-leader/set-key "hds" 'spacemacs/describe-system-info)
(spacemacs/set-leader-keys "hds" 'spacemacs/describe-system-info)
(spacemacs||set-helm-key "hdt" describe-theme)
(spacemacs||set-helm-key "hdv" describe-variable)
(spacemacs||set-helm-key "hL" helm-locate-library)
;; search functions -----------------------------------------------------------
(spacemacs||set-helm-key "sww" helm-wikipedia-suggest)
(spacemacs||set-helm-key "swg" helm-google-suggest)
;; errors ---------------------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"en" 'spacemacs/next-error
"ep" 'spacemacs/previous-error
"eN" 'spacemacs/previous-error)
;; file -----------------------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"fc" 'spacemacs/copy-file
"fD" 'spacemacs/delete-current-buffer-file
"fei" 'spacemacs/find-user-init-file
Expand All @@ -140,15 +140,15 @@ Ensure that helm is required before calling FUNC."
"fvp" 'add-file-local-variable-prop-line
"fy" 'spacemacs/show-and-copy-buffer-filename)
;; insert stuff ---------------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"iJ" 'spacemacs/insert-line-below-no-indent
"iK" 'spacemacs/insert-line-above-no-indent
"ik" 'spacemacs/evil-insert-line-above
"ij" 'spacemacs/evil-insert-line-below)
;; format ---------------------------------------------------------------------
;; <SPC> j k key binding for a frequent action: go and indent line below the point
;; <SPC> J split the current line at point and indent it
(evil-leader/set-key
(spacemacs/set-leader-keys
"J" 'sp-split-sexp
"jj" 'sp-newline
"jo" 'open-line
Expand All @@ -157,18 +157,18 @@ Ensure that helm is required before calling FUNC."
"jk" 'spacemacs/evil-goto-next-line-and-indent)

;; navigation -----------------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"jh" 'spacemacs/push-mark-and-goto-beginning-of-line
"jl" 'spacemacs/push-mark-and-goto-end-of-line)

;; Compilation ----------------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"cC" 'compile
"cr" 'recompile
"cq" 'spacemacs/close-compilation-window)

;; narrow & widen -------------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"nr" 'narrow-to-region
"np" 'narrow-to-page
"nf" 'narrow-to-defun
Expand Down Expand Up @@ -282,7 +282,7 @@ Ensure that helm is required before calling FUNC."
:documentation "Enable semantic-stickyfunc globally."
:evil-leader "T C-s")
;; quit -----------------------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"qs" 'spacemacs/save-buffers-kill-emacs
"qq" 'spacemacs/prompt-kill-emacs
"qQ" 'spacemacs/kill-emacs
Expand All @@ -306,7 +306,7 @@ Ensure that helm is required before calling FUNC."
(symbol-value golden-ratio-mode))
(golden-ratio)))

(evil-leader/set-key
(spacemacs/set-leader-keys
"w2" 'spacemacs/layout-double-columns
"w3" 'spacemacs/layout-triple-columns
"wb" 'spacemacs/switch-to-minibuffer-window
Expand Down Expand Up @@ -345,7 +345,7 @@ Ensure that helm is required before calling FUNC."
;; text -----------------------------------------------------------------------
(defalias 'count-region 'count-words-region)

(evil-leader/set-key
(spacemacs/set-leader-keys
"xaa" 'align
"xar" 'spacemacs/align-repeat
"xam" 'spacemacs/align-repeat-math-oper
Expand All @@ -369,7 +369,7 @@ Ensure that helm is required before calling FUNC."
"xu" 'downcase-region
"xwc" 'spacemacs/count-words-analysis)
;; google translate -----------------------------------------------------------
(evil-leader/set-key
(spacemacs/set-leader-keys
"xgl" 'spacemacs/set-google-translate-languages)
;; shell ----------------------------------------------------------------------
(with-eval-after-load 'shell
Expand Down
71 changes: 27 additions & 44 deletions layers/+distribution/spacemacs-base/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
(setq spacemacs-base-packages
'(
bind-key
(bind-map :step pre)
bookmark
diminish
(electric-indent-mode :location built-in)
ediff
eldoc
evil
evil-escape
evil-leader
;; evil-leader
evil-surround
evil-visualstar
(evil-evilified-state :location local :step pre :protected t)
Expand Down Expand Up @@ -62,6 +63,14 @@

(defun spacemacs-base/init-bind-key ())

(defun spacemacs-base/init-bind-map ()
(use-package bind-map
:init
(bind-map spacemacs-default-map
:prefix-cmd spacemacs-cmds
:keys (dotspacemacs-emacs-leader-key)
:evil-keys (dotspacemacs-leader-key))))

(defun spacemacs-base/init-bookmark ()
(use-package bookmark
:defer t
Expand Down Expand Up @@ -225,7 +234,7 @@
(define-key evil-window-map (kbd "<up>") 'evil-window-up)
(define-key evil-window-map (kbd "<down>") 'evil-window-down)

(evil-leader/set-key "re" 'evil-show-registers)
(spacemacs/set-leader-keys "re" 'evil-show-registers)

(defmacro evil-map (state key seq)
"Map for a given STATE a KEY to a sequence SEQ of keys.
Expand Down Expand Up @@ -399,32 +408,6 @@ Example: (evil-map visual \"<\" \"<gv\")"
:config
(spacemacs|hide-lighter evil-escape-mode)))

(defun spacemacs-base/init-evil-leader ()
(use-package evil-leader
:init
(progn
(setq evil-leader/leader dotspacemacs-leader-key)
(global-evil-leader-mode)
;; This is the same hook used by evil-leader. We make sure that this
;; function is called after `evil-leader-mode' using the last argument
(add-hook 'evil-local-mode-hook
#'spacemacs-additional-leader-mode t))
:config
(progn
;; Unset shortcuts which shadow evil leader
(eval-after-load "compile"
'(progn
;; (define-key compilation-mode-map (kbd dotspacemacs-leader-key) nil)
(define-key compilation-mode-map (kbd "h") nil)))
;; (with-eval-after-load "dired" (define-key dired-mode-map (kbd
;; dotspacemacs-leader-key) nil))
;; evil-leader does not get activated in existing buffers, so we have to
;; force it here
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(evil-leader-mode 1)
(spacemacs-additional-leader-mode 1))))))

(defun spacemacs-base/init-evil-surround ()
(use-package evil-surround
:init
Expand Down Expand Up @@ -650,7 +633,7 @@ Removes the automatic guessing of the initial value based on thing at point. "
(unless (configuration-layer/package-usedp 'smex)
(global-set-key (kbd "M-x") 'helm-M-x))

(evil-leader/set-key
(spacemacs/set-leader-keys
"<f1>" 'helm-apropos
"bb" 'helm-mini
"Cl" 'helm-colors
Expand All @@ -671,7 +654,7 @@ Removes the automatic guessing of the initial value based on thing at point. "
"sl" 'spacemacs/jump-in-buffer)

;; search with grep
(evil-leader/set-key
(spacemacs/set-leader-keys
"sgb" 'spacemacs/helm-buffers-do-grep
"sgB" 'spacemacs/helm-buffers-do-grep-region-or-symbol
"sgf" 'spacemacs/helm-files-do-grep
Expand All @@ -684,7 +667,7 @@ Removes the automatic guessing of the initial value based on thing at point. "
(add-hook 'emacs-startup-hook
(lambda ()
(unless (configuration-layer/package-usedp 'smex)
(evil-leader/set-key dotspacemacs-command-key 'helm-M-x))))
(spacemacs/set-leader-keys dotspacemacs-command-key 'helm-M-x))))

(defvar spacemacs-helm-display-help-buffer-regexp '("*.*Helm.*Help.**"))
(defvar spacemacs-helm-display-buffer-regexp `("*.*helm.**"
Expand Down Expand Up @@ -920,7 +903,7 @@ ARG non nil means that the editing style is `vim'."
(progn
(setq helm-descbinds-window-style 'split)
(add-hook 'helm-mode-hook 'helm-descbinds-mode)
(evil-leader/set-key "?" 'helm-descbinds))))
(spacemacs/set-leader-keys "?" 'helm-descbinds))))

(defun spacemacs-base/init-helm-projectile ()
(use-package helm-projectile
Expand All @@ -944,7 +927,7 @@ ARG non nil means that the editing style is `vim'."
(defalias
'spacemacs/helm-project-do-grep-region-or-symbol 'helm-projectile-grep)

(evil-leader/set-key
(spacemacs/set-leader-keys
"pb" 'helm-projectile-switch-to-buffer
"pd" 'helm-projectile-find-dir
"pf" 'helm-projectile-find-file
Expand All @@ -959,9 +942,9 @@ ARG non nil means that the editing style is `vim'."
:commands (helm-spacemacs helm-spacemacs-faq)
:init
(progn
(evil-leader/set-key "feh" 'helm-spacemacs)
(evil-leader/set-key "fef" 'helm-spacemacs-faq)
(evil-leader/set-key "h SPC" 'helm-spacemacs))))
(spacemacs/set-leader-keys "feh" 'helm-spacemacs)
(spacemacs/set-leader-keys "fef" 'helm-spacemacs-faq)
(spacemacs/set-leader-keys "h SPC" 'helm-spacemacs))))

(defun spacemacs-base/init-hs-minor-mode ()
;; required for evil folding
Expand Down Expand Up @@ -1021,7 +1004,7 @@ ARG non nil means that the editing style is `vim'."
(progn
(ido-vertical-mode t)
(when dotspacemacs-use-ido
(evil-leader/set-key "ff" 'ido-find-file))
(spacemacs/set-leader-keys "ff" 'ido-find-file))
(defun spacemacs//ido-minibuffer-setup ()
"Setup the minibuffer."
;; Since ido is implemented in a while loop where each
Expand Down Expand Up @@ -1203,8 +1186,8 @@ ARG non nil means that the editing style is `vim'."
:config
(progn
(popwin-mode 1)
(evil-leader/set-key "wpm" 'popwin:messages)
(evil-leader/set-key "wpp" 'popwin:close-popup-window)
(spacemacs/set-leader-keys "wpm" 'popwin:messages)
(spacemacs/set-leader-keys "wpp" 'popwin:close-popup-window)

;; don't use default value but manage it ourselves
(setq popwin:special-display-config nil)
Expand Down Expand Up @@ -1266,14 +1249,14 @@ ARG non nil means that the editing style is `vim'."
projectile-known-projects-file (concat spacemacs-cache-directory
"projectile-bookmarks.eld"))
(unless (configuration-layer/package-usedp 'helm-projectile)
(evil-leader/set-key
(spacemacs/set-leader-keys
"pb" 'projectile-switch-to-buffer
"pd" 'projectile-find-dir
"pf" 'projectile-find-file
"ph" 'helm-projectile
"pr" 'projectile-recentf
"ps" 'projectile-switch-project))
(evil-leader/set-key
(spacemacs/set-leader-keys
"p!" 'projectile-run-shell-command-in-root
"p&" 'projectile-run-async-shell-command-in-root
"pa" 'projectile-toggle-between-implementation-and-test
Expand All @@ -1287,7 +1270,7 @@ ARG non nil means that the editing style is `vim'."
"pT" 'projectile-find-test-file
"py" 'projectile-find-tag)
(when (configuration-layer/package-usedp 'persp-mode)
(evil-leader/set-key
(spacemacs/set-leader-keys
"pl" 'spacemacs/helm-persp-switch-project)))
:config
(progn
Expand Down Expand Up @@ -1321,7 +1304,7 @@ ARG non nil means that the editing style is `vim'."
(use-package restart-emacs
:defer t
:init
(evil-leader/set-key "qr" 'spacemacs/restart-emacs)
(spacemacs/set-leader-keys "qr" 'spacemacs/restart-emacs)
(defun spacemacs/restart-emacs ()
(interactive)
(setq spacemacs-really-kill-emacs t)
Expand Down Expand Up @@ -1431,7 +1414,7 @@ ARG non nil means that the editing style is `vim'."
"Display a buffer with available key bindings."
:evil-leader "tK")

(evil-leader/set-key "hk" 'which-key-show-top-level)
(spacemacs/set-leader-keys "hk" 'which-key-show-top-level)

(let ((new-descriptions
;; being higher in this list means the replacement is applied later
Expand Down
Loading

0 comments on commit 9befd20

Please sign in to comment.