emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IDEA] Add function clean-buffer


From: Joseph Turner
Subject: [IDEA] Add function clean-buffer
Date: Sun, 03 Sep 2023 15:18:59 -0700

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]