* How can I bind these two keys? @ 2006-04-09 19:24 volunteers 2006-04-10 8:27 ` Alan Mackenzie 0 siblings, 1 reply; 4+ messages in thread From: volunteers @ 2006-04-09 19:24 UTC (permalink / raw) 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'? Thanks. Vol ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How can I bind these two keys? 2006-04-09 19:24 How can I bind these two keys? volunteers @ 2006-04-10 8:27 ` Alan Mackenzie 2006-04-10 12:07 ` Miles Bader 2006-04-10 15:12 ` Kevin Rodgers 0 siblings, 2 replies; 4+ messages in thread From: Alan Mackenzie @ 2006-04-10 8:27 UTC (permalink / raw) 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"). ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How can I bind these two keys? 2006-04-10 8:27 ` Alan Mackenzie @ 2006-04-10 12:07 ` Miles Bader 2006-04-10 15:12 ` Kevin Rodgers 1 sibling, 0 replies; 4+ messages in thread From: Miles Bader @ 2006-04-10 12:07 UTC (permalink / raw) Alan Mackenzie <acm@muc.de> writes: > 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. For matlab, you probably want to be using "octave-mode" (Octave is the free software equivalent of matlab). Emacs defaults to objc-mode for .m files, so you'll probably have to select the mode manually (until you've overridden the default in auto-mode-alist). The keymap variable for octave-mode is as expected, `octave-mode-map'. -Miles -- Occam's razor split hairs so well, I bought the whole argument! ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How can I bind these two keys? 2006-04-10 8:27 ` Alan Mackenzie 2006-04-10 12:07 ` Miles Bader @ 2006-04-10 15:12 ` Kevin Rodgers 1 sibling, 0 replies; 4+ messages in thread From: Kevin Rodgers @ 2006-04-10 15:12 UTC (permalink / raw) Alan Mackenzie wrote: > 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. There's no need to look up the keymap variable. Just do: (add-hook 'foo-mode-hook (lambda () (local-set-key KEY COMMAND) ...)) > 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) -- Kevin Rodgers ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-04-10 15:12 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-04-09 19:24 How can I bind these two keys? volunteers 2006-04-10 8:27 ` Alan Mackenzie 2006-04-10 12:07 ` Miles Bader 2006-04-10 15:12 ` Kevin Rodgers
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).