* [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
* Re: [IDEA] Add function clean-buffer
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
0 siblings, 1 reply; 12+ messages in thread
From: Philip Kaludercic @ 2023-09-04 16:02 UTC (permalink / raw)
To: Joseph Turner; +Cc: Emacs Devel Mailing List, mail+gh
Joseph Turner <joseph@breatheoutbreathe.in> 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?
>
> (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?
> Joseph
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-04 16:02 ` Philip Kaludercic
@ 2023-09-05 19:37 ` Joseph Turner
2023-09-06 11:59 ` Eli Zaretskii
0 siblings, 1 reply; 12+ messages in thread
From: Joseph Turner @ 2023-09-05 19:37 UTC (permalink / raw)
To: Philip Kaludercic; +Cc: Emacs Devel Mailing List, mail+gh
[-- Attachment #1: Type: text/plain, Size: 1867 bytes --]
Philip Kaludercic <philipk@posteo.net> writes:
> Joseph Turner <joseph@breatheoutbreathe.in> 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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-new-function-clean-buffer.patch --]
[-- Type: text/x-diff, Size: 1289 bytes --]
From 6253633af98240f1f3ad2d00888cec945de5d708 Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
Date: Tue, 5 Sep 2023 12:28:49 -0700
Subject: [PATCH 1/2] Add new function clean-buffer
* lisp/subr.el (clean-buffer):
Removes all local variables, overlays, and text properties.
---
lisp/subr.el | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lisp/subr.el b/lisp/subr.el
index 6cedaffa806..cd4149c0a79 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4694,6 +4694,16 @@ Normally, mouse motion is ignored."
(declare (debug (def-body)) (indent 0))
`(internal--track-mouse (lambda () ,@body)))
+(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))))
+
(defmacro with-current-buffer (buffer-or-name &rest body)
"Execute the forms in BODY with BUFFER-OR-NAME temporarily current.
BUFFER-OR-NAME must be a buffer or the name of an existing buffer.
--
2.41.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Refactor-clean-mode-to-use-clean-buffer.patch --]
[-- Type: text/x-diff, Size: 1310 bytes --]
From dfb0ac3d7ae03d8e9dffd1d447afe0a604a49960 Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
Date: Tue, 5 Sep 2023 12:34:23 -0700
Subject: [PATCH 2/2] Refactor clean-mode to use clean-buffer
* lisp/simple.el (clean-mode):
Use clean-mode internally. Clarify docstring.
---
lisp/simple.el | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index 05a3c4b93d6..37d76c174dc 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -546,13 +546,11 @@ Other major modes are defined by comparison with this one."
(run-mode-hooks))
(define-derived-mode clean-mode fundamental-mode "Clean"
- "A mode that removes all overlays and text properties."
- (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)
- (setq-local yank-excluded-properties t)))
+ "Mode removing all local variables, overlays, and text properties.
+This mode is intended for debugging purposes. For non-interactive
+use, see `clean-buffer'."
+ (clean-buffer)
+ (setq-local yank-excluded-properties t))
;; Special major modes to view specially formatted data rather than files.
--
2.41.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-05 19:37 ` Joseph Turner
@ 2023-09-06 11:59 ` Eli Zaretskii
2023-09-08 4:55 ` Joseph Turner
2023-09-09 0:38 ` Richard Stallman
0 siblings, 2 replies; 12+ messages in thread
From: Eli Zaretskii @ 2023-09-06 11:59 UTC (permalink / raw)
To: Joseph Turner; +Cc: philipk, emacs-devel, mail+gh
> From: Joseph Turner <joseph@breatheoutbreathe.in>
> Cc: Emacs Devel Mailing List <emacs-devel@gnu.org>, mail+gh@daniel-mendler.de
> Date: Tue, 05 Sep 2023 12:37:30 -0700
>
> +(defun clean-buffer (&optional buffer)
> + "Remove all local variables, overlays, and text properties in BUFFER.
> + When BUFFER is nil, act on current buffer."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Our usual style is to say
BUFFER defaults to the current buffer.
or
If BUFFER is omitted or nil, it defaults to the 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))))
> (define-derived-mode clean-mode fundamental-mode "Clean"
> - "A mode that removes all overlays and text properties."
> - (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)
> - (setq-local yank-excluded-properties t)))
> + "Mode removing all local variables, overlays, and text properties.
Why not the original "Mode that removes"?
> +This mode is intended for debugging purposes. For non-interactive
^^
Two spaces between sentences, please.
Also, why "For non-interactive use"? The opposite of "debugging
purposes" is something like "for other purposes".
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-06 11:59 ` Eli Zaretskii
@ 2023-09-08 4:55 ` Joseph Turner
2023-09-08 9:13 ` David Ponce
2023-09-09 0:38 ` Richard Stallman
1 sibling, 1 reply; 12+ messages in thread
From: Joseph Turner @ 2023-09-08 4:55 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: philipk, emacs-devel, mail+gh
[-- Attachment #1: Type: text/plain, Size: 1732 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Joseph Turner <joseph@breatheoutbreathe.in>
>> Cc: Emacs Devel Mailing List <emacs-devel@gnu.org>, mail+gh@daniel-mendler.de
>> Date: Tue, 05 Sep 2023 12:37:30 -0700
>>
>> +(defun clean-buffer (&optional buffer)
>> + "Remove all local variables, overlays, and text properties in BUFFER.
>> + When BUFFER is nil, act on current buffer."
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Our usual style is to say
>
> BUFFER defaults to the current buffer.
>
> or
>
> If BUFFER is omitted or nil, it defaults to the 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))))
>
>> (define-derived-mode clean-mode fundamental-mode "Clean"
>> - "A mode that removes all overlays and text properties."
>> - (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)
>> - (setq-local yank-excluded-properties t)))
>> + "Mode removing all local variables, overlays, and text properties.
>
> Why not the original "Mode that removes"?
>
>> +This mode is intended for debugging purposes. For non-interactive
> ^^
> Two spaces between sentences, please.
>
> Also, why "For non-interactive use"? The opposite of "debugging
> purposes" is something like "for other purposes".
Thanks for the corrections. See patches.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-new-function-clean-buffer.patch --]
[-- Type: text/x-diff, Size: 1284 bytes --]
From 1f19e97545f858067b2ac345b92fcc27165b3bc1 Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
Date: Tue, 5 Sep 2023 12:28:49 -0700
Subject: [PATCH 1/2] Add new function clean-buffer
* lisp/subr.el (clean-buffer):
Removes all local variables, overlays, and text properties.
---
lisp/subr.el | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lisp/subr.el b/lisp/subr.el
index 34d87e83310..edf96124ec6 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4694,6 +4694,16 @@ Normally, mouse motion is ignored."
(declare (debug (def-body)) (indent 0))
`(internal--track-mouse (lambda () ,@body)))
+(defun clean-buffer (&optional buffer)
+ "Remove all local variables, overlays, and text properties in BUFFER.
+BUFFER defaults to the 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))))
+
(defmacro with-current-buffer (buffer-or-name &rest body)
"Execute the forms in BODY with BUFFER-OR-NAME temporarily current.
BUFFER-OR-NAME must be a buffer or the name of an existing buffer.
--
2.41.0
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Refactor-clean-mode-to-use-clean-buffer.patch --]
[-- Type: text/x-diff, Size: 1306 bytes --]
From a909cf811e0eb10fca8df4080454bb310e0d510d Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
Date: Tue, 5 Sep 2023 12:34:23 -0700
Subject: [PATCH 2/2] Refactor clean-mode to use clean-buffer
* lisp/simple.el (clean-mode):
Use clean-mode internally. Clarify docstring.
---
lisp/simple.el | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index 05a3c4b93d6..d61a88223ad 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -546,13 +546,11 @@ Other major modes are defined by comparison with this one."
(run-mode-hooks))
(define-derived-mode clean-mode fundamental-mode "Clean"
- "A mode that removes all overlays and text properties."
- (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)
- (setq-local yank-excluded-properties t)))
+ "Mode removing all local variables, overlays, and text properties.
+This mode is intended for debugging purposes. For other purposes,
+see `clean-buffer'."
+ (clean-buffer)
+ (setq-local yank-excluded-properties t))
;; Special major modes to view specially formatted data rather than files.
--
2.41.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-08 4:55 ` Joseph Turner
@ 2023-09-08 9:13 ` David Ponce
2023-09-08 17:21 ` Joseph Turner
0 siblings, 1 reply; 12+ messages in thread
From: David Ponce @ 2023-09-08 9:13 UTC (permalink / raw)
To: Joseph Turner, Eli Zaretskii; +Cc: philipk, emacs-devel, mail+gh
On 08/09/2023 06:55, Joseph Turner wrote:
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Joseph Turner <joseph@breatheoutbreathe.in>
>>> Cc: Emacs Devel Mailing List <emacs-devel@gnu.org>, mail+gh@daniel-mendler.de
>>> Date: Tue, 05 Sep 2023 12:37:30 -0700
>>>
>>> +(defun clean-buffer (&optional buffer)
>>> + "Remove all local variables, overlays, and text properties in BUFFER.
>>> + When BUFFER is nil, act on current buffer."
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> Our usual style is to say
>>
>> BUFFER defaults to the current buffer.
>>
>> or
>>
>> If BUFFER is omitted or nil, it defaults to the 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))))
>>
>>> (define-derived-mode clean-mode fundamental-mode "Clean"
>>> - "A mode that removes all overlays and text properties."
>>> - (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)
>>> - (setq-local yank-excluded-properties t)))
>>> + "Mode removing all local variables, overlays, and text properties.
>>
>> Why not the original "Mode that removes"?
>>
>>> +This mode is intended for debugging purposes. For non-interactive
>> ^^
>> Two spaces between sentences, please.
>>
>> Also, why "For non-interactive use"? The opposite of "debugging
>> purposes" is something like "for other purposes".
>
> Thanks for the corrections. See patches.
>
Hi all,
A naive question: is there any reason to not use the builtin
`delete-all-overlays' instead of an explicit loop, to delete
every overlay?
Thanks!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-08 9:13 ` David Ponce
@ 2023-09-08 17:21 ` Joseph Turner
0 siblings, 0 replies; 12+ messages in thread
From: Joseph Turner @ 2023-09-08 17:21 UTC (permalink / raw)
To: David Ponce; +Cc: Eli Zaretskii, philipk, emacs-devel, mail+gh
> A naive question: is there any reason to not use the builtin
> `delete-all-overlays' instead of an explicit loop, to delete
> every overlay?
I just extracted the code verbatim from clean-mode into clean-buffer.
If others agree that delete-all-overlays would be more appropriate,
I'll submit a second patch.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-06 11:59 ` Eli Zaretskii
2023-09-08 4:55 ` Joseph Turner
@ 2023-09-09 0:38 ` Richard Stallman
2023-09-09 0:59 ` Joseph Turner
1 sibling, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2023-09-09 0:38 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: joseph, emacs-devel, mail+gh
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
Why make this command kill local variables?
Most buffer-local variables come from the major mode.
Is it really desirable to reliminate the major mode?
Eliminating the major mode is what `fundamental-mode' does.
Text properties are usually related to the major mode,
often due to Font Lock mode.
Should `fundamental-mode' eliminate text properties? Or perhaps only
some text properties?
Should `clean-buffer' eliminate only the text properties and overlays
that do NOT come from the major mode?
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-09 0:38 ` Richard Stallman
@ 2023-09-09 0:59 ` Joseph Turner
2023-09-09 7:00 ` Eli Zaretskii
0 siblings, 1 reply; 12+ messages in thread
From: Joseph Turner @ 2023-09-09 0:59 UTC (permalink / raw)
To: rms, Richard Stallman, Eli Zaretskii; +Cc: emacs-devel, mail+gh
On September 8, 2023 5:38:46 PM PDT, Richard Stallman <rms@gnu.org> wrote:
>[[[ To any NSA and FBI agents reading my email: please consider ]]]
>[[[ whether defending the US Constitution against all enemies, ]]]
>[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>Why make this command kill local variables?
>Most buffer-local variables come from the major mode.
>Is it really desirable to reliminate the major mode?
>
>Eliminating the major mode is what `fundamental-mode' does.
>Text properties are usually related to the major mode,
>often due to Font Lock mode.
>
>Should `fundamental-mode' eliminate text properties? Or perhaps only
>some text properties?
>
>Should `clean-buffer' eliminate only the text properties and overlays
>that do NOT come from the major mode?
I'm also concerned that clean-buffer is too vague a function name, and so the scope of its behavior is not clear. I can see that some programs may want to "clean a buffer" by eliminating text properties and overlays but not killing local variables, whereas others may want to do all three and potentially something else.
At this point, I'm open to letting this patch go ignored.
Thank you for considering this idea with me!
Joseph
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-09 0:59 ` Joseph Turner
@ 2023-09-09 7:00 ` Eli Zaretskii
2023-09-10 8:19 ` Stefan Kangas
0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2023-09-09 7:00 UTC (permalink / raw)
To: Joseph Turner, Stefan Kangas; +Cc: rms, rms, emacs-devel, mail+gh
> Date: Fri, 08 Sep 2023 17:59:53 -0700
> From: Joseph Turner <joseph@breatheoutbreathe.in>
> CC: emacs-devel@gnu.org, mail+gh@daniel-mendler.de
>
> >Why make this command kill local variables?
> >Most buffer-local variables come from the major mode.
> >Is it really desirable to reliminate the major mode?
> >
> >Eliminating the major mode is what `fundamental-mode' does.
> >Text properties are usually related to the major mode,
> >often due to Font Lock mode.
> >
> >Should `fundamental-mode' eliminate text properties? Or perhaps only
> >some text properties?
> >
> >Should `clean-buffer' eliminate only the text properties and overlays
> >that do NOT come from the major mode?
>
> I'm also concerned that clean-buffer is too vague a function name, and so the scope of its behavior is not clear. I can see that some programs may want to "clean a buffer" by eliminating text properties and overlays but not killing local variables, whereas others may want to do all three and potentially something else.
>
> At this point, I'm open to letting this patch go ignored.
Stefan, what is your view on this?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-09 7:00 ` Eli Zaretskii
@ 2023-09-10 8:19 ` Stefan Kangas
2023-09-12 0:29 ` Richard Stallman
0 siblings, 1 reply; 12+ messages in thread
From: Stefan Kangas @ 2023-09-10 8:19 UTC (permalink / raw)
To: Eli Zaretskii, Joseph Turner; +Cc: rms, emacs-devel, mail+gh
Eli Zaretskii <eliz@gnu.org> writes:
>> I'm also concerned that clean-buffer is too vague a function name,
>> and so the scope of its behavior is not clear. I can see that some
>> programs may want to "clean a buffer" by eliminating text properties
>> and overlays but not killing local variables, whereas others may want
>> to do all three and potentially something else.
>>
>> At this point, I'm open to letting this patch go ignored.
>
> Stefan, what is your view on this?
I agree with Richard that invoking fundamental-mode is the way to kill
local variables. I don't see that job as tightly connected to killing
overlays and text properties, mostly because I often find it useful to
keep the latter.
Perhaps a command `clean-buffer' that just gets rid of overlays and text
properties, without killing local variables, would make more sense. But
if this is a specific need only for hyperdrive.el, such a command might
belong in that package?
Richard Stallman <rms@gnu.org> writes:
> Should `fundamental-mode' eliminate text properties? Or perhaps only
> some text properties?
It's worth considering the case `read-only'. I often find it
inconvenient in situations like, e.g.
(progn
(pop-to-buffer "test")
(insert (propertize "foo" 'read-only t))
(fundamental-mode)
(insert (propertize "bar"))) ; errors out
I'm not so sure about other text properties though. I guess they'd each
need to be considered separately.
> Should `clean-buffer' eliminate only the text properties and overlays
> that do NOT come from the major mode?
How could one know where they "come from"?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [IDEA] Add function clean-buffer
2023-09-10 8:19 ` Stefan Kangas
@ 2023-09-12 0:29 ` Richard Stallman
0 siblings, 0 replies; 12+ messages in thread
From: Richard Stallman @ 2023-09-12 0:29 UTC (permalink / raw)
To: Stefan Kangas; +Cc: eliz, joseph, emacs-devel, mail+gh
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> > Should `clean-buffer' eliminate only the text properties and overlays
> > that do NOT come from the major mode?
> How could one know where they "come from"?
We can set up a way for major modes to declare which properties
they create and manipulate -- if we want to have that information.
I am not sure we do.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
^ 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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).