[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
- [IDEA] Add function clean-buffer,
Joseph Turner <=
- Re: [IDEA] Add function clean-buffer, Philip Kaludercic, 2023/09/04
- Re: [IDEA] Add function clean-buffer, Richard Stallman, 2023/09/08
- Re: [IDEA] Add function clean-buffer, Joseph Turner, 2023/09/09
- Re: [IDEA] Add function clean-buffer, Eli Zaretskii, 2023/09/09
- Re: [IDEA] Add function clean-buffer, Stefan Kangas, 2023/09/10