[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C-x r refers to both rectangle and register...
From: |
Kevin Rodgers |
Subject: |
Re: C-x r refers to both rectangle and register... |
Date: |
Thu, 07 Mar 2002 17:03:32 -0700 |
Dan Jacobson wrote:
>
> I noticed that the C-x r bindings include both those for rectangle and
> register... hmmm. My fault finding analysis says this is bad... the
> rectangle stuff and register stuff now step on each others toes in our
> brains... plus one day there are a lot of new additions, they will
> suffer from unfair mutual crowding. "Don't do this next time".
Indeed. How about moving one set of commands to `C-x R'?
> By the way, I did find a real problem,
> I do C-x C-h and things are out of order, no matter what my LC_* env
> variables are,
> C-x 4 d dired-other-window
> C-x 4 a add-change-log-entry-other-window
> C-x 4 C-o display-buffer
> C-x 4 b switch-to-buffer-other-window
> why isn't this list sorted beyond "4"?
Because ctl-x-4-prefix is a sparse keymap, ordered from newest to oldest
bindings. But you might want to try this:
(defun sort-keymap (keymap)
"Sort KEYMAP, by the bound events.
Nested keymaps bound to prefix keys and inherited keymaps are not sorted."
(or (keymapp keymap)
(signal 'wrong-type-argument (list 'keymapp keymap)))
(let ((inherited-keymaps (memq 'keymap (cdr keymap))))
(if inherited-keymaps
;; Remove (destructively) the inherited bindings from the keymap:
(let ((bindings keymap))
(while (not (eq (cdr bindings) inherited-keymaps))
(setq bindings (cdr bindings)))
(setcdr bindings nil)))
;; Do we need to remove shadowed bindings from a sparse keymap,
;; to prevent them from being sorted before a newer binding?
(setcdr keymap ; in case KEYMAP is inherited
(nconc (sort (cdr keymap)
(lambda (binding-1 binding-2)
(cond ((vectorp binding-1)) ; full keymap =>
; (eq binding-1 (car bindings))
((stringp binding-1)) ; menu name =>
; (eq binding-1 (car bindings))
((integerp (car binding-1)) ; keyboard event
(if (integerp (car binding-2)) ; ditto
(< (car binding-1) (car binding-2))
(not (or (vectorp binding-2)
(stringp binding-2)))))
((symbolp (car binding-1)) ; function key or
; mouse event
(if (symbolp (car binding-2)) ; ditto
(string< (symbol-name (car binding-1))
(symbol-name (car binding-2)))
(not (or (vectorp binding-2)
(stringp binding-2)
(integerp (car binding-2)))))))))
inherited-keymaps))
keymap))
(sort-keymap (indirect-function 'ctl-x-4-prefix))
;; See (Info-goto-node "(elisp)Standard Keymaps") and
;; (Info-goto-node "(elisp)Prefix Keys") for other sparse keymaps
;; you may want to sort.
--
Kevin Rodgers <kevinr@ihs.com>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: C-x r refers to both rectangle and register...,
Kevin Rodgers <=