* Capture ALL keystrokes
@ 2008-05-29 10:36 Ben Forbes
2008-05-29 11:11 ` Daniel Pittman
0 siblings, 1 reply; 7+ messages in thread
From: Ben Forbes @ 2008-05-29 10:36 UTC (permalink / raw)
To: help-gnu-emacs
When some keystroke A is entered, I set a flag, and I want this flag
to be unset if any keystroke is entered except some keystroke B. So
basically, I only want keystroke B to have any effect if it is
preceded by keystroke A. How can I do this?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Capture ALL keystrokes
2008-05-29 10:36 Capture ALL keystrokes Ben Forbes
@ 2008-05-29 11:11 ` Daniel Pittman
2008-05-29 12:01 ` Ben Forbes
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Pittman @ 2008-05-29 11:11 UTC (permalink / raw)
To: help-gnu-emacs
"Ben Forbes" <bdforbes@gmail.com> writes:
> When some keystroke A is entered, I set a flag, and I want this flag
> to be unset if any keystroke is entered except some keystroke B. So
> basically, I only want keystroke B to have any effect if it is
> preceded by keystroke A. How can I do this?
The standard way would be:
(define-key global-map [(a)(b)] #'my-function)
Alternately, make a keymap, point the `a' key to it, and then install
handlers into it.
Your approach is, in essence, "doing it wrong."
Regards,
Daniel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Capture ALL keystrokes
2008-05-29 11:11 ` Daniel Pittman
@ 2008-05-29 12:01 ` Ben Forbes
2008-05-29 13:32 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 7+ messages in thread
From: Ben Forbes @ 2008-05-29 12:01 UTC (permalink / raw)
To: Daniel Pittman; +Cc: help-gnu-emacs
Yes I thought my approach seemed too complex. I don't think your first
suggestion will work, because I want to be able to hit AB, ABB, ABBB,
ABBBB etc, where each repeated keystroke B repeats the command. Could
you expand on the second option? It sounds promising, thanks.
On Thu, May 29, 2008 at 9:11 PM, Daniel Pittman <daniel@rimspace.net> wrote:
> "Ben Forbes" <bdforbes@gmail.com> writes:
>
>> When some keystroke A is entered, I set a flag, and I want this flag
>> to be unset if any keystroke is entered except some keystroke B. So
>> basically, I only want keystroke B to have any effect if it is
>> preceded by keystroke A. How can I do this?
>
> The standard way would be:
>
> (define-key global-map [(a)(b)] #'my-function)
>
> Alternately, make a keymap, point the `a' key to it, and then install
> handlers into it.
>
> Your approach is, in essence, "doing it wrong."
>
> Regards,
> Daniel
>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Capture ALL keystrokes
2008-05-29 12:01 ` Ben Forbes
@ 2008-05-29 13:32 ` Lennart Borgman (gmail)
2008-05-29 15:10 ` Tassilo Horn
0 siblings, 1 reply; 7+ messages in thread
From: Lennart Borgman (gmail) @ 2008-05-29 13:32 UTC (permalink / raw)
To: Ben Forbes; +Cc: Daniel Pittman, help-gnu-emacs
Have a look at kmacro-call-macro which does something similar. It is
bound to "C-x e" and you repeat it with just "e".
Ben Forbes wrote:
> Yes I thought my approach seemed too complex. I don't think your first
> suggestion will work, because I want to be able to hit AB, ABB, ABBB,
> ABBBB etc, where each repeated keystroke B repeats the command. Could
> you expand on the second option? It sounds promising, thanks.
>
> On Thu, May 29, 2008 at 9:11 PM, Daniel Pittman <daniel@rimspace.net> wrote:
>> "Ben Forbes" <bdforbes@gmail.com> writes:
>>
>>> When some keystroke A is entered, I set a flag, and I want this flag
>>> to be unset if any keystroke is entered except some keystroke B. So
>>> basically, I only want keystroke B to have any effect if it is
>>> preceded by keystroke A. How can I do this?
>> The standard way would be:
>>
>> (define-key global-map [(a)(b)] #'my-function)
>>
>> Alternately, make a keymap, point the `a' key to it, and then install
>> handlers into it.
>>
>> Your approach is, in essence, "doing it wrong."
>>
>> Regards,
>> Daniel
>>
>>
>>
>>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Capture ALL keystrokes
2008-05-29 13:32 ` Lennart Borgman (gmail)
@ 2008-05-29 15:10 ` Tassilo Horn
0 siblings, 0 replies; 7+ messages in thread
From: Tassilo Horn @ 2008-05-29 15:10 UTC (permalink / raw)
To: help-gnu-emacs
"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
Hi,
> Have a look at kmacro-call-macro which does something similar. It is
> bound to "C-x e" and you repeat it with just "e".
Another possibility is to use a timer and a minor mode. The first
keystroke enables the mode which will be disabled by a timer. Any
further keystroke resets the timer to its initial value.
If you use EMMS, have a look at
,----
| C-c + runs the command emms-volume-mode-plus, which is an interactive compiled
| Lisp function in `emms-volume.el'.
|
| It is bound to C-c +.
|
| (emms-volume-mode-plus)
|
| Raise volume and enable or extend the `emms-volume-minor-mode' timeout.
`----
Bye,
Tassilo
^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.12372.1212057381.18990.help-gnu-emacs@gnu.org>]
* Re: Capture ALL keystrokes
[not found] <mailman.12372.1212057381.18990.help-gnu-emacs@gnu.org>
@ 2008-05-30 9:57 ` harven
2008-05-30 11:21 ` Ben Forbes
0 siblings, 1 reply; 7+ messages in thread
From: harven @ 2008-05-30 9:57 UTC (permalink / raw)
To: help-gnu-emacs
On May 29, 12:36 pm, "Ben Forbes" <bdfor...@gmail.com> wrote:
> When some keystroke A is entered, I set a flag, and I want this flag
> to be unset if any keystroke is entered except some keystroke B. So
> basically, I only want keystroke B to have any effect if it is
> preceded by keystroke A. How can I do this?
Be more specific about what you are trying to achieve.
Bound the following command to key A. Pressing the A key
inserts the letter A. It then executes the command newline
repeatedly if B is pressed any amount of time.
(defun my-command ()
"After key A, key B executes the command newline repeatedly"
(interactive)
(insert "A")
(while (equal (setq key (read-event)) ?B)
(next-line))
(push key unread-command-events))
(global-set-key "A" 'my-command)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Capture ALL keystrokes
2008-05-30 9:57 ` harven
@ 2008-05-30 11:21 ` Ben Forbes
0 siblings, 0 replies; 7+ messages in thread
From: Ben Forbes @ 2008-05-30 11:21 UTC (permalink / raw)
To: harven; +Cc: help-gnu-emacs
> (defun my-command ()
> "After key A, key B executes the command newline repeatedly"
> (interactive)
> (insert "A")
> (while (equal (setq key (read-event)) ?B)
> (next-line))
> (push key unread-command-events))
>
> (global-set-key "A" 'my-command)
>
That approach works quite well, thanks. My goal was to be able to call
emms-random with a single keystroke when the initial call required two
keystrokes. This is because I've put all my emms keystrokes after
C-H-s-c to keep them organized. Now I can hit C-H-s-c C-H-s-r to call
emms-random once, and every time I hit C-H-s-r after that, it calls
emms-random again. It's a bit frivolous I guess, but it was more about
learning emacs programming than anything else. Thanks for the help
everyone.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-05-30 11:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-29 10:36 Capture ALL keystrokes Ben Forbes
2008-05-29 11:11 ` Daniel Pittman
2008-05-29 12:01 ` Ben Forbes
2008-05-29 13:32 ` Lennart Borgman (gmail)
2008-05-29 15:10 ` Tassilo Horn
[not found] <mailman.12372.1212057381.18990.help-gnu-emacs@gnu.org>
2008-05-30 9:57 ` harven
2008-05-30 11:21 ` Ben Forbes
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).