-
Notifications
You must be signed in to change notification settings - Fork 87
which-key-add-keymap-based-replacements with key sequences #275
Comments
For example So can |
That shouldn't happen I don't think. Can you give me a small non-spacemacs example to test? |
Yeah it was my mistake. Sorry. Btw it works fine for evil-leader (setq inhibit-startup-screen t)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(package-refresh-contents)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun testfun ()
(interactive)
(message "success!"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(unless (package-installed-p 'evil)
(package-install 'evil)
(package-install 'evil-leader))
(unless (package-installed-p 'evil-leader)
(package-install 'evil-leader))
(unless (package-installed-p 'which-key)
(package-install 'which-key))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'which-key)
(which-key-mode)
(which-key-setup-side-window-bottom)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'evil)
(evil-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'evil-leader)
(global-evil-leader-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(evil-leader/set-leader "SPC")
(evil-leader/set-key-for-mode 'emacs-lisp-mode "a b c" 'testfun)
(which-key-add-keymap-based-replacements
evil-leader--default-map "a b" '("replacement"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(emacs-lisp-mode) Too bad making it mode specific would require digging into |
Should be possible outside evil-leader too. What you’re asking for is a
version that is aware of evil keymaps, meaning it understands how evil
binds to a mode in a keymap.
…On Thu, Dec 17, 2020 at 8:28 PM Eugene Yaremenko ***@***.***> wrote:
Yeah it was my mistake. Sorry.
Btw it works fine for evil-leader
(setq inhibit-startup-screen t)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(package-refresh-contents)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun testfun ()
(interactive)
(message "success!"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(unless (package-installed-p 'evil)
(package-install 'evil)
(package-install 'evil-leader))
(unless (package-installed-p 'evil-leader)
(package-install 'evil-leader))
(unless (package-installed-p 'which-key)
(package-install 'which-key))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'which-key)
(which-key-mode)
(which-key-setup-side-window-bottom)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'evil)
(evil-mode 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'evil-leader)
(global-evil-leader-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(evil-leader/set-leader "SPC")
(evil-leader/set-key-for-mode 'emacs-lisp-mode "a b c" 'testfun)
(which-key-add-keymap-based-replacements
evil-leader--default-map "a b" '("replacement"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(emacs-lisp-mode)
Too bad making it mode specific would require digging into
evil-leader--mode-maps
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#275 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQ3E7VZZPOJYR45CPZIHYTSVKV4VANCNFSM4UND577A>
.
|
@justbur it's simpler to make it work for Spacemacs since it has a defvar for every mode map. But |
It would be cool if
which-key-add-keymap-based-replacements
worked for key sequences, especially major mode specific ones since which-key stores the replacements in the single global variable and Spacemacs has a lot of them.This actually works(surprisingly) but only visually:
(which-key-add-keymap-based-replacements emacs-lisp-mode-map "SPC mt" "test")
The problem is that it collides with "SPC" (or any other leading kbd) in Evil mode and prevents you from typing. And adding it "the usual way" results in bad prefix error.
Maybe it ca be fixed by adding unused key code that will serve as a root for all fake which-key keys in the map so it won't collide with anything user defined?
The text was updated successfully, but these errors were encountered: