add support for remapped and aliased modes #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch tries to make
bind-map
aware of two ways in which major modes can be remapped: via aliasing or viamajor-mode-remap-alist
.The motivating scenario is AUCTeX, which as of version 14.0.1 has renamed several major modes, e.g., latex-mode has been renamed as LaTeX-mode. AUCTeX attempts to offer backwards compatibility using a mix of remapping and aliasing. For users of emacs < 29,
latex-mode
is redefined as an alias forLaTeX-mode
, whereas for users of emacs 29+,latex-mode
is remapped toLaTeX-mode
usingmajor-mode-remap-alist
.However, if a user had configured keymaps for
latex-mode
usingbind-map
, they will not be available inLaTeX-mode
. This is especially problematic for distributions likespacemacs
which need to support users of both old and new AUCTeX (see syl20bnr/spacemacs#16282 for more discussion).This patch introduces two new customizable options,
bind-map-use-remapped-modes
andbind-map-use-aliased-modes
. Both options default tot
, in which case whenbind-map
is deciding whether to activate a given keymap, it will compare the value ofmajor-mode
to not only the symbol for which the keymap was configured configured (e.g.,latex-mode
), but any remapped or aliased modes (e.g.,'(latex-mode LaTeX-mode)
. This logic is implemented in the new (private) functionbind-map--lookup-major-modes
to facilitate lookup of applicable major-modes on the fly. As a result, if a user adjustsmajor-mode-remap-alist
or adjusts aliased,bind-map
's behavior will change accordingly.