emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
@ 2021-10-05 13:14 Marcel van der Boom
  2021-10-05 17:53 ` Bhavin Gandhi
  2021-10-06  2:08 ` No Wayman
  0 siblings, 2 replies; 10+ messages in thread
From: Marcel van der Boom @ 2021-10-05 13:14 UTC (permalink / raw)
  To: emacs-orgmode


Summary:
When calling `org-save-all-org-buffers` the initial visibility 
setting as specified in `org-startup-folded` or specified in 
=#+STARTUP: overview= will be applied to the org buffer in view.

My usecase is that `org-save-all-org-buffers` is called in an idle 
timer and makes working on org files annoying, as the outline 
keeps changing all the time, for example after returning from an 
interrupting phonecall.

To reproduce:

- create two files:

test.org:

--8<---------------cut here---------------start------------->8---
  #+SETUPFILE: ~/test-config.org

* Header one
  Test header folding on save all buffers
** Header two
  This will collapse after calling org-save-all-org-buffers
--8<---------------cut here---------------end--------------->8---


test-config.org;

--8<---------------cut here---------------start------------->8---
#+STARTUP:overview
--8<---------------cut here---------------end--------------->8---

- emacs -Q test.org
- make sure the outline is unfolded
- make a change so test.org is 'dirty'
- M-x org-save-all-org-buffers

Observed behaviour:
The outline in test.org will collapse and only show 'Header one'

Expected behaviour:
Outline state does not change on calling `org-save-all-buffers`




Emacs  : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.30, cairo version 1.17.4)
 of 2021-10-03
Package: Org mode version 9.5 (release_9.5 @ 
/usr/local/share/emacs/29.0.50/lisp/org/)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
  2021-10-05 13:14 Marcel van der Boom
@ 2021-10-05 17:53 ` Bhavin Gandhi
  2021-10-06  2:08 ` No Wayman
  1 sibling, 0 replies; 10+ messages in thread
From: Bhavin Gandhi @ 2021-10-05 17:53 UTC (permalink / raw)
  To: Marcel van der Boom; +Cc: emacs-orgmode

Hello Marcel,

On Tue, 5 Oct 2021 at 19:14, Marcel van der Boom <marcel@hsdev.com> wrote:
> […]
> - emacs -Q test.org
> - make sure the outline is unfolded
> - make a change so test.org is 'dirty'
> - M-x org-save-all-org-buffers
>
> Observed behaviour:
> The outline in test.org will collapse and only show 'Header one'
>
> Expected behaviour:
> Outline state does not change on calling `org-save-all-buffers`
>

I tried to follow the above steps with Emacs 27.1, and Org mode latest
main branch as well as the release_9.5 tag. The only different step I
took was this:

emacs -Q -L ~/src/org-mode/lisp/ ~/test.org

When I modify the test.org and call org-save-all-org-buffers, all the
headings remain unfolded. I tried to switch to a different buffer and
called the function, but still it remained in overview state. Maybe
someone with the latest Emacs build from master can try to reproduce?

-- 
Regards,
Bhavin Gandhi (bhavin192) | https://geeksocket.in


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Fwd: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
       [not found] <cdd5fdae-5c61-916b-9e6e-9e9d51a0a834@ctpowe.net>
@ 2021-10-05 19:51 ` Michael Powe
  2021-10-08 11:55   ` Lennart C. Karssen
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Powe @ 2021-10-05 19:51 UTC (permalink / raw)
  To: Org Mode List; +Cc: marcel


[-- Attachment #1.1.1: Type: text/plain, Size: 2152 bytes --]


forgot to hit 'reply all.'


-------- Forwarded Message --------
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/)]
Date: 	Tue, 5 Oct 2021 15:47:42 -0400
From: 	Michael Powe <powem@ctpowe.net>
To: 	Bhavin Gandhi <bhavin7392@gmail.com>



Hello,

I hesitate to reply, but here's a report from Windows 10.

