Skip to content

Commit

Permalink
Add: redo-spacemacs handles more keymaps (eg. winum M-num in magit)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekaschalk committed Nov 5, 2018
1 parent 4d3084a commit 26c7ae4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
4 changes: 2 additions & 2 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ Check `dotspacemacs/get-variable-string-list' for all vars you can configure."
(display :location local)
(personal :location local))
dotspacemacs-configuration-layer-path '("~/.spacemacs.d/layers/")
dotspacemacs-additional-packages '(solarized-theme)
dotspacemacs-additional-packages '()
dotspacemacs-frozen-packages '()
dotspacemacs-excluded-packages
'(;; Must Exclude (for styling and functionality reasons)
'(;; Must Exclude (for styling, functionality, bug-fixing reasons)
fringe importmagic scss-mode vi-tilde-fringe

;; Packages I don't use
Expand Down
16 changes: 10 additions & 6 deletions layers/config/local/redo-spacemacs/redo-spacemacs.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
;; A pkg for wrapping undoing spacemacs leader bindings with warnings for
;; when keybindings change. The alist is configured in the config/packages.el.

(require 'macros)

(provide 'redo-spacemacs)
Expand All @@ -16,6 +13,9 @@ Optionally, a new-def can be included in any ele to indicate a new binding.")
(defvar redo-spacemacs-new-bindings-alist nil
"Simple alist of key-def to apply `global-set-key' over.")

(defvar redo-spacemacs-maps-to-overwrite nil
"List of keymap symbols to include by default in `redo-spacemacs-new-bindings.'")

(defvar redo-spacemacs-prefixes-list nil
"A list of keys to remove as leader prefixes, along with their bindings.")

Expand Down Expand Up @@ -57,9 +57,13 @@ Optionally, a new-def can be included in any ele to indicate a new binding.")
:warning
(format "Attempting to unbind non-existant prefix `%s'." key)))))

(defun redo-spacemacs-new-bindings (key def)
"Simple wrapper around `global-set-key' and `kbd' onto KEY for DEF."
(global-set-key (kbd key) def))
(defun redo-spacemacs-new-bindings (key def &rest maps)
"Wrap `bind-key' for MAPS and `redo-spacemacs-maps-to-overwrite'."
(bind-key key def)
(--each redo-spacemacs-maps-to-overwrite
(bind-key key def (symbol-value it)))
(--each maps
(bind-key key def (symbol-value it))))

(defun redo-spacemacs-bindings ()
"Remove unused prefixes and bindings and apply new bindings."
Expand Down
24 changes: 22 additions & 2 deletions layers/config/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@

(use-package redo-spacemacs
:if redo-bindings?
:after macros
;; Throw all the pkgs we modify keymaps of here
:after magit macros
:config
(progn
(setq redo-spacemacs-prefixes-list
Expand Down Expand Up @@ -344,6 +345,18 @@
("fr" counsel-recentf)
))

(setq redo-spacemacs--magit-maps
'(
magit-commit-message-section-map magit-commit-section-map
magit-diff-mode-map magit-file-mode-map magit-file-section-map
magit-log-mode-map magit-mode-map magit-mode-menu magit-process-mode-map
magit-reflog-mode-map magit-refs-mode-map magit-repolist-mode-map
magit-status-mode-map magit-tag-section-map magit-unmerged-section-map
magit-unpulled-section-map magit-unpushed-section-map
magit-unstaged-section-map magit-untracked-section-map
magit-worktree-section-map magit-status-mode-map))
(setq redo-spacemacs-maps-to-overwrite `(,@redo-spacemacs--magit-maps))

(setq redo-spacemacs-new-bindings-alist
'(;; Windows, Layouts Management
("M-w" spacemacs/toggle-maximize-buffer)
Expand All @@ -362,11 +375,18 @@
("M-f" counsel-find-file)
("M-r" counsel-recentf)

;; Force below defaults for `redo-spacemacs-maps-to-overwrite'
("M-1" winum-select-window-1)
("M-2" winum-select-window-2)
("M-3" winum-select-window-3)
("M-4" winum-select-window-4)
("M-5" winum-select-window-5)

;; Rebindings todo
;; spacemacs/kill-this-buffer
;; winner-undo
;; winner-redo

;; Free chords to look at
;; M-u
;; M-u, M-i
)))))

0 comments on commit 26c7ae4

Please sign in to comment.