Philip Kaludercic writes: > Joseph Turner writes: > >> Prompted by Daniel Mendler's comment here: >> >> https://github.com/emacs-compat/compat/issues/27#issuecomment-1704381157 >> >> IIUC, clean-mode is intended for interactive, debugging usage. I am >> interested in a function that performs some of the internal behavior of >> the Emacs 29 clean-mode in non-interactive use. Note that >> yank-excluded-properties is not set in clean-buffer. > > Perhaps you could explain what the concrete example is where you need > the functionality? In hyperdrive.el, when writing an existing buffer to a hyperdrive file, we want to first remove overlays, text properties, and local variables, and then use set-auto-mode to set the major mode (along with its overlays, text properties, and local variable). The reason for doing this is so that after writing a buffer to a file, users will see the buffer as it will appear on another peer's machine. For example, if you call hyperdrive-write-buffer on a magit log buffer, we want the overlays to disappear so that users don't expect others to be able to see the overlays when they load the file. >> (defun clean-buffer (&optional buffer) >> "Remove all local variables, overlays, and text properties in BUFFER. >> When BUFFER is nil, act on current buffer." >> (with-current-buffer (or buffer (current-buffer)) >> (kill-all-local-variables t) >> (let ((inhibit-read-only t)) >> (dolist (overlay (overlays-in (point-min) (point-max))) >> (delete-overlay overlay)) >> (set-text-properties (point-min) (point-max) nil)))) >> >> It could also be used internally in clean-mode. > > Could you prepare this as a patch? See attached patches. I'm not sure if subr.el is the right place for this change, and I haven't added added to the NEWS file.