Skip to content

Commit f23cfc1

Browse files
authored
Merge pull request #11 from fnussbaum/fix-remapped-modes-emacs-30
Fix bindings for remapped modes in Emacs 30
2 parents d7b0e42 + d64ea3c commit f23cfc1

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

bind-map.el

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,26 @@ when the major mode is an element of the cdr. See
211211
(defun bind-map--lookup-major-modes (mode)
212212
"Return a list of implicated modes depending on the values of
213213
`bind-map-use-remapped-modes' and `bind-map-use-aliased-modes'.
214-
If both are nil, just return `mode'. If
215-
`bind-map-use-remapped-modes' is non-nil, also return mode to
216-
which it has been remapped in `major-mode-remap-alist' (if
217-
applicable). If `bind-map-use-aliased-modes' is non-nil, also
214+
If both are nil, just return `mode'.
215+
If `bind-map-use-remapped-modes' is non-nil, also return mode
216+
to which it has been remapped in `major-mode-remap-alist'
217+
or `major-mode-remap-defaults' (if applicable).
218+
If `bind-map-use-aliased-modes' is non-nil, also
218219
return any modes for which `mode' is an alias (if applicable).
219220
Note: finding aliased modes relies on `function-alias-p', which
220221
is only available on Emacs 29.1+."
221222
(let ((r-mode
222-
(or (and bind-map-use-remapped-modes
223-
(boundp 'major-mode-remap-alist)
224-
(alist-get mode major-mode-remap-alist))))
223+
(when bind-map-use-remapped-modes
224+
(cond ((fboundp 'major-mode-remap)
225+
;; bound in Emacs 30
226+
(major-mode-remap mode))
227+
((boundp 'major-mode-remap-alist)
228+
;; bound in Emacs 29
229+
(alist-get mode major-mode-remap-alist)))))
225230
(a-modes (and bind-map-use-aliased-modes
226231
(fboundp 'function-alias-p)
227232
(function-alias-p mode))))
228-
(delq nil (append (list mode r-mode) a-modes))))
233+
(delete-dups (delq nil (append (list mode r-mode) a-modes)))))
229234

230235
(defun bind-map-add-to-major-mode-list (activate-var major-mode-list)
231236
"Add (ACTIVATE-VAR . MAJOR-MODE-LIST) to

0 commit comments

Comments
 (0)