* How does `undo` know that `keyboard-quit`has been called?
@ 2014-11-07 21:36 Raffaele Ricciardi
2014-11-07 22:02 ` Stefan Monnier
2014-11-07 22:02 ` Drew Adams
0 siblings, 2 replies; 3+ messages in thread
From: Raffaele Ricciardi @ 2014-11-07 21:36 UTC (permalink / raw)
To: help-gnu-emacs
I would like to write a command that behaves like `undo`, that is: a
command that reverses its behaviour when the user calls `keyboard-quit`.
I have read the Lisp code for both `undo` and `keyboard-quit` and I
can't understand how `undo` achieves such behaviour. (I know that I
could always advise `keyboard-quit`.)
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How does `undo` know that `keyboard-quit`has been called?
2014-11-07 21:36 How does `undo` know that `keyboard-quit`has been called? Raffaele Ricciardi
@ 2014-11-07 22:02 ` Stefan Monnier
2014-11-07 22:02 ` Drew Adams
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2014-11-07 22:02 UTC (permalink / raw)
To: help-gnu-emacs
> I would like to write a command that behaves like `undo`, that is: a command
> that reverses its behaviour when the user calls `keyboard-quit`. I have read
> the Lisp code for both `undo` and `keyboard-quit` and I can't understand how
> `undo` achieves such behaviour. (I know that I could always advise
> `keyboard-quit`.)
undo reverses its behavior after any other command than undo.
I.e. keyboard-quit is not special in this respect. The only part that's
special about keyboard-quit is that if you use it like that, it
typically doesn't do anything else (well, it beeps).
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: How does `undo` know that `keyboard-quit`has been called?
2014-11-07 21:36 How does `undo` know that `keyboard-quit`has been called? Raffaele Ricciardi
2014-11-07 22:02 ` Stefan Monnier
@ 2014-11-07 22:02 ` Drew Adams
1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2014-11-07 22:02 UTC (permalink / raw)
To: Raffaele Ricciardi, help-gnu-emacs
> I would like to write a command that behaves like `undo`, that is: a
> command that reverses its behaviour when the user calls `keyboard-
> quit`.
> I have read the Lisp code for both `undo` and `keyboard-quit` and
> I can't understand how `undo` achieves such behaviour. (I know that I
> could always advise `keyboard-quit`.)
If you just want to stop doing something when a user hits `C-g'
then wrap `condition-case' around the doing of the something:
(condition-case nil
(do-something)
(quit (handle-C-g-however-you-like)))
See the Elisp manual, node `Handling Errors`.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-07 22:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07 21:36 How does `undo` know that `keyboard-quit`has been called? Raffaele Ricciardi
2014-11-07 22:02 ` Stefan Monnier
2014-11-07 22:02 ` Drew Adams
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).