Article View: gnu.emacs.help
Article #189611Re: binding keys in .emacs
From: Martin Boyer
Date: Thu, 13 Dec 1990 00:25
Date: Thu, 13 Dec 1990 00:25
57 lines
2994 bytes
2994 bytes
In article <1990Dec9.005608.42@drycas.club.cc.cmu.edu> gaston@drycas.club.cc.cmu.edu writes:
>
>I have the following in my .emacs file:
>
>(define-key esc-map "OA" 'kill-line)
>(define-key esc-map "OB" 'newline-and-indent)
>(define-key esc-map "OC" 'universial-argument)
>(define-key esc-map "OD" 'help-command)
>
>[...]after gnu-emacs comes up, everything else I have in my .emacs
>worked fine, but these key bindings got lost somewhere.
That's because the terminal initialization file gets loaded after your
.emacs in the normal startup procedure. There are good reasons to do
this, one of them is to give the user the option of loading his own
version of the terminal initialization file. Many terminal files have
a call to terminal-specific customization hook at the end. Look in
your {emacs}/lisp/term/***.el files for one that matches your terminal
type (emacs finds it by doing a (getenv "TERM")) and look for
something that looks like (run-hook 'terminal-hook) at the end of the
file. If there is no such line, you can easily add something like:
(run-hooks 'vt100-term-hook)
Don't forget to byte-compile the new file.
Add the following in your .emacs:
(defun my-vt100-taste ()
(define-key esc-map "OA" 'kill-line)
(define-key esc-map "OB" 'newline-and-indent)
(define-key esc-map "OC" 'universial-argument)
(define-key esc-map "OD" 'help-command))
(setq vt100-term-hook 'my-vt100-taste)
There are other ways to do this, defining the CSI-map for instance,
but they are not as obvious to the casual user.
Ultimately, though, you may be after what the 'keypad' library does;
it assigns the keypad and function keys to an entry in a table. The
default entries invoke commands that are related to the labels on the
keys, but there are provisions for the user to change the table
entries. The big advantage is that you can map the 'F1' key to a
command of your choice on *all* the terminals (that use this library)
in a single line, without having to play with hooks. I have an
extended version of the keypad library and a few terminal files to go
with it if anyone is interested.
Martin
--
Martin Boyer mboyer@ireq-robot.hydro.qc.ca
Institut de recherche d'Hydro-Quebec mboyer@ireq-robot.uucp
Varennes, QC, Canada J3X 1S1
+1 514 652-8136
Technical Details
Message-ID:
<4359@s3.ireq.hydro.qc.ca>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!clyde.concordia.ca!s3!gaminReferences:
<1990Dec9.005608.42@drycas.club.cc.cmu.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,8357e38831273317 X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1990-12-13 13:53:56 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!clyde.concordia.ca!s3!gamin From: gamin@ireq-robot.hydro.qc.ca (Martin Boyer) Newsgroups: gnu.emacs.help Subject: Re: binding keys in .emacs Message-ID: <4359@s3.ireq.hydro.qc.ca> Date: 13 Dec 90 00:25:56 GMT References: <1990Dec9.005608.42@drycas.club.cc.cmu.edu> Sender: root@s3.ireq.hydro.qc.ca Organization: Laboratoire de robotique, Institut de recherche d'Hydro-Quebec Lines: 57 Posted: Thu Dec 13 01:25:56 1990