emacs-devel
[Top][All Lists]
Advanced

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

Re: [IDEA] Add function clean-buffer


From: David Ponce
Subject: Re: [IDEA] Add function clean-buffer
Date: Fri, 8 Sep 2023 11:13:45 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0

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!



reply via email to

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