[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#6527: C-h b autoloads iso-transl and alters key-translation-map
From: |
Stefan Monnier |
Subject: |
bug#6527: C-h b autoloads iso-transl and alters key-translation-map |
Date: |
Thu, 19 Jul 2012 08:06:32 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) |
> How about something like the following (modulo comment changes and
> fixing the isearch integration)?
I don't much like the idea of hard-coding key-translation-map's parent
like this.
> There's still no facility for cleanly adding/removing a keymap parent.
Then, let's try to fix this problem.
How 'bout:
(defun add-parent (map new-parent)
(let ((cur (keymap-parent map)))
(cond
((null cur) (set-keymap-parent map new-parent))
((eq cur new-parent))
((and (consp cur) (memq new-parent cur)))
((implicit-parents-holder-p cur)
(push new-parent (cdr cur)))
(t (set-keymap-parent
map (make-composed-keymap (list new-parent cur)))))))
(defun remove-parent (map parent)
(let ((cur (keymap-parent map)))
(cond
((eq cur parent) (set-keymap-parent map nil))
((and (consp cur) (memq parent cur))
(delq parent cur)
(unless (cdr cur) (set-keymap-parent map nil))))))
The only remaining problem is to define implicit-parents-holder-p
which magically determines if the keymap is one of those that where
implicitly created by add-parent (by calling make-composed-keymap)
or if it's a *real* keymap that belongs to someone else and that we
shouldn't modify.
Stefan