works as expected
C:\Emacs\emacs-28\bin\runemacs.exe -Q -L
C:\Users\micha\AppData\Roaming\.emacs.d\elpa\org-9.5\ 'G:\My
Drive\org\daily.org'
GNU Emacs 28.0.50 (build 1, x86_64-w64-mingw32) of 2021-08-11
Org mode version 9.5 (9.5-g0a86ad @
c:/Users/micha/AppData/Roaming/.emacs.d/elpa/org-9.5/)

Now for the bad news.

does not save files at all!
C:\Emacs\emacs29\bin\runemacs.exe -Q 'G:\My Drive\org\daily.org'
GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32) of 2021-10-02
Org mode version 9.5 (release_9.5 @
c:/Emacs/emacs29/share/emacs/29.0.50/lisp/org/)

Upon invoking the save, contents of the file shift to the left, then
shift back; and that's it.

HTH.

mp

Bhavin Gandhi wrote on 10/5/2021 13:53:
> Hello Marcel,
>
> On Tue, 5 Oct 2021 at 19:14, Marcel van der Boom <marcel@hsdev.com> wrote:
>> […]
>> - emacs -Q test.org
>> - make sure the outline is unfolded
>> - make a change so test.org is 'dirty'
>> - M-x org-save-all-org-buffers
>>
>> Observed behaviour:
>> The outline in test.org will collapse and only show 'Header one'
>>
>> Expected behaviour:
>> Outline state does not change on calling `org-save-all-buffers`
>>
> I tried to follow the above steps with Emacs 27.1, and Org mode latest
> main branch as well as the release_9.5 tag. The only different step I
> took was this:
>
> emacs -Q -L ~/src/org-mode/lisp/ ~/test.org
>
> When I modify the test.org and call org-save-all-org-buffers, all the
> headings remain unfolded. I tried to switch to a different buffer and
> called the function, but still it remained in overview state. Maybe
> someone with the latest Emacs build from master can try to reproduce?
>

-- 
Sent from Postbox <https://www.postbox-inc.com>

