find-function-mode-lower-precedence: Also remove the global bindings
* lisp/emacs-lisp/find-func.el (find-function-mode): When find-function-mode-lower-precedence is non-nil, apply the bindings in such a way that we can also remove them when the mode is deactivated. Approach due to Stefan Monnier.
This commit is contained in:
parent
9838b88c2e
commit
ad57fbc58f
1 changed files with 8 additions and 14 deletions
|
@ -854,20 +854,14 @@ See `find-function-on-key'."
|
|||
(if find-function-mode
|
||||
(make-sparse-keymap)
|
||||
find-function-mode-map))
|
||||
(named-let define-keys ((from find-function-mode-map)
|
||||
(into (current-global-map))
|
||||
(prefix []))
|
||||
(map-keymap (lambda (event binding)
|
||||
(let* ((key (vector event))
|
||||
(prefixed (vconcat prefix key)))
|
||||
(if-let* (((keymapp binding))
|
||||
(ninto (lookup-key into key))
|
||||
((keymapp ninto)))
|
||||
(define-keys binding ninto prefixed)
|
||||
(if find-function-mode
|
||||
(global-set-key prefixed binding)
|
||||
(global-unset-key prefixed)))))
|
||||
from))))
|
||||
(let ((parent (keymap-parent (current-global-map))))
|
||||
(if find-function-mode
|
||||
(unless (memq find-function-mode-map parent)
|
||||
(setf (keymap-parent (current-global-map))
|
||||
(make-composed-keymap (list find-function-mode-map
|
||||
parent))))
|
||||
(when (memq find-function-mode-map parent)
|
||||
(delq find-function-mode-map parent))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun find-function-setup-keys ()
|
||||
|
|
Loading…
Add table
Reference in a new issue