* Basic elisp question: bind key to function with arg
@ 2015-01-25 23:12 Tory S. Anderson
2015-01-25 23:16 ` Dmitry Gutov
0 siblings, 1 reply; 3+ messages in thread
From: Tory S. Anderson @ 2015-01-25 23:12 UTC (permalink / raw)
To: emacs list
I have the following in my emacs init, and it works fine:
(global-set-key [C-up] 'enlarge-window)
(global-set-key [C-down] (lambda () (interactive)
(enlarge-window -1)))
But it seems awkward to me that I need to add all the extra just to pass a -1 arg to the function, so I'm suspecting there's a simpler way to write this. Any tips?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Basic elisp question: bind key to function with arg
2015-01-25 23:12 Basic elisp question: bind key to function with arg Tory S. Anderson
@ 2015-01-25 23:16 ` Dmitry Gutov
2015-01-25 23:57 ` Marcin Borkowski
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Gutov @ 2015-01-25 23:16 UTC (permalink / raw)
To: Tory S. Anderson, emacs list
On 01/26/2015 01:12 AM, torys.anderson@gmail.com (Tory S. Anderson) wrote:
> I have the following in my emacs init, and it works fine:
>
> (global-set-key [C-up] 'enlarge-window)
> (global-set-key [C-down] (lambda () (interactive)
> (enlarge-window -1)))
>
> But it seems awkward to me that I need to add all the extra just to pass a -1 arg to the function, so I'm suspecting there's a simpler way to write this. Any tips?
No, that's how you do it. Or you create a named function doing the same,
and bind it instead.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Basic elisp question: bind key to function with arg
2015-01-25 23:16 ` Dmitry Gutov
@ 2015-01-25 23:57 ` Marcin Borkowski
0 siblings, 0 replies; 3+ messages in thread
From: Marcin Borkowski @ 2015-01-25 23:57 UTC (permalink / raw)
To: Tory S. Anderson, emacs list
On 2015-01-26, at 00:16, Dmitry Gutov <dgutov@yandex.ru> wrote:
> On 01/26/2015 01:12 AM, torys.anderson@gmail.com (Tory S. Anderson) wrote:
>> I have the following in my emacs init, and it works fine:
>>
>> (global-set-key [C-up] 'enlarge-window)
>> (global-set-key [C-down] (lambda () (interactive)
>> (enlarge-window -1)))
>>
>> But it seems awkward to me that I need to add all the extra just to pass a -1 arg to the function, so I'm suspecting there's a simpler way to write this. Any tips?
>
> No, that's how you do it. Or you create a named function doing the same,
> and bind it instead.
And creating a named function is imho slightly better, since the result
of C-h c is not very readable with a lambda.
Hth,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-25 23:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-25 23:12 Basic elisp question: bind key to function with arg Tory S. Anderson
2015-01-25 23:16 ` Dmitry Gutov
2015-01-25 23:57 ` Marcin Borkowski
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).