From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id fKVeFTMIXWH7OwAAgWs5BA (envelope-from ) for ; Wed, 06 Oct 2021 04:21:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id wDt2EDMIXWHHLwAAbx9fmQ (envelope-from ) for ; Wed, 06 Oct 2021 02:21:39 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id ADAED364A8 for ; Wed, 6 Oct 2021 04:21:38 +0200 (CEST) Received: from localhost ([::1]:57246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXwYq-0006qw-Hc for larch@yhetil.org; Tue, 05 Oct 2021 22:21:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXwYF-0006qn-4u for emacs-orgmode@gnu.org; Tue, 05 Oct 2021 22:20:59 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:45697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mXwYA-0001hm-S6 for emacs-orgmode@gnu.org; Tue, 05 Oct 2021 22:20:58 -0400 Received: by mail-qk1-x72c.google.com with SMTP id q125so948657qkd.12 for ; Tue, 05 Oct 2021 19:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=user-agent:from:to:cc:subject:in-reply-to:date:message-id :mime-version; bh=2TDEekCyS7Gl0Z5uAs6NfY1igx6n5vnfarVwGoiUqMQ=; b=AegQOWr5wpFlX9qpwJso9A1DmvE63mzSgEPtRJ/lxVRNIuGGTZcSZRVnmtGDAmrzOM pE0uQEvlTM5hDwQZ2velmNVpAF4bflChxYPIY59hGX6xTwhWqXKWXfY4T2a999PHs/f3 UdgYVOGfN7fDe2DIZqpc/pHbfS8nl+HNI41RCFj8NhvCvNqo4ouG4G1CXBA821dijAOJ scoroPoSkA33i26nC9ZWo6rcaKfKGX/F2pinGJPGw8bCzdfVMjqC7Cj+ObP5cflylnNq duVTJZeL+bepfwSEfR4p072XKHBVRCuAe2eOATTFDxLkW4tBxuwCEMVznBdyKu97h0yH rBcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=2TDEekCyS7Gl0Z5uAs6NfY1igx6n5vnfarVwGoiUqMQ=; b=mV5M/3ZxMOBy6Ya8MDC2RE+5iGyLbcy1WfJQ+mVtT57xbmNqJpqkogDADEhLEujdeT pP4xLTQDtrWfbd7jeQNVKxUto3E5l8Vdd21haGNSccuaKVwwQ4scKjCHd9+UVps6b8UM +q4YCJbmTsA0M/mJhpnrDjTv4aXLDmjQjyS00ddMsXC+p/+Oav6G1CW/SsLzrq9QkZnS 8vHsIww+64N2kXv79uHrrlCX8DWO8KqMxq4sR+pitcb8PxNtQCQZPakVlAYk8Il3LzsI soXWgv5MBzojQ4ll3CYRF2C6t3p/7dlgSu0eOg11XADXSeEoWBD5DZUeP9PnWC2k6n4j b08w== X-Gm-Message-State: AOAM531RU5QIKOoP8uxUiqgu5y+5IzpfCkzEmfGWb0AFnHKYk8mrbaoc 6gNKnTERC/9FRTxJMHTfuHmHhnpT17gMlw== X-Google-Smtp-Source: ABdhPJz0+0ZJNFCryey5PzT1ufkkvwZF/gquYzgl0H7Lck8kY+QWDN3T72eVlCOFqBwk5qImbBgJOA== X-Received: by 2002:a37:43d2:: with SMTP id q201mr2859967qka.214.1633486853178; Tue, 05 Oct 2021 19:20:53 -0700 (PDT) Received: from arch ([2601:82:c200:166d:afae:ebe6:a0e2:409e]) by smtp.gmail.com with ESMTPSA id 9sm1872628qkn.84.2021.10.05.19.20.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 19:20:52 -0700 (PDT) User-agent: mu4e 1.7.0; emacs 28.0.50 From: No Wayman To: marcel@hsdev.com Subject: Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)] In-Reply-To: <87ilybmvvf.fsf@hsdev.com> Date: Tue, 05 Oct 2021 22:08:43 -0400 Message-ID: <87zgrmc2rg.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=iarchivedmywholelife@gmail.com; helo=mail-qk1-x72c.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633486898; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=2TDEekCyS7Gl0Z5uAs6NfY1igx6n5vnfarVwGoiUqMQ=; b=B1CaPkg1O9+ZOR9H/Z1DWuXGaR1QHY7Z4YQunDtKrJQ/nGQqKBK9gEmO719RjScKxpiFaw yRO+CwbDVLsN4kY5Rb28tpqpoeu4ZaOc5i4RY6qdR2q20ll5rcA3eMm/hf4pHMtMX2WTS5 PmtM7Fs+suN4a47CorQVo7utAS+L0dkyamco0Zh638c/FlCfFaX5eNVX8i3ZCneaCrR0Uo Hi1iVOPDX3x/TeNODLKv9uWwpuLpKSCJaz9XOeCB8zqEh4eijCCR/lKv18s2waT+8+JkuE fAtLF1X/d5xXE+EQP/xSBLdEjuFrii25wCNvL5fxpNoMYsi+OgB2qwAFpMMAsQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633486898; a=rsa-sha256; cv=none; b=BmxUhdgozZwZ1C2DpeRHCsUEJe+/4Cwn+ESE/otIwqPKG0T68txYrWjJG8VvrynjrethN6 qXTR9oiHTSure5k3RvSCgVO/ZUEMi8wd+Xwi4L/g3c4DdAcItyQ5QBMOA+L21q23rQlF8/ I14+rXYG60YmXcCv025aM6GJqeC1UjdnlmlNf79aejWcoTDlfOE/2pawRu/EmdcDXPqLI3 A5J/zYLaUTBn3c36nuNUZpHdlAMwC3yv822bmOk71bwX32YZLlcNlMqWL0ytbHgqL7qWpC ZtLfnReGSf4EthFvifToI2uYUA9Y1S7x/fUJAEiVXstFwPRhI/hvOznzjWYxAQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=AegQOWr5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -4.01 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=AegQOWr5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: ADAED364A8 X-Spam-Score: -4.01 X-Migadu-Scanner: scn1.migadu.com X-TUID: neZy1434WAzA --=-=-= Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Confirmed with the following, simpler, test case: Yodel[1] Report 2021-10-05 22:07:33 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --8<---------------cut here---------------start------------->8--- (yodel :user-dir "org-save-all-org-buffers" :packages* org :formatter yodel-format-as-mailing-list-message :post* (yodel-file "./test.org" :with* "#+startup: overview * A ** B" :then* (require 'org-element) (defun +org-visible nil (org-element-interpret-data (org-element-parse-buffer nil 'visible-only))) (message "%s %s" "Before `org-save-all-org-buffers':" (+org-visible)) (set-buffer-modified-p t) (org-save-all-org-buffers) (message "%s %s" "After `org-save-all-org-buffers':" (+org-visible)))) --8<---------------cut here---------------end--------------->8--- STDOUT =3D=3D=3D=3D=3D=3D > Loading=20 > /tmp/org-save-all-org-buffers/straight-bootstrap-snippet.el=20 > (source)... > Before `org-save-all-org-buffers': > #+startup: overview > * A > ** B > Saving all Org buffers... > Saving all Org buffers... done > After `org-save-all-org-buffers': > #+startup: overview > * A Environment =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - emacs version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu,=20 X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-09-29 - system type: gnu/linux Packages =3D=3D=3D=3D=3D=3D=3D=3D - org=20 https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=3Dcc2490a= 7061955395c4f5a1a23a088044554a2f7 The behavior of `save-some-buffers' PRED argument changed=20 recently: https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3Da9ad3d477441feefa3= bf6107d58281cb64e0e78a If the PRED returns a function, that function is called. Since `derived-mode-p' returns the symbol `org-mode', Org is being=20 reloaded in modified buffers. That's what is causing the visibility change.=20 This could also have other undesirable behavior such as running=20 the mode hook, resetting buffer-local variables, etc. The attached patch ensures we're returning a boolean from the PRED=20 function. Tested with: Yodel[1] Report 2021-10-05 22:07:33 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --8<---------------cut here---------------start------------->8--- (yodel :user-dir "org-save-all-org-buffers.patch" :packages* (org :host github :repo "progfolio/org-mode" :branch=20 "fix/org-save-all-org-buffers") :formatter yodel-format-as-mailing-list-message :post* (yodel-file "./test.org" :with* "#+startup: overview * A ** B" :then* (require 'org-element) (defun +org-visible nil (org-element-interpret-data (org-element-parse-buffer nil 'visible-only))) (message "%s %s" "Before `org-save-all-org-buffers':" (+org-visible)) (set-buffer-modified-p t) (org-save-all-org-buffers) (message "%s %s" "After `org-save-all-org-buffers':" (+org-visible)))) --8<---------------cut here---------------end--------------->8--- STDOUT =3D=3D=3D=3D=3D=3D > Loading=20 > /tmp/org-save-all-org-buffers.patch/straight-bootstrap-snippet.el=20 > (source)... > Bootstrapping straight.el... > Bootstrapping straight.el...done > Rebuilding all packages due to build cache schema change > Looking for gnu-elpa-mirror recipe =E2=86=92 Cloning melpa... > Looking for gnu-elpa-mirror recipe =E2=86=92 Cloning melpa...done > Looking for emacsmirror-mirror recipe =E2=86=92 Cloning=20 > gnu-elpa-mirror... > Looking for emacsmirror-mirror recipe =E2=86=92 Cloning=20 > gnu-elpa-mirror...done > Looking for emacsmirror-mirror recipe =E2=86=92 Cloning el-get... > Looking for emacsmirror-mirror recipe =E2=86=92 Cloning el-get...done > Looking for straight recipe =E2=86=92 Cloning emacsmirror-mirror... > Looking for straight recipe =E2=86=92 Cloning emacsmirror-mirror...done > Building straight... > Building straight...done > Cloning org... > Cloning org...done > Building org... > Building org...done > Before `org-save-all-org-buffers': > #+startup: overview > * A > ** B > Saving all Org buffers... > Saving all Org buffers... done > After `org-save-all-org-buffers': > #+startup: overview > * A > ** B Environment =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - emacs version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu,=20 X toolkit, cairo version 1.17.4, Xaw3d scroll bars) of 2021-09-29 - system type: gnu/linux Packages =3D=3D=3D=3D=3D=3D=3D=3D - org=20 https://github.com/progfolio/org-mode/commit/f1fc22f861ca9610ad4f1e122766= 0712b46337e4 [1] https://www.github.com/progfolio/yodel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-org.el-org-save-all-org-buffers-Prevent-org-mod.patch >From f1fc22f861ca9610ad4f1e1227660712b46337e4 Mon Sep 17 00:00:00 2001 From: Nicholas Vollmer Date: Tue, 5 Oct 2021 21:07:01 -0400 Subject: [PATCH] lisp/org.el: (org-save-all-org-buffers): Prevent `org-mode' reload * lisp/org.el: (org-save-all-org-buffers): Ensure `save-some-buffers' PRED returns boolean. As of this upstream commit: https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=a9ad3d477441feefa3bf6107d58281cb64e0e78a `save-some-buffers' will call its PRED argument if it returns a function. Since (derived-mode-p 'org-mode) returns the symbol org-mode, and org-mode is a function, org-mode is reloaded in modified Org buffers when calling `org-save-all-org-buffers'. Among other undesirable behavior, this will cause the buffer's visibility to be reset to its initial visibility. --- lisp/org.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index 18cb53af6..6ddcc6af7 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15366,7 +15366,7 @@ The value is a list, with zero or more of the symbols `effort', `appt', "Save all Org buffers without user confirmation." (interactive) (message "Saving all Org buffers...") - (save-some-buffers t (lambda () (derived-mode-p 'org-mode))) + (save-some-buffers t (lambda () (and (derived-mode-p 'org-mode) t))) (when (featurep 'org-id) (org-id-locations-save)) (message "Saving all Org buffers... done")) -- 2.33.0 --=-=-=--