Elisp: Enable Undo in Buffer

By Xah Lee. Date: . Last updated: .

How to enable undo in output/temp buffer?

(buffer-enable-undo)
(buffer-disable-undo)

when writing elisp command, sometimes your command generates a output buffer. You can enable undo in that buffer, so user who might use that buffer will have undo.

to enable, just call buffer-enable-undo, or set buffer-undo-list to nil in that buffer. Example:

(with-output-to-temp-buffer outputBuffer
  ;;   (switch-to-buffer outputBuffer)
  (buffer-enable-undo))

Thanks to jcs at irreal.org

Put $5 at https://www.patreon.com/xahlee , or goto paypal.com and pay to Xah@XahLee.org . Message me on XahLee discord, say so, ask me questions.
Or Buy Xah Emacs Tutorial