Is there a way so that the Emacs are able to tell if the current user is undoing/redoing in the current buffer?

Here is the task I want to accomplish, I have add a hook to after-change-function, it all works out great exclusive of when I hit undo/redo this hook get called too. And this is what I want to avoid... Is there other way to get around this issue?

  • 2
    Welcome. Can you give an example of what you are trying to use this for? – Andrew Swann Dec 2 '18 at 12:04

C-hv undo-in-progress

Non-nil while performing an undo.
Some change-hooks test this variable to do something different.

Bearing in mind that "redoing" is really still "undoing" in Emacs, this ought to cover all cases.

  • 1
    @Jen-ChiehShen : please upvote and accept the answer if it resolves the problem. Thanks! – Dan Dec 2 '18 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.