[-- Attachment #1.1.2: Type: text/html, Size: 3521 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 972 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
  2021-10-05 13:14 Marcel van der Boom
  2021-10-05 17:53 ` Bhavin Gandhi
@ 2021-10-06  2:08 ` No Wayman
  2021-10-09 19:33   ` Kyle Meyer
  1 sibling, 1 reply; 10+ messages in thread
From: No Wayman @ 2021-10-06  2:08 UTC (permalink / raw)
  To: marcel; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 4501 bytes --]

Confirmed with the following, simpler, test case:

Yodel[1] Report 2021-10-05 22:07:33
===================================

--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
======

> Loading 
> /tmp/org-save-all-org-buffers/straight-bootstrap-snippet.el 
> (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
===========

- emacs version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, 
  X toolkit, cairo version 1.17.4, Xaw3d scroll bars)
 of 2021-09-29
- system type: gnu/linux

Packages
========

- org 
  https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=cc2490a7061955395c4f5a1a23a088044554a2f7

The behavior of `save-some-buffers' PRED argument changed 
recently:

https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=a9ad3d477441feefa3bf6107d58281cb64e0e78a

If the PRED returns a function, that function is called.
Since `derived-mode-p' returns the symbol `org-mode', Org is being 
reloaded in modified buffers.
That's what is causing the visibility change. 
This could also have other undesirable behavior such as running 
the mode hook, resetting buffer-local variables, etc.

The attached patch ensures we're returning a boolean from the PRED 
function.
Tested with:

Yodel[1] Report 2021-10-05 22:07:33
===================================

--8<---------------cut here---------------start------------->8---
(yodel
  :user-dir "org-save-all-org-buffers.patch"
  :packages*
  (org :host github :repo "progfolio/org-mode" :branch 
  "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
======

> Loading 
> /tmp/org-save-all-org-buffers.patch/straight-bootstrap-snippet.el 
> (source)...
> Bootstrapping straight.el...
> Bootstrapping straight.el...done
> Rebuilding all packages due to build cache schema change
> Looking for gnu-elpa-mirror recipe → Cloning melpa...
> Looking for gnu-elpa-mirror recipe → Cloning melpa...done
> Looking for emacsmirror-mirror recipe → Cloning 
> gnu-elpa-mirror...
> Looking for emacsmirror-mirror recipe → Cloning 
> gnu-elpa-mirror...done
> Looking for emacsmirror-mirror recipe → Cloning el-get...
> Looking for emacsmirror-mirror recipe → Cloning el-get...done
> Looking for straight recipe → Cloning emacsmirror-mirror...
> Looking for straight recipe → 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
===========

- emacs version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, 
  X toolkit, cairo version 1.17.4, Xaw3d scroll bars)
 of 2021-09-29
- system type: gnu/linux

Packages
========

- org 
  https://github.com/progfolio/org-mode/commit/f1fc22f861ca9610ad4f1e1227660712b46337e4


[1] https://www.github.com/progfolio/yodel


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-org.el-org-save-all-org-buffers-Prevent-org-mod.patch --]
[-- Type: text/x-patch, Size: 1470 bytes --]

From f1fc22f861ca9610ad4f1e1227660712b46337e4 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: Fwd: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
  2021-10-05 19:51 ` Fwd: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)] Michael Powe
@ 2021-10-08 11:55   ` Lennart C. Karssen
  2021-10-08 22:00     ` Mark Barton
  0 siblings, 1 reply; 10+ messages in thread
From: Lennart C. Karssen @ 2021-10-08 11:55 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 3037 bytes --]

Dear list,

Confirmed.

This is to confirm Micheal's overservation that
`org-save-all-org-buffers' doesn't save any Org buffers any more in
Emacs 28, compiled a few days ago from commit d86b2e59c and Org 9.5 from
Elpa, running on Ubuntu Linux 21.04.
I can't say if this is because of the upgrade of Org 9.5 or the newly
compiled Emacs as I did both at the same time.
Command used for testing:
  emacs -Q -L ~/.emacs.d/elpa/org-9.5/ /tmp/test.org


Best regards,

Lennart Karssen.

On 05-10-2021 21:51, Michael Powe wrote:
> 
> forgot to hit 'reply all.'
> 
> 
> -------- Forwarded Message --------
> 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/)]
> Date: 	Tue, 5 Oct 2021 15:47:42 -0400
> From: 	Michael Powe <powem@ctpowe.net>
> To: 	Bhavin Gandhi <bhavin7392@gmail.com>
> 
> 
> 
> Hello,
> 
> I hesitate to reply, but here's a report from Windows 10.
> 
> works as expected
> C:\Emacs\emacs-28\bin\runemacs.exe -Q -L
> C:\Users\micha\AppData\Roaming\.emacs.d\elpa\org-9.5\ 'G:\My
> Drive\org\daily.org'
> GNU Emacs 28.0.50 (build 1, x86_64-w64-mingw32) of 2021-08-11
> Org mode version 9.5 (9.5-g0a86ad @
> c:/Users/micha/AppData/Roaming/.emacs.d/elpa/org-9.5/)
> 
> Now for the bad news.
> 
> does not save files at all!
> C:\Emacs\emacs29\bin\runemacs.exe -Q 'G:\My Drive\org\daily.org'
> GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32) of 2021-10-02
> Org mode version 9.5 (release_9.5 @
> c:/Emacs/emacs29/share/emacs/29.0.50/lisp/org/)
> 
> Upon invoking the save, contents of the file shift to the left, then
> shift back; and that's it.
> 
> HTH.
> 
> mp
> 
> Bhavin Gandhi wrote on 10/5/2021 13:53:
>> Hello Marcel,
>>
>> On Tue, 5 Oct 2021 at 19:14, Marcel van der Boom <marcel@hsdev.com> wrote:
>>> […]
>>> - emacs -Q test.org
>>> - make sure the outline is unfolded
>>> - make a change so test.org is 'dirty'
>>> - M-x org-save-all-org-buffers
>>>
>>> Observed behaviour:
>>> The outline in test.org will collapse and only show 'Header one'
>>>
>>> Expected behaviour:
>>> Outline state does not change on calling `org-save-all-buffers`
>>>
>> I tried to follow the above steps with Emacs 27.1, and Org mode latest
>> main branch as well as the release_9.5 tag. The only different step I
>> took was this:
>>
>> emacs -Q -L ~/src/org-mode/lisp/ ~/test.org
>>
>> When I modify the test.org and call org-save-all-org-buffers, all the
>> headings remain unfolded. I tried to switch to a different buffer and
>> called the function, but still it remained in overview state. Maybe
>> someone with the latest Emacs build from master can try to reproduce?
>>
> 
> -- 
> Sent from Postbox <https://www.postbox-inc.com>

