help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I bind these two keys?


From: Alan Mackenzie
Subject: Re: How can I bind these two keys?
Date: Mon, 10 Apr 2006 08:27:57 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

volunteers@gmail.com wrote on 9 Apr 2006 12:24:37 -0700:
> Hi, group,
> I just start to use emacs. How can I bind the keys 'C-c C-s' to one key
> such as 'C-m'? I don't want 'C-m' to be a global keybinding and I just
> want it works when I edit matlab codes. How about bind them to 'F5'?

I'm guessing you already know about `global-set-key' and have tried it.

To set it for matlab files, you'll need to know what "mode" you're using
for them.  This is displayed on the "mode line" near the bottom of your
screen, and for Text Mode would look something like "(Text H Fill)" -
ignore the "H Fill" bit.

Your new key sequence will be active for all buffers using this mode.
(It is tricky to restrict it further than this.)

Firstly, you need the name of the "key map" belonging to the mode.
There's no totally systematic way of finding this, but for Text Mode it
is `text-mode-map', for Texinfo Mode it is `texinfo-mode-map', for Emacs
Lisp Mode it is `emacs-lisp-mode-map'.  Use C-h v, typing in your guesses
for the name till you find it.

Then find out the name the function on C-c C-s - Use C-h c followed by
the actual key sequence to get this.  It might be something like
`matlab-show-info'.  You'd then bind this by writing one of the following
Lisp forms into your .emacs:

   (define-key matlab-mode-map "\C-m" 'matlab-show-info)
   (define-key matlab-mode-map [F5] 'matlab-show-info)

(Be careful about the ' signs - they are critically important.)

However, C-m probably isn't a good choice, since it produces the same
effect as carriage return.  F5 is just fine, though.

> Thanks.

> Vol

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").



reply via email to

[Prev in Thread] Current Thread [Next in Thread]