From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner Newsgroups: gmane.emacs.devel Subject: [IDEA] Add function clean-buffer Date: Sun, 03 Sep 2023 15:18:59 -0700 Message-ID: <87il8qx50p.fsf@breatheoutbreathe.in> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5246"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Philip Kaludercic , mail+gh@daniel-mendler.de To: Emacs Devel Mailing List Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 04 04:21:30 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 1qczDV-000161-A7 for ged-emacs-devel@m.gmane-mx.org; Mon, 04 Sep 2023 04:21:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qczCU-0004rK-6n; Sun, 03 Sep 2023 22:20:26 -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 1qcvdY-0002Pe-QR for emacs-devel@gnu.org; Sun, 03 Sep 2023 18:32:08 -0400 Original-Received: from out-227.mta1.migadu.com ([2001:41d0:203:375::e3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcvdV-0000LS-AV for emacs-devel@gnu.org; Sun, 03 Sep 2023 18:32:08 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1693780319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=xJlwN2qIjMiWuUPX6s4XWyHmR0lTV8e5sX+nueFyUb4=; b=BeUsy4GZee3GU7zsghMBL5oCsXOsUOZELYqdIfbP90IXhNZvb14NQAxIFQW/wYGCiaQibw k0aWJ6+elk6nYF14emJyju6Zs8cjsZiQW/AmpJwbYVRuCIll0+ZDho/yUATS6RM6eEQoim yMomcDaZo/PkG8F2s4c2X5e+XwkGs24= X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:203:375::e3; envelope-from=joseph@breatheoutbreathe.in; helo=out-227.mta1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 03 Sep 2023 22:20:23 -0400 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:310043 Archived-At: 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