From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: David Ponce Newsgroups: gmane.emacs.devel Subject: Re: [IDEA] Add function clean-buffer Date: Fri, 8 Sep 2023 11:13:45 +0200 Message-ID: References: <87il8qx50p.fsf@breatheoutbreathe.in> <87ledm6i68.fsf@posteo.net> <87a5u0tmwd.fsf@breatheoutbreathe.in> <83cyyv342w.fsf@gnu.org> <878r9hw9cp.fsf@breatheoutbreathe.in> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32078"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Cc: philipk@posteo.net, emacs-devel@gnu.org, mail+gh@daniel-mendler.de To: Joseph Turner , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 08 11:14:42 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qeXZZ-0008DW-S2 for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Sep 2023 11:14:41 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeXYt-0002nQ-HL; Fri, 08 Sep 2023 05:13:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeXYp-0002n5-29 for emacs-devel@gnu.org; Fri, 08 Sep 2023 05:13:56 -0400 Original-Received: from smtp-17.smtpout.orange.fr ([80.12.242.17] helo=smtp.smtpout.orange.fr) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeXYl-0001QP-0y for emacs-devel@gnu.org; Fri, 08 Sep 2023 05:13:54 -0400 Original-Received: from [192.168.1.15] ([2.7.71.181]) by smtp.orange.fr with ESMTPA id eXYfqfsLYhJTueXYfqrkzX; Fri, 08 Sep 2023 11:13:47 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1694164427; bh=WbLWIGSWE5IQ6U3TI7v1RGNGywq27WycNfj40hIx03U=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=eMGgsVtkJ2soa0PC8O+YBPQoxOt0uJK6I4fHkZpWXfypN4Eu607bG1tx8jPvMwrtK ghIMjff6Dihk/oCbRqU9z7kOYedpUGqg7D4Qda6Cn2wGvnW3Cue1LmUgz/cj/uP37Q p6PA0bMACao4/2EHfIo9mQJDBZ17ilYOjnYFH9hKh3jdFl9ACesZ6UELMJop6QbFst eFhIhReqA3HCACo2DtFfbQ77uUifIXZ+yS+JvUvqcavIJa4IbaiFbkfwZ1sCJMHmyZ 8J+/F/YoxdhVsjuCoxQni8gZ72MO6MtLEmrs1vrEk6om3LYAxbzj9Y/T88V2rIaHho aAj0Xx4F+k1Pg== X-ME-Helo: [192.168.1.15] X-ME-Auth: ZGFfdmlkQHdhbmFkb28uZnI= X-ME-Date: Fri, 08 Sep 2023 11:13:47 +0200 X-ME-IP: 2.7.71.181 Content-Language: fr, en-US In-Reply-To: <878r9hw9cp.fsf@breatheoutbreathe.in> Received-SPF: pass client-ip=80.12.242.17; envelope-from=da_vid@orange.fr; helo=smtp.smtpout.orange.fr X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, NICE_REPLY_A=-1.473, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310316 Archived-At: On 08/09/2023 06:55, Joseph Turner wrote: > > Eli Zaretskii writes: > >>> From: Joseph Turner >>> Cc: Emacs Devel Mailing List , 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!