unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Question on accessible-keymaps
@ 2006-09-18  0:21 Drew Adams
  2006-09-19  5:21 ` Drew Adams
  0 siblings, 1 reply; 2+ messages in thread
From: Drew Adams @ 2006-09-18  0:21 UTC (permalink / raw)


I have a question about using `accessible-keymaps'. I've implemented a kind
of key-sequence completion, but I'm having trouble picking up all of the
global prefix maps. I do something like this:

(dolist (key+map (accessible-keymaps (current-global-map)))
  (when (keymapp (cdr key+map))
    (map-keymap (lambda (event binding)
                  (when (keymapp binding)
                    (let ((key (vconcat (car key+map)
                                        (vector event)
                                        [S-tab])))
                      (unless (lookup-key my-map key)
                        (define-key my-map key foo)))))
                (cdr key+map))))

My hope was to run through all keymaps accessible from the current global
map, and bind, in `my-map', to command `foo', any prefix keys followed by
[S-tab]. (Similarly to, say, `C-x C-h', `C-x S-tab' gives access to the
possible `C-x' bindings, but in this case as completion candidates.)

This works fine for prefix keys such as `C-x' and `C-x 4', but it doesn't
work for some other prefix keys, such as `C-x v', `C-h', and `C-x 8'. I've
hacked some of those separately as individual one-offs, but I imagine there
must be a way to pick them up generally with `accessible-keymaps'.

Any suggestions would be appreciated. Is this a reasonable approach, or can
you suggest an easier/better/smarter way to do what I want? You can reply
off-list if you don't think others would be interested. I looked at the
existing Emacs sources for inspiration, but the only use I found of
`accessible-keymaps' was a comment in emerge.el, and it didn't help.

Note that this will only work anyway for globally defined prefixes, not for,
e.g., `%' in Dired mode. That's OK. I'd like to do the same for mode maps
(e.g. Dired), but that seems like it would be a bit complicated (`my-map' is
a minor-mode map; I don't want to modify any global or modal bindings).

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Question on accessible-keymaps
  2006-09-18  0:21 Question on accessible-keymaps Drew Adams
@ 2006-09-19  5:21 ` Drew Adams
  0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2006-09-19  5:21 UTC (permalink / raw)


    I have a question about using `accessible-keymaps'...

Nevermind; I realized my mistake (not that I expect anyone was planning to
respond).

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-09-19  5:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-18  0:21 Question on accessible-keymaps Drew Adams
2006-09-19  5:21 ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).