Confused about general-create-definer and :prefix-command and/or :prefix-map with :keymaps
Opened this issue · 1 comments
So I wanted to try using :prefix-map
and :prefix-command
because it allows using :prefix-name
.
Following the Creating New Key Definers section of the README I tried the following:
(general-create-definer tyrant-def
:prefix "H-SPC"
:prefix-command 'tyrant-prefix-command
:prefix-map 'tyrant-prefix-map)
(tyrant-def :keymaps 'org-mode-map "o" 'counsel-org-goto)
(tyrant-def :keymaps 'python-mode-map "i" 'run-python)
Unexpectedly, this leads to both o
and i
being bound in both modes once a buffer using each has been opened. So starting out, org mode only has o
, I open a python buffer, now both have o
and i
. What I expected was o
only being bound to in org-mode and i
only being bound in python-mode. And this is the case when not using :prefix-map
/:prefix-command
.
I'm guessing I misunderstood the example because it specifies a keymap. What did I miss?
See the section of the readme that talks about these keywords. The behavior of your definer is to bind the prefix key "H-SPC" to the prefix map/command you've created. The first call binds H-SPC
to the prefix command in org-mode-map, and the second does the same for python-mode-map. Any keys defined (o
and i
here) will be bound in thae created prefix map, so yes they will be available in both python and org mode. I'm not sure why you want to use :prefix-map
. Maybe you are misunderstanding :prefix-name
? :prefix-name
is just passed as an argument to define-prefix-command
.