* How to bind keys in emacs?
@ 2005-12-23 7:38 zelzel.zsu
2005-12-23 8:24 ` Pascal Bourguignon
0 siblings, 1 reply; 8+ messages in thread
From: zelzel.zsu @ 2005-12-23 7:38 UTC (permalink / raw)
Subject: How to bind keys in emacs?
hi, I am new to emacs.
can anyone wrote some code for me?
I want to bind some functions to F5, F6 keys.
I want to use F5 keys to serve as C-x C-s [save buffer].
and use F5 keys to serve as C-z [suspend].
What should i write in my ~/.emacs?
Regards.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to bind keys in emacs?
2005-12-23 7:38 How to bind keys in emacs? zelzel.zsu
@ 2005-12-23 8:24 ` Pascal Bourguignon
2005-12-23 18:18 ` Cameron Desautels
[not found] ` <mailman.20269.1135361990.20277.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 8+ messages in thread
From: Pascal Bourguignon @ 2005-12-23 8:24 UTC (permalink / raw)
"zelzel.zsu@gmail.com" <zelzel.zsu@gmail.com> writes:
> Subject: How to bind keys in emacs?
>
> hi, I am new to emacs.
> can anyone wrote some code for me?
>
> I want to bind some functions to F5, F6 keys.
>
> I want to use F5 keys to serve as C-x C-s [save buffer].
> and use F5 keys to serve as C-z [suspend].
>
> What should i write in my ~/.emacs?
If find it strange that you have non-deterministics wants, but here you are:
(global-set-key (kbd "<f5>") (lambda ()
(interactive)
(if (oddp (random 2))
(save-buffer 0)
(if window-system
(iconify-or-deiconify-frame)
(suspend-emacs)))))
--
__Pascal Bourguignon__ http://www.informatimago.com/
In a World without Walls and Fences,
who needs Windows and Gates?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to bind keys in emacs?
2005-12-23 8:24 ` Pascal Bourguignon
@ 2005-12-23 18:18 ` Cameron Desautels
[not found] ` <mailman.20269.1135361990.20277.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 8+ messages in thread
From: Cameron Desautels @ 2005-12-23 18:18 UTC (permalink / raw)
On Fri, Dec 23, 2005 at 09:24:34AM +0100, Pascal Bourguignon wrote:
> > I want to use F5 keys to serve as C-x C-s [save buffer].
> > and use F5 keys to serve as C-z [suspend].
> >
> > What should i write in my ~/.emacs?
>
> If find it strange that you have non-deterministics wants, but here you are:
Hah. I think that was a typo. I think he wants [f5] as save-buffer
and [f6] as suspend. Like so:
(global-set-key [f5] 'save-buffer)
(global-set-key [f6] 'suspend-emacs)
--
Cameron Desautels <cam@apt2324.com>
Given infinite time, 100 monkeys could type out the complete works of
Shakespeare. Win 98 source code? Eight monkeys, five minutes.
^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <mailman.20269.1135361990.20277.help-gnu-emacs@gnu.org>]
* Re: How to bind keys in emacs?
[not found] ` <mailman.20269.1135361990.20277.help-gnu-emacs@gnu.org>
@ 2005-12-23 23:13 ` B. T. Raven
2005-12-23 23:28 ` Pascal Bourguignon
0 siblings, 1 reply; 8+ messages in thread
From: B. T. Raven @ 2005-12-23 23:13 UTC (permalink / raw)
"Cameron Desautels" <cam@apt2324.com> wrote in message
news:mailman.20269.1135361990.20277.help-gnu-emacs@gnu.org...
> On Fri, Dec 23, 2005 at 09:24:34AM +0100, Pascal Bourguignon wrote:
> > > I want to use F5 keys to serve as C-x C-s [save buffer].
> > > and use F5 keys to serve as C-z [suspend].
> > >
> > > What should i write in my ~/.emacs?
> >
> > If find it strange that you have non-deterministics wants, but here
you are:
>
> Hah. I think that was a typo. I think he wants [f5] as save-buffer
> and [f6] as suspend. Like so:
>
> (global-set-key [f5] 'save-buffer)
> (global-set-key [f6] 'suspend-emacs)
> --
> Cameron Desautels <cam@apt2324.com>
>
>
> Given infinite time, 100 monkeys could type out the complete works of
> Shakespeare. Win 98 source code? Eight monkeys, five minutes.
>
>
Or 'iconify-or-deiconify-frame for w32, apparently, instead of
'suspend-emacs. I don't know why this is. Do both work under Linux?
Ed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to bind keys in emacs?
2005-12-23 23:13 ` B. T. Raven
@ 2005-12-23 23:28 ` Pascal Bourguignon
2005-12-24 6:16 ` B. T. Raven
2005-12-24 8:13 ` Eli Zaretskii
0 siblings, 2 replies; 8+ messages in thread
From: Pascal Bourguignon @ 2005-12-23 23:28 UTC (permalink / raw)
"B. T. Raven" <ecinmn@peoplepc.com> writes:
> "Cameron Desautels" <cam@apt2324.com> wrote in message
> news:mailman.20269.1135361990.20277.help-gnu-emacs@gnu.org...
>> On Fri, Dec 23, 2005 at 09:24:34AM +0100, Pascal Bourguignon wrote:
>> > > I want to use F5 keys to serve as C-x C-s [save buffer].
>> > > and use F5 keys to serve as C-z [suspend].
>> > >
>> > > What should i write in my ~/.emacs?
>> >
>> > If find it strange that you have non-deterministics wants, but here
> you are:
>>
>> Hah. I think that was a typo. I think he wants [f5] as save-buffer
>> and [f6] as suspend. Like so:
>>
>> (global-set-key [f5] 'save-buffer)
>> (global-set-key [f6] 'suspend-emacs)
>> --
>> Cameron Desautels <cam@apt2324.com>
>>
>>
>> Given infinite time, 100 monkeys could type out the complete works of
>> Shakespeare. Win 98 source code? Eight monkeys, five minutes.
>>
>>
>
> Or 'iconify-or-deiconify-frame for w32, apparently, instead of
> 'suspend-emacs. I don't know why this is. Do both work under Linux?
Why do you think I wrote:
(if window-system
(iconify-or-deiconify-frame)
(suspend-emacs))
?
--
__Pascal Bourguignon__ http://www.informatimago.com/
PLEASE NOTE: Some quantum physics theories suggest that when the
consumer is not directly observing this product, it may cease to
exist or will exist only in a vague and undetermined state.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to bind keys in emacs?
2005-12-23 23:28 ` Pascal Bourguignon
@ 2005-12-24 6:16 ` B. T. Raven
2005-12-24 7:11 ` Pascal Bourguignon
2005-12-24 8:13 ` Eli Zaretskii
1 sibling, 1 reply; 8+ messages in thread
From: B. T. Raven @ 2005-12-24 6:16 UTC (permalink / raw)
"Pascal Bourguignon" <spam@mouse-potato.com> wrote in message
news:8764pfe6ku.fsf@thalassa.informatimago.com...
> "B. T. Raven" <ecinmn@peoplepc.com> writes:
>
> > "Cameron Desautels" <cam@apt2324.com> wrote in message
> > news:mailman.20269.1135361990.20277.help-gnu-emacs@gnu.org...
> >> On Fri, Dec 23, 2005 at 09:24:34AM +0100, Pascal Bourguignon wrote:
> >> > > I want to use F5 keys to serve as C-x C-s [save buffer].
> >> > > and use F5 keys to serve as C-z [suspend].
> >> > >
> >> > > What should i write in my ~/.emacs?
> >> >
> >> > If find it strange that you have non-deterministics wants, but here
> > you are:
> >>
> >> Hah. I think that was a typo. I think he wants [f5] as save-buffer
> >> and [f6] as suspend. Like so:
> >>
> >> (global-set-key [f5] 'save-buffer)
> >> (global-set-key [f6] 'suspend-emacs)
> >> --
> >> Cameron Desautels <cam@apt2324.com>
> >>
> >>
> >> Given infinite time, 100 monkeys could type out the complete works of
> >> Shakespeare. Win 98 source code? Eight monkeys, five minutes.
> >>
> >>
> >
> > Or 'iconify-or-deiconify-frame for w32, apparently, instead of
> > 'suspend-emacs. I don't know why this is. Do both work under Linux?
>
> Why do you think I wrote:
> (if window-system
> (iconify-or-deiconify-frame)
> (suspend-emacs))
>
> ?
Why do you think I wrote "I don't know why this is":
??
In fact, when I read your code I really didn't understand it. All I did
was identify what was happening with C-z on my (w32) machine. Also I read
that suspend-emacs "makes no sense" in a window environment. Now I know
that window-system can take a value of 'x in addition to 'w32 or nil
(terminal?). I suppose I was flummoxed by the (to my mind) infelicitous
(oddp (random... statement. I don't have oddp or evenp here. Would the op
have learned something if she had obediently added your code to her .emacs
or would he (!) just have seen "Debugger entered--Lisp error:
(void-function oddp)?" Anyway (as we all know) every tyro (randomly male
or female) has certain indeterminate needs.
Ed
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to bind keys in emacs?
2005-12-24 6:16 ` B. T. Raven
@ 2005-12-24 7:11 ` Pascal Bourguignon
0 siblings, 0 replies; 8+ messages in thread
From: Pascal Bourguignon @ 2005-12-24 7:11 UTC (permalink / raw)
"B. T. Raven" <ecinmn@peoplepc.com> writes:
>> > Or 'iconify-or-deiconify-frame for w32, apparently, instead of
>> > 'suspend-emacs. I don't know why this is. Do both work under Linux?
Both work under Linux. This is not the discrimant.
>> Why do you think I wrote:
The discriminant is:
>> (if window-system
>> (iconify-or-deiconify-frame)
>> (suspend-emacs))
>>
>> ?
>
> Why do you think I wrote "I don't know why this is":
> ??
> In fact, when I read your code I really didn't understand it.
Since the OP wrote f5 for both save-buffer and iconify or suspend, I
playfully implemented the non deterministic choice: (random 2)
returns 0 or 1 aleatorily, and oddp test for 1. (I could have used
evenp to test for 0 as well).
> All I did
> was identify what was happening with C-z on my (w32) machine. Also I read
> that suspend-emacs "makes no sense" in a window environment. Now I know
> that window-system can take a value of 'x in addition to 'w32 or nil
> (terminal?).
> I suppose I was flummoxed by the (to my mind) infelicitous
> (oddp (random... statement. I don't have oddp or evenp here.
You should add (require 'cl) to your ~/.emacs
> Would the op
> have learned something if she had obediently added your code to her .emacs
> or would he (!) just have seen "Debugger entered--Lisp error:
> (void-function oddp)?" Anyway (as we all know) every tyro (randomly male
> or female) has certain indeterminate needs.
--
__Pascal Bourguignon__ http://www.informatimago.com/
In a World without Walls and Fences,
who needs Windows and Gates?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to bind keys in emacs?
2005-12-23 23:28 ` Pascal Bourguignon
2005-12-24 6:16 ` B. T. Raven
@ 2005-12-24 8:13 ` Eli Zaretskii
1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2005-12-24 8:13 UTC (permalink / raw)
> From: Pascal Bourguignon <spam@mouse-potato.com>
> Date: Sat, 24 Dec 2005 00:28:49 +0100
>
> > Or 'iconify-or-deiconify-frame for w32, apparently, instead of
> > 'suspend-emacs. I don't know why this is. Do both work under Linux?
>
> Why do you think I wrote:
> (if window-system
> (iconify-or-deiconify-frame)
> (suspend-emacs))
>
> ?
(I'm not the OP) I don't know why, I only know that `window-system' is
``considered harmful''. In this case, you should use
`display-multi-frame-p' or `(fboundp 'iconify-or-deiconify-frame)'
instead. That's because `window-system' doesn't say anything about
the underlying functionality, so it's better to use predicates which
do. (As a matter of fact, there's at least one Emacs configuration
that has non-nil `window-system', but doesn't support iconify.)
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-12-24 8:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-23 7:38 How to bind keys in emacs? zelzel.zsu
2005-12-23 8:24 ` Pascal Bourguignon
2005-12-23 18:18 ` Cameron Desautels
[not found] ` <mailman.20269.1135361990.20277.help-gnu-emacs@gnu.org>
2005-12-23 23:13 ` B. T. Raven
2005-12-23 23:28 ` Pascal Bourguignon
2005-12-24 6:16 ` B. T. Raven
2005-12-24 7:11 ` Pascal Bourguignon
2005-12-24 8:13 ` Eli Zaretskii
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).