-- 
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
L.C. Karssen
's-Hertogenbosch
The Netherlands

lennart@karssen.org
http://blog.karssen.org
GPG key ID: A88F554A
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
  2021-10-08 11:55   ` Lennart C. Karssen
@ 2021-10-08 22:00     ` Mark Barton
  2021-10-08 22:30       ` Mark Barton
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Barton @ 2021-10-08 22:00 UTC (permalink / raw)
  To: Lennart C. Karssen, Juri Linkov; +Cc: orgmode

I can confirm this too.

(defun org-save-all-org-buffers ()
  "Save all Org buffers without user confirmation."
  (interactive)
  (message "Saving all Org buffers...")
  (save-some-buffers t (lambda () (derived-mode-p 'org-mode)))
  (when (featurep 'org-id) (org-id-locations-save))
  (message "Saving all Org buffers... done"))

If I comment out this change to the function save-some-buffers, then org-save-all-org-buffers works again.

a9ad3d477441feefa3bf6107d58281cb64e0e78a
Author:     Juri Linkov <juri@linkov.net>
AuthorDate: Fri Aug 13 10:10:29 2021 +0300
Commit:     Juri Linkov <juri@linkov.net>
CommitDate: Fri Aug 13 10:10:29 2021 +0300

Parent:     c4d34d24e3 CC Mode: Enhance C++ Mode raw strings to multi-line strings for any language
Merged:     emacs-27 feature/native-comp
Contained:  master
Follows:    emacs-27.1 (8875)

Add save-some-buffers-root to save-some-buffers-default-predicate (bug#46374)

* lisp/files.el (save-some-buffers-default-predicate): Add choice
'save-some-buffers-root'.
(save-some-buffers-root): New predicate function.
(save-some-buffers): Check if 'pred' returns a lexically-bound lambda,
then use it as 'pred'.


 (defun save-some-buffers (&optional arg pred)
   "Save some modified file-visiting buffers.  Asks user about each one.
 You can answer `y' or SPC to save, `n' or DEL not to save, `C-r'
@@ -5758,6 +5772,11 @@ save-some-buffers
   (interactive "P")
   (unless pred
     (setq pred save-some-buffers-default-predicate))
+  ;; Allow `pred' to be a function that returns a predicate
+  ;; with lexical bindings in its original environment (bug#46374).
+  (let ((pred-fun (and (functionp pred) (funcall pred))))
+    (when (functionp pred-fun)
+      (setq pred pred-fun)))
   (let* ((switched-buffer nil)
          (save-some-buffers--switch-window-callback
           (lambda (buffer)

I think it has to do with how org-save-all-org-buffers sets the pred argument with:
(lambda () (derived-mode-p 'org-mode))

> On Oct 8, 2021, at 4:55 AM, Lennart C. Karssen <lennart@karssen.org> wrote:
> 
> Dear list,
> 
> Confirmed.
> 
> This is to confirm Micheal's overservation that
> `org-save-all-org-buffers' doesn't save any Org buffers any more in
> Emacs 28, compiled a few days ago from commit d86b2e59c and Org 9.5 from
> Elpa, running on Ubuntu Linux 21.04.
> I can't say if this is because of the upgrade of Org 9.5 or the newly
> compiled Emacs as I did both at the same time.
> Command used for testing:
>  emacs -Q -L ~/.emacs.d/elpa/org-9.5/ /tmp/test.org
> 
> 
> Best regards,
> 
> Lennart Karssen.
> 
> On 05-10-2021 21:51, Michael Powe wrote:
>> 
>> forgot to hit 'reply all.'
>> 
>> 
>> -------- Forwarded Message --------
>> 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/)]
>> Date: 	Tue, 5 Oct 2021 15:47:42 -0400
>> From: 	Michael Powe <powem@ctpowe.net>
>> To: 	Bhavin Gandhi <bhavin7392@gmail.com>
>> 
>> 
>> 
>> Hello,
>> 
>> I hesitate to reply, but here's a report from Windows 10.
>> 
>> works as expected
>> C:\Emacs\emacs-28\bin\runemacs.exe -Q -L
>> C:\Users\micha\AppData\Roaming\.emacs.d\elpa\org-9.5\ 'G:\My
>> Drive\org\daily.org'
>> GNU Emacs 28.0.50 (build 1, x86_64-w64-mingw32) of 2021-08-11
>> Org mode version 9.5 (9.5-g0a86ad @
>> c:/Users/micha/AppData/Roaming/.emacs.d/elpa/org-9.5/)
>> 
>> Now for the bad news.
>> 
>> does not save files at all!
>> C:\Emacs\emacs29\bin\runemacs.exe -Q 'G:\My Drive\org\daily.org'
>> GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32) of 2021-10-02
>> Org mode version 9.5 (release_9.5 @
>> c:/Emacs/emacs29/share/emacs/29.0.50/lisp/org/)
>> 
>> Upon invoking the save, contents of the file shift to the left, then
>> shift back; and that's it.
>> 
>> HTH.
>> 
>> mp
>> 
>> Bhavin Gandhi wrote on 10/5/2021 13:53:
>>> Hello Marcel,
>>> 
>>> On Tue, 5 Oct 2021 at 19:14, Marcel van der Boom <marcel@hsdev.com> wrote:
>>>> […]
>>>> - emacs -Q test.org
>>>> - make sure the outline is unfolded
>>>> - make a change so test.org is 'dirty'
>>>> - M-x org-save-all-org-buffers
>>>> 
>>>> Observed behaviour:
>>>> The outline in test.org will collapse and only show 'Header one'
>>>> 
>>>> Expected behaviour:
>>>> Outline state does not change on calling `org-save-all-buffers`
>>>> 
>>> I tried to follow the above steps with Emacs 27.1, and Org mode latest
>>> main branch as well as the release_9.5 tag. The only different step I
>>> took was this:
>>> 
>>> emacs -Q -L ~/src/org-mode/lisp/ ~/test.org
>>> 
>>> When I modify the test.org and call org-save-all-org-buffers, all the
>>> headings remain unfolded. I tried to switch to a different buffer and
>>> called the function, but still it remained in overview state. Maybe
>>> someone with the latest Emacs build from master can try to reproduce?
>>> 
>> 
>> -- 
>> Sent from Postbox <https://www.postbox-inc.com>
> 
> -- 
> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
> L.C. Karssen
> 's-Hertogenbosch
> The Netherlands
> 
> lennart@karssen.org
> http://blog.karssen.org
> GPG key ID: A88F554A
> -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
  2021-10-08 22:00     ` Mark Barton
@ 2021-10-08 22:30       ` Mark Barton
  2021-10-09 16:38         ` No Wayman
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Barton @ 2021-10-08 22:30 UTC (permalink / raw)
  To: Lennart C. Karssen, Juri Linkov; +Cc: orgmode

The debugger shows that pred gets set to org-mode rather than the function to test for org mode.

Debugger entered--returning value: org-mode
  (setq pred pred-fun)
* (progn (setq pred pred-fun))
* (if (functionp pred-fun) (progn (setq pred pred-fun)))
* (let ((pred-fun (and (functionp pred) (funcall pred)))) (if (functionp pred-fun) (progn (setq pred pred-fun))))
* (closure (backup-extract-version-start t) (&optional arg pred) "Save some modified file-visiting buffers.  Asks us..." (interactive "P") (if pred nil (setq pred save-some-buffers-default-predicate)) (let ((pred-fun (and (functionp pred) (funcall pred)))) (if (functionp pred-fun) (progn (setq pred pred-fun)))) (let* ((switched-buffer nil) (save-some-buffers--switch-window-callback #'(lambda (buffer) (setq switched-buffer buffer))) queried autosaved-buffers files-done abbrevs-done) (unwind-protect (let ((wconfig (current-window-configuration))) (unwind-protect (progn (let ... ...) (setq files-done ...) (and save-abbrevs abbrevs-changed ...) (or queried ... abbrevs-done ...)) (set-window-configuration wconfig))) (if switched-buffer (progn (pop-to-buffer-same-window switched-buffer))))))(t #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_336>)
* apply((closure (backup-extract-version-start t) (&optional arg pred) "Save some modified file-visiting buffers.  Asks us..." (interactive "P") (if pred nil (setq pred save-some-buffers-default-predicate)) (let ((pred-fun (and (functionp pred) (funcall pred)))) (if (functionp pred-fun) (progn (setq pred pred-fun)))) (let* ((switched-buffer nil) (save-some-buffers--switch-window-callback #'(lambda (buffer) (setq switched-buffer buffer))) queried autosaved-buffers files-done abbrevs-done) (unwind-protect (let ((wconfig (current-window-configuration))) (unwind-protect (progn (let ... ...) (setq files-done ...) (and save-abbrevs abbrevs-changed ...) (or queried ... abbrevs-done ...)) (set-window-configuration wconfig))) (if switched-buffer (progn (pop-to-buffer-same-window switched-buffer)))))) (t #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_336>))
* save-some-buffers(t #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_336>)
  org-save-all-org-buffers()
  funcall-interactively(org-save-all-org-buffers)
  command-execute(org-save-all-org-buffers record)
  execute-extended-command(nil "org-save-all-org-buffers" nil)
  funcall-interactively(execute-extended-command nil "org-save-all-org-buffers" nil)
  command-execute(execute-extended-command)


> On Oct 8, 2021, at 3:00 PM, Mark Barton <mbarton98@gmail.com> wrote:
> 
> I can confirm this too.
> 
> (defun org-save-all-org-buffers ()
>  "Save all Org buffers without user confirmation."
>  (interactive)
>  (message "Saving all Org buffers...")
>  (save-some-buffers t (lambda () (derived-mode-p 'org-mode)))
>  (when (featurep 'org-id) (org-id-locations-save))
>  (message "Saving all Org buffers... done"))
> 
> If I comment out this change to the function save-some-buffers, then org-save-all-org-buffers works again.
> 
> a9ad3d477441feefa3bf6107d58281cb64e0e78a
> Author:     Juri Linkov <juri@linkov.net>
> AuthorDate: Fri Aug 13 10:10:29 2021 +0300
> Commit:     Juri Linkov <juri@linkov.net>
> CommitDate: Fri Aug 13 10:10:29 2021 +0300
> 
> Parent:     c4d34d24e3 CC Mode: Enhance C++ Mode raw strings to multi-line strings for any language
> Merged:     emacs-27 feature/native-comp
> Contained:  master
> Follows:    emacs-27.1 (8875)
> 
> Add save-some-buffers-root to save-some-buffers-default-predicate (bug#46374)
> 
> * lisp/files.el (save-some-buffers-default-predicate): Add choice
> 'save-some-buffers-root'.
> (save-some-buffers-root): New predicate function.
> (save-some-buffers): Check if 'pred' returns a lexically-bound lambda,
> then use it as 'pred'.
> 
> 
> (defun save-some-buffers (&optional arg pred)
>   "Save some modified file-visiting buffers.  Asks user about each one.
> You can answer `y' or SPC to save, `n' or DEL not to save, `C-r'
> @@ -5758,6 +5772,11 @@ save-some-buffers
>   (interactive "P")
>   (unless pred
>     (setq pred save-some-buffers-default-predicate))
> +  ;; Allow `pred' to be a function that returns a predicate
> +  ;; with lexical bindings in its original environment (bug#46374).
> +  (let ((pred-fun (and (functionp pred) (funcall pred))))
> +    (when (functionp pred-fun)
> +      (setq pred pred-fun)))
>   (let* ((switched-buffer nil)
>          (save-some-buffers--switch-window-callback
>           (lambda (buffer)
> 
> I think it has to do with how org-save-all-org-buffers sets the pred argument with:
> (lambda () (derived-mode-p 'org-mode))
> 
>> On Oct 8, 2021, at 4:55 AM, Lennart C. Karssen <lennart@karssen.org> wrote:
>> 
>> Dear list,
>> 
>> Confirmed.
>> 
>> This is to confirm Micheal's overservation that
>> `org-save-all-org-buffers' doesn't save any Org buffers any more in
>> Emacs 28, compiled a few days ago from commit d86b2e59c and Org 9.5 from
>> Elpa, running on Ubuntu Linux 21.04.
>> I can't say if this is because of the upgrade of Org 9.5 or the newly
>> compiled Emacs as I did both at the same time.
>> Command used for testing:
>> emacs -Q -L ~/.emacs.d/elpa/org-9.5/ /tmp/test.org
>> 
>> 
>> Best regards,
>> 
>> Lennart Karssen.
>> 
>> On 05-10-2021 21:51, Michael Powe wrote:
>>> 
>>> forgot to hit 'reply all.'
>>> 
>>> 
>>> -------- Forwarded Message --------
>>> 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/)]
>>> Date: 	Tue, 5 Oct 2021 15:47:42 -0400
>>> From: 	Michael Powe <powem@ctpowe.net>
>>> To: 	Bhavin Gandhi <bhavin7392@gmail.com>
>>> 
>>> 
>>> 
>>> Hello,
>>> 
>>> I hesitate to reply, but here's a report from Windows 10.
>>> 
>>> works as expected
>>> C:\Emacs\emacs-28\bin\runemacs.exe -Q -L
>>> C:\Users\micha\AppData\Roaming\.emacs.d\elpa\org-9.5\ 'G:\My
>>> Drive\org\daily.org'
>>> GNU Emacs 28.0.50 (build 1, x86_64-w64-mingw32) of 2021-08-11
>>> Org mode version 9.5 (9.5-g0a86ad @
>>> c:/Users/micha/AppData/Roaming/.emacs.d/elpa/org-9.5/)
>>> 
>>> Now for the bad news.
>>> 
>>> does not save files at all!
>>> C:\Emacs\emacs29\bin\runemacs.exe -Q 'G:\My Drive\org\daily.org'
>>> GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32) of 2021-10-02
>>> Org mode version 9.5 (release_9.5 @
>>> c:/Emacs/emacs29/share/emacs/29.0.50/lisp/org/)
>>> 
>>> Upon invoking the save, contents of the file shift to the left, then
>>> shift back; and that's it.
>>> 
>>> HTH.
>>> 
>>> mp
>>> 
>>> Bhavin Gandhi wrote on 10/5/2021 13:53:
>>>> Hello Marcel,
>>>> 
>>>> On Tue, 5 Oct 2021 at 19:14, Marcel van der Boom <marcel@hsdev.com> wrote:
>>>>> […]
>>>>> - emacs -Q test.org
>>>>> - make sure the outline is unfolded
>>>>> - make a change so test.org is 'dirty'
>>>>> - M-x org-save-all-org-buffers
>>>>> 
>>>>> Observed behaviour:
>>>>> The outline in test.org will collapse and only show 'Header one'
>>>>> 
>>>>> Expected behaviour:
>>>>> Outline state does not change on calling `org-save-all-buffers`
>>>>> 
>>>> I tried to follow the above steps with Emacs 27.1, and Org mode latest
>>>> main branch as well as the release_9.5 tag. The only different step I
>>>> took was this:
>>>> 
>>>> emacs -Q -L ~/src/org-mode/lisp/ ~/test.org
>>>> 
>>>> When I modify the test.org and call org-save-all-org-buffers, all the
>>>> headings remain unfolded. I tried to switch to a different buffer and
>>>> called the function, but still it remained in overview state. Maybe
>>>> someone with the latest Emacs build from master can try to reproduce?
>>>> 
>>> 
>>> -- 
>>> Sent from Postbox <https://www.postbox-inc.com>
>> 
>> -- 
>> *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
>> L.C. Karssen
>> 's-Hertogenbosch
>> The Netherlands
>> 
>> lennart@karssen.org
>> http://blog.karssen.org
>> GPG key ID: A88F554A
>> -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
>> 
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
  2021-10-08 22:30       ` Mark Barton
@ 2021-10-09 16:38         ` No Wayman
  2021-10-09 18:43           ` Mark Barton
  0 siblings, 1 reply; 10+ messages in thread
From: No Wayman @ 2021-10-09 16:38 UTC (permalink / raw)
  To: mbarton98; +Cc: emacs-orgmode, lennart, juri


Your analysis is correct. I looked into this a couple days ago.
See the following message for an explanation and a patch (testing 
appreciated):

https://list.orgmode.org/87zgrmc2rg.fsf@gmail.com/T/#m9888bc09d77d7bba70ba99671aca72446c4d41b9




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
  2021-10-09 16:38         ` No Wayman
@ 2021-10-09 18:43           ` Mark Barton
  0 siblings, 0 replies; 10+ messages in thread
From: Mark Barton @ 2021-10-09 18:43 UTC (permalink / raw)
  To: No Wayman; +Cc: orgmode, lennart, juri

 It works on my system with native compilation on macOS 11.6. I made the change to org.el that is in my local clone of the emacs master branch and recompiled.

Looking at the Help for the function, I see it is native compiled Lisp in my test here.

- *Help* - buffer
org-save-all-org-buffers is an interactive native compiled Lisp
function in ‘org.el’.

(org-save-all-org-buffers)
—

- diff -
Save all Org buffers without user confirmation.

modified   lisp/org/org.el
@@ -15362,7 +15362,7 @@ org-save-all-org-buffers
   "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"))
 


> On Oct 9, 2021, at 9:38 AM, No Wayman <iarchivedmywholelife@gmail.com> wrote:
> 
> 
> Your analysis is correct. I looked into this a couple days ago.
> See the following message for an explanation and a patch (testing appreciated):
> 
> https://list.orgmode.org/87zgrmc2rg.fsf@gmail.com/T/#m9888bc09d77d7bba70ba99671aca72446c4d41b9
> 
> 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)]
  2021-10-06  2:08 ` No Wayman
@ 2021-10-09 19:33   ` Kyle Meyer
  0 siblings, 0 replies; 10+ messages in thread
From: Kyle Meyer @ 2021-10-09 19:33 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

No Wayman writes:

> 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.

Thanks for the analysis and fix.

  To git.savannah.gnu.org:/srv/git/emacs/org-mode.git
     11f450da8..b71474ff7  bugfix -> bugfix


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-09 19:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cdd5fdae-5c61-916b-9e6e-9e9d51a0a834@ctpowe.net>
2021-10-05 19:51 ` Fwd: [BUG] org-save-all-org-buffers reapplies startup visibility [9.5 (release_9.5 @ /usr/local/share/emacs/29.0.50/lisp/org/)] Michael Powe
2021-10-08 11:55   ` Lennart C. Karssen
2021-10-08 22:00     ` Mark Barton
2021-10-08 22:30       ` Mark Barton
2021-10-09 16:38         ` No Wayman
2021-10-09 18:43           ` Mark Barton
2021-10-05 13:14 Marcel van der Boom
2021-10-05 17:53 ` Bhavin Gandhi
2021-10-06  2:08 ` No Wayman
2021-10-09 19:33   ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).