Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for remapped and aliased modes
This patch tries to make `bind-map` aware of two ways in which major modes can be remapped: via aliasing or via `major-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 for `LaTeX-mode`, whereas for users of emacs 29+, `latex-mode` is remapped to `LaTeX-mode` using `major-mode-remap-alist`. However, if a user had configured keymaps for `latex-mode` using `bind-map`, they will not be available in `LaTeX-mode`. This is especially problematic for distributions like `spacemacs` 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` and `bind-map-use-aliased-modes`. Both options default to `t`, in which case when `bind-map` is deciding whether to activate a given keymap, it will compare the value of `major-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) function `bind-map--lookup-major-modes` to facilitate lookup of applicable major-modes on the fly. As a result, if a user adjusts `major-mode-remap-alist` or adjusts aliased, `bind-map`'s behavior will change accordingly.
- Loading branch information