name of local mode's keymap

Discussion of Emacs Lisp

name of local mode's keymap

Postby rubing » Wed Dec 30, 2009 5:13 pm

I am unable to set key-bindings for a local mode (mew - mail program), b/c i do not know the name of the mode's keymap. I have tried looking at the 'current-local-map' variable, but just see the whole keymap in the minibuffer. Also looked at functions: current-active-maps, accessible-keymaps , but these come up void as well.


I know that it should be simple to set a binding. As quoted from elisp reference manual:

(local-set-key key binding)

(define-key (current-local-map) key binding)
rubing
 
Posts: 9
Joined: Sun Nov 22, 2009 11:44 am

Re: name of local mode's keymap

Postby gugamilare » Thu Dec 31, 2009 11:44 am

Well, I am not quite sure how is this syntax for keys, but I managed to do come up with these key bindings a while ago:

Code: Select all
(global-set-key [s-tab] 'slime-complete-symbol) ; the "s" refers to the key with a windows logo
(global-set-key [24 right] 'previous-buffer) ; 24 means C-x
(global-set-key [24 C-right] 'previous-buffer)
(global-set-key [24 left] 'next-buffer)
(global-set-key [24 C-left] 'next-buffer)


The last four was to invert the standard key binding of C-x left and C-x right, which just confuses me (my intuition says that, when I open a new file, the buffer I was working with before should be the previous one, not the next one).

By the way, IIRC, you can use strings instead of using [ and ], but I am not sure how exactly they are interpreted.
gugamilare
 
Posts: 406
Joined: Sat Mar 07, 2009 6:17 pm
Location: Brazil

Re: name of local mode's keymap

Postby rubing » Thu Dec 31, 2009 11:48 am

I have figured out how to set a local mode's keybinding using a hook while not knowing the keymaps name **see: http://www.io.com/~jimm/emacs_tips.html

It still bugs me though, not being able to easily access something so fundamental :?


Code: Select all
(setq mew-summary-mode-hook '(lambda ()
                (local-set-key "\C-x\C-y" 'mew-popmail)))
rubing
 
Posts: 9
Joined: Sun Nov 22, 2009 11:44 am

Re: name of local mode's keymap

Postby rubing » Thu Dec 31, 2009 11:52 am

@gugamilare.

I don't want to set a global key. I only want my functions to be part of the local mode map for mew (my mailing program). As I just shared above I found out how to do it. However, I am still clueless where to find the name of a given mode's keymap :?:
rubing
 
Posts: 9
Joined: Sun Nov 22, 2009 11:44 am

Re: name of local mode's keymap

Postby Paul Donnelly » Thu Dec 31, 2009 7:28 pm

rubing wrote:@gugamilare.

I don't want to set a global key. I only want my functions to be part of the local mode map for mew (my mailing program). As I just shared above I found out how to do it. However, I am still clueless where to find the name of a given mode's keymap :?:


Looking at LOCAL-SET-KEY's source, it uses CURRENT-LOCAL-MAP, which may be nil, in which case it creates a sparse keymap.

EDIT: I guess I was too hasty... keymap objects don't have names, do they?
Paul Donnelly
 
Posts: 148
Joined: Wed Jul 30, 2008 11:26 pm

Re: name of local mode's keymap

Postby rubing » Fri Jan 01, 2010 2:21 pm

Paul,

As it suggests in the manual, most local modes have named keymaps: http://www.gnu.org/software/emacs/manual/html_node/emacs/Local-Keymaps.html

As does the mew mode for sending messages that i am using. Unfortunately, I cannot find a function on my emacs for displaying the name of the local keymap.
rubing
 
Posts: 9
Joined: Sun Nov 22, 2009 11:44 am

Re: name of local mode's keymap

Postby Paul Donnelly » Fri Jan 01, 2010 6:25 pm

rubing wrote:Paul,

As it suggests in the manual, most local modes have named keymaps: http://www.gnu.org/software/emacs/manual/html_node/emacs/Local-Keymaps.html


Keymap objects are what I said are nameless. A “named keymap” is, as far as I can tell, just a variable storing a keymap object. You might grep the source of the program you're using for "make-sparse-keymap", which is likely to be near a variable declaration.
Paul Donnelly
 
Posts: 148
Joined: Wed Jul 30, 2008 11:26 pm


Return to Emacs Lisp

Who is online

Users browsing this forum: No registered users and 1 guest