🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #2181

Re: keymap defs -- using lambda expressions

#2181
From: Dag Nummedal
Date: Sun, 24 Jan 1993 23:11
32 lines
1819 bytes
In article <C1DMuy.Hw2@cs.psu.edu> liblit@cs.psu.edu (Benjamin R. Liblit) writes:
  
>In article <hyk1H?8o3c@atlantis.psu.edu>, TTN@ECL.PSU.EDU (Thien-Thi Nguyen) writes:
>> (define-key some-mode-map '(lambda () (kill-buffer (current-buffer))))

>You're missing an argument to define-key.  The general format is:

>	(define-key KEYMAP KEY DEFINITION)

>You've got the keymap and the definition, but you're missing the key
>itself.  Try something like the following:

>	(define-key some-mode-map "k" '(lambda () .....))

>That would find the given lambda function to the "k" key in the given
>keymap.  For more information on how keys can be specified, see
>"String Type" in the elisp reference.

The correct way to do this is (the example defines M-K to kill current
buffer):
(define-key esc-map "K" 
 '(lambda () (interactive)(kill-buffer (current-buffer))))

You need the KEY field as said over, but the lambda-expression must
also include some version of the "(interactive)" declaration.

Use describe-function (C-h f) on define-key and interactive if you
need more information.

--
----------------------------------------------------------------------
Dag Nummedal numme@itk.unit.no  "Don't blame me, I just work here."
Technical Details
Message-ID: <NUMME.93Jan25001125@mona.itk.unit.no>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ugle.unit.no!ugle.unit.no!numme
References: <hyk1H?8o3c@atlantis.psu.edu> <C1DMuy.Hw2@cs.psu.edu>

Show Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.help
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ugle.unit.no!ugle.unit.no!numme
From: numme@itk.unit.no (Dag Nummedal)
Subject: Re: keymap defs -- using lambda expressions
In-Reply-To: liblit@cs.psu.edu's message of Sun, 24 Jan 1993 21:11:15 GMT
Message-ID: <NUMME.93Jan25001125@mona.itk.unit.no>
Lines: 29
Sender: news@ugle.unit.no (NetNews Administrator)
Organization: Norwegian Institute of Technology / SINTEF, Trondheim, Norway
References: <hyk1H?8o3c@atlantis.psu.edu> <C1DMuy.Hw2@cs.psu.edu>
Date: 24 Jan 93 23:11:25 GMT
Lines: 32