Skip to content

Instantly share code, notes, and snippets.

@clarkgrubb
Created August 26, 2012 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkgrubb/3481345 to your computer and use it in GitHub Desktop.
Save clarkgrubb/3481345 to your computer and use it in GitHub Desktop.
(defun undo-only (&optional arg)
"Undo some previous changes.
Repeat this command to undo more changes.
A numeric ARG serves as a repeat count.
Contrary to `undo', this will not redo a previous undo."
(interactive "*p")
(let ((undo-no-redo t))
(undo arg)
;; assume undo succeeded and overwrite
;; what it wrote.
(message "%s" (if (or (region-active-p) (and arg (not (numberp arg))))
"Undo in region!"
"Undo!"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment