all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [IDEA] Add function clean-buffer
@ 2023-09-03 22:18 Joseph Turner
  2023-09-04 16:02 ` Philip Kaludercic
  0 siblings, 1 reply; 12+ messages in thread
From: Joseph Turner @ 2023-09-03 22:18 UTC (permalink / raw)
  To: Emacs Devel Mailing List; +Cc: Philip Kaludercic, mail+gh

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.

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

Joseph



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-09-12  0:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-03 22:18 [IDEA] Add function clean-buffer Joseph Turner
2023-09-04 16:02 ` Philip Kaludercic
2023-09-05 19:37   ` Joseph Turner
2023-09-06 11:59     ` Eli Zaretskii
2023-09-08  4:55       ` Joseph Turner
2023-09-08  9:13         ` David Ponce
2023-09-08 17:21           ` Joseph Turner
2023-09-09  0:38       ` Richard Stallman
2023-09-09  0:59         ` Joseph Turner
2023-09-09  7:00           ` Eli Zaretskii
2023-09-10  8:19             ` Stefan Kangas
2023-09-12  0:29               ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.