help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How does `undo` know that `keyboard-quit`has been called?


From: Drew Adams
Subject: RE: How does `undo` know that `keyboard-quit`has been called?
Date: Fri, 7 Nov 2014 14:02:48 -0800 (PST)

> 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`.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]