Skip to content

Add a feature to set high priority keymaps for emulation modes #1004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

fukamachi
Copy link
Collaborator

@fukamachi fukamachi commented Aug 25, 2023

Add a new variable *emulation-mode-keymaps-functions* to set keymaps that precede other major/minor modes. This is equivalent to Emacs's emulation-mode-map-alists for emulation mode.

ref. Controlling Active Maps | Emacs manual

For the time being, vi-mode is in mind. It requires switching multiple keymaps by its "state" and has to merge with others to work better in other modes.

Talking about preceding lisp-mode's keybinds, and problems with directory-mode at #992 .

@fukamachi
Copy link
Collaborator Author

fukamachi commented Aug 25, 2023

The other option to achieve the demand for vi-mode is allowing multiple keymaps from modes, something like changing mode-keymap -> mode-keymaps.
However, it's rare to need this kind of feature, so adding this to all modes is overkill and will negatively influence Lem's performance.

@fukamachi fukamachi force-pushed the emulation-mode-keymaps branch from 100322a to d5205a2 Compare August 25, 2023 10:10
@cxxxr
Copy link
Member

cxxxr commented Aug 25, 2023

Hmm, I would prefer not to add more special variables.
How about separating the methods as follows?

(defmethod compute-keymaps ((global-mode emacs-mode)) ...)
(defmethod compute-keymaps ((global-mode vi-mode)) ...)

(defun all-keymaps ()
  ...
  (let ((keymaps (compute-keymaps (current-global-mode))))
    ...
  ))

This way, I feel it will be easier to expand in the future.

@fukamachi
Copy link
Collaborator Author

Thanks for your comment.
It'd be fine for me if it can return multiple keymaps that precede others.
I think emulation-mode-map-alists is Emacs's way, as Emacs Lisp doesn't have generic methods.

@fukamachi fukamachi force-pushed the emulation-mode-keymaps branch from d5205a2 to a4aa412 Compare August 25, 2023 16:03
@cxxxr
Copy link
Member

cxxxr commented Aug 25, 2023

Thank you.
Personally, I feel this is more Common Lisp like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants