From 8a4bf9c655744081eebb030f587777c061f224e5 Mon Sep 17 00:00:00 2001 From: duianto Date: Mon, 10 Sep 2018 19:55:44 +0200 Subject: [PATCH] filetrees: remap winum-select-window-0-or-10 Problem: `C-x w 0` calls `winum-select-window-0-or-10` which shows: winum-select-window-by-number: No window numbered 10 Solution (Thanks Miciah): Remap `winum-select-window-0-or-10` to the current filetree command: `neotree-show` or `treemacs-select-window` Then all three key bindings: `C-x w 0`, `SPC 0` and `M-0` will call the same filetree command. Additionally: Renamed the remapped which-key name to the filetree command. Wrapped lines to keep them under 80 chars. --- CHANGELOG.develop | 4 ++++ layers/+filetree/neotree/packages.el | 11 +++++++---- layers/+filetree/treemacs/packages.el | 13 +++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.develop b/CHANGELOG.develop index 76e76f465..ca28d0001 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -1785,6 +1785,8 @@ Other: - ~SPC 0~ and ~M-0~ are consistent across Neotree and Treemacs - Fixed ~RET~ binding functionality (thanks to Lupco Kotev) - Use "open" instead of "xdg-open" on macos (thanks to Alexander-Miller) +- Remapped =winum-select-window-0-or-10= to =neotree-show= so that ~C-x w 0~, + ~SPC 0~ and ~M-0~ call the same command (thanks to duianto and Miciah) **** NixOS - Enabled Flycheck (thanks to William Casarin) - Defer loading (thanks to Benno Fünfstück) @@ -2307,6 +2309,8 @@ Other: **** Treemacs - =Treemacs= replaces =NeoTree= as the default sidebar - Add missing ~SPC p t~ to =readme.org= (thanks to oo6) +- Remapped =winum-select-window-0-or-10= to =treemacs-select-window= so that + ~C-x w 0~, ~SPC 0~ and ~M-0~ call the same command (thanks to duianto, Miciah) **** Typescript - Call tsfmt with extension of current buffer for TSX formatting (thanks to Victor Andrée) diff --git a/layers/+filetree/neotree/packages.el b/layers/+filetree/neotree/packages.el index 3b9e84efe..e83b92199 100644 --- a/layers/+filetree/neotree/packages.el +++ b/layers/+filetree/neotree/packages.el @@ -116,7 +116,10 @@ Navigation^^^^ Actions^^ Visual actions/config^^^ (defun neotree/pre-init-winum () (spacemacs|use-package-add-hook winum :post-config - ;; window 0 is reserved for file trees - (spacemacs/set-leader-keys "0" #'neotree-show) - (define-key winum-keymap (kbd "M-0") #'neotree-show) - (add-to-list 'winum-assign-functions #'spacemacs//winum-neotree-assign-func))) + ;; `0', `M-0' and `C-x w 0' are bound to `winum-select-window-0-or-10' + (define-key winum-keymap [remap winum-select-window-0-or-10] #'neotree-show) + ;; replace the which-key name + (push '((nil . "winum-select-window-0-or-10") . (nil . "neotree-show")) + which-key-replacement-alist) + (add-to-list 'winum-assign-functions + #'spacemacs//winum-neotree-assign-func))) diff --git a/layers/+filetree/treemacs/packages.el b/layers/+filetree/treemacs/packages.el index b5452668f..fd71e7cda 100644 --- a/layers/+filetree/treemacs/packages.el +++ b/layers/+filetree/treemacs/packages.el @@ -85,10 +85,15 @@ (spacemacs|use-package-add-hook winum :post-config (progn - ;; window 0 is reserved for file trees - (spacemacs/set-leader-keys "0" 'treemacs-select-window) - (define-key winum-keymap (kbd "M-0") 'treemacs-select-window) + ;; `0', `M-0' and `C-x w 0' are bound to `winum-select-window-0-or-10' + (define-key winum-keymap + [remap winum-select-window-0-or-10] #'treemacs-select-window) + ;; replace the which-key name + (push '((nil . "winum-select-window-0-or-10") . + (nil . "treemacs-select-window")) + which-key-replacement-alist) (with-eval-after-load 'treemacs (dolist (n (number-sequence 1 5)) (add-to-list 'winum-ignored-buffers - (format "%sFramebuffer-%s*" treemacs--buffer-name-prefix n))))))) + (format "%sFramebuffer-%s*" + treemacs--buffer-name-prefix n)))))))