Re: org-persist warning when archiving

2021-10-29 Thread Colin Baxter 
> Ihor Radchenko  writes:

> Colin Baxter   writes:
>> Hi Ihor,
>> 
>> My ECM is as follows. I'm using GNU-Linux and emacs-28.0.60.

> Thanks! I was able to reproduce on my system. Should be fixed on
> main via 9f87b1cc3.

Yes, I can confirm the problem is fixed for me. Great!

Thank you.

Best wishes,

Colin.



Re: org-persist warning when archiving

2021-10-29 Thread Ihor Radchenko
Colin Baxter   writes:

> Hi Ihor,
>
> My ECM is as follows. I'm using GNU-Linux and emacs-28.0.60.

Thanks! I was able to reproduce on my system. Should be fixed on main
via 9f87b1cc3.

Best,
Ihor



Re: org-persist warning when archiving

2021-10-29 Thread Colin Baxter 
Hi Ihor,

My ECM is as follows. I'm using GNU-Linux and emacs-28.0.60.

1. Delete any existing org-persist directory.
2. mkdir ~/a
3. emacs -Q
4. Evaluate path to latest org-mode. I enter
   (add-to-list 'load-path (expand-file-name "~/path/to/git/org-mode/lisp"))
   in the scratch buffer and do C-j.
5. C-x C-f ~/test.org 
6. Enter the following in test.org:

* Test
  :PROPERTIES:
  :CATEGORY: Test
  :DESCRIPTION: Test
  :ARCHIVE:  ~/a/%s_archive::datetree/* Test
  :LOG_INTO_DRAWER: LOGDRAWER
  :END:

** TODO archive test
   SCHEDULED: <2021-10-29 Fri>

# Local Variables:
# eval: (setq org-adapt-indentation t)
# End:

7. Same the file and close down emacs in order to populate the
or-persist directory.
8. emacs -Q 
9. Evaluate path to latest org-mode, as before.
10. Open ~/test.org and make the TODO as DONE.
11. Save ~/test.org
12. I think I then closed down emacs and re-launched emacs to ensure
org-persist noted the changes. I don't think this step is necessary.
13. With cursor on DONE  do C-c C-x C-a to archive the item.
14. Item is archived to ~/a but with the warning:

--8<---cut here---start->8---
Warning (emacs): org-element--cache: Unregistered buffer modifications 
detected. Resetting.
If this warning appears regularly, please report it to Org mode mailing list 
(M-x org-submit-bug-report).
The buffer is: test.org_archive
 Current command: org-archive-subtree-default Disable showing Disable logging
Warning (emacs): org-element--cache: Unregistered buffer modifications 
detected. Resetting.
If this warning appears regularly, please report it to Org mode mailing list 
(M-x org-submit-bug-report).
The buffer is: test.org_archive
 Current command: org-archive-subtree-default Disable showing Disable logging
Warning (emacs): org-element--cache: Unregistered buffer modifications 
detected. Resetting.
If this warning appears regularly, please report it to Org mode mailing list 
(M-x org-submit-bug-report).
The buffer is: test.org_archive
 Current command: org-archive-subtree-default Disable showing Disable logging
--8<---cut here---end--->8---

15. If the test is repeated but with
:ARCHIVE:  ~/a/%s_archive::datetree/* Test
removed. Then we get the warning

--8<---cut here---start->8---
Warning (emacs): org-element--cache: Unregistered buffer modifications 
detected. Resetting.
If this warning appears regularly, please report it to Org mode mailing list 
(M-x org-submit-bug-report).
The buffer is: test.org_archive
 Current command: org-archive-subtree-default Disable showing Disable logging
--8<---cut here---end--->8---


It would appear that the local variables and the archive path are both
conspiring to produce the warning.

Best wishes,

Colin.



Re: org-persist warning when archiving

2021-10-28 Thread Ihor Radchenko
Colin Baxter   writes:

> I have now discovered what is causing the org-persist warnings. It is
> because my org-agenda files have local variables present. If I remove
> the local variables, the warnings disappear.

Do you mean file-local? Can you provide a minimal Org file example?

I also have file-local variables in my Org buffers, but I do not
experience the issue. Maybe it is some specific file-local variable?

Best,
Ihor



Re: org-persist warning when archiving

2021-10-28 Thread Colin Baxter 


I have now discovered what is causing the org-persist warnings. It is
because my org-agenda files have local variables present. If I remove
the local variables, the warnings disappear.

Best wishes,

Colin.



Re: org-persist warning when archiving

2021-10-28 Thread Colin Baxter 
> Ihor Radchenko  writes:

> Colin Baxter   writes:
>> Ok, I now applied your patch and remade org-mode. Unfortunately,
>> I don't see any change. I still get the warning on all the
>> archive commands: org-agenda-archive-default, org-agenda-archive
>> and org-agenda-archive-default-with-confirmation. I've appended
>> the warning for the latter command.

> Thanks for testing! My guess was incorrect and I am still unable
> to reproduce using agenda (previously, I just tried archiving from
> inside Org buffer).

>> --8<---cut here---start->8---
>> Warning (emacs): org-element--cache: Unregistered buffer
>> modifications detected. Resetting.  If this warning appears
>> regularly, please report it to Org mode mailing list (M-x
>> org-submit-bug-report).  The buffer is: todo.org_archive Current
>> command: org-agenda-archive-default-with-confirmation Disable
>> showing Disable logging Warning (emacs): org-element--cache:
>> Unregistered buffer modifications detected. Resetting.  If this
>> warning appears regularly, please report it to Org mode mailing
>> list (M-x org-submit-bug-report).  The buffer is:
>> todo.org_archive Current command:
>> org-agenda-archive-default-with-confirmation Disable showing
>> Disable logging --8<---cut
>> here---end--->8---
>> 
>> I've not tried it on emacs -Q yet. For that, do I need to start
>> afresh and first delete the org-persist-directory?

> You can simply start from emacs -Q + a new file (the new file will
> not have any cache). In my testing, I just created a new org file,
> opening it from emacs -Q -L /path/to/latest/org/lisp -l org
> /path/to/the/new/file.org Then, I added a new TODO heading, opened
> todo agenda for current buffer, and tried to archive the heading
> from agenda.  No warning on my side.

> You can repeat my steps and see what happens. If nothing, you may
> try archiving from your todo.org (but still using emacs -Q). If
> still nothing, it may be something about your config.

The warnings may be due to my use of ATTACH directories in agenda
files. I don't attach by id but prefer to use a directory for each node
and to link attachments to other files rather than copy. The attachments
also include other org-mode files. I should have time this weekend
to check this and to confirm if my configuration is responsible. 

Best wishes,

Colin.



Re: org-persist warning when archiving

2021-10-27 Thread Ihor Radchenko
Colin Baxter   writes:

> Ok, I now applied your patch and remade org-mode. Unfortunately, I don't
> see any change. I still get the warning on all the archive commands:
> org-agenda-archive-default, org-agenda-archive and
> org-agenda-archive-default-with-confirmation. I've appended the warning
> for the latter command.

Thanks for testing! My guess was incorrect and I am still unable to
reproduce using agenda (previously, I just tried archiving from inside
Org buffer).

> --8<---cut here---start->8---
> Warning (emacs): org-element--cache: Unregistered buffer modifications 
> detected. Resetting.
> If this warning appears regularly, please report it to Org mode mailing list 
> (M-x org-submit-bug-report).
> The buffer is: todo.org_archive
>  Current command: org-agenda-archive-default-with-confirmation Disable 
> showing Disable logging
> Warning (emacs): org-element--cache: Unregistered buffer modifications 
> detected. Resetting.
> If this warning appears regularly, please report it to Org mode mailing list 
> (M-x org-submit-bug-report).
> The buffer is: todo.org_archive
> Current command: org-agenda-archive-default-with-confirmation Disable showing 
> Disable logging
> --8<---cut here---end--->8---
>
> I've not tried it on emacs -Q yet. For that, do I need to start afresh
> and first delete the org-persist-directory?

You can simply start from emacs -Q + a new file (the new file will not
have any cache). In my testing, I just created a new org file, opening
it from emacs -Q -L /path/to/latest/org/lisp -l org
/path/to/the/new/file.org Then, I added a new TODO heading, opened todo
agenda for current buffer, and tried to archive the heading from agenda.
No warning on my side.

You can repeat my steps and see what happens. If nothing, you may try
archiving from your todo.org (but still using emacs -Q). If still
nothing, it may be something about your config.

The original intention of the warning you are seeing is catching
external packages that change buffer text silently. That's a no-go for
Org cache because unnoticed changes could make the cache incorrect (for
now, they just force cache reset making cache useless).

Best,
Ihor



Re: org-persist warning when archiving

2021-10-26 Thread Colin Baxter 
Hi Ihor,

> Ihor Radchenko  writes:

> Colin Baxter   writes:
>> I'm running Org mode version 9.5 (release_9.5-178-gcf8906) on
>> emacs-28.0.60. Unfortunately, I could not apply your patch
>> ('patch would not apply') using either 'git apply /path/to/patch'
>> or 'git a /path/to/patch'.

> Oops. Try the updated patch. The old one was based on my working
> branch.

Ok, I now applied your patch and remade org-mode. Unfortunately, I don't
see any change. I still get the warning on all the archive commands:
org-agenda-archive-default, org-agenda-archive and
org-agenda-archive-default-with-confirmation. I've appended the warning
for the latter command.

--8<---cut here---start->8---
Warning (emacs): org-element--cache: Unregistered buffer modifications 
detected. Resetting.
If this warning appears regularly, please report it to Org mode mailing list 
(M-x org-submit-bug-report).
The buffer is: todo.org_archive
 Current command: org-agenda-archive-default-with-confirmation Disable showing 
Disable logging
Warning (emacs): org-element--cache: Unregistered buffer modifications 
detected. Resetting.
If this warning appears regularly, please report it to Org mode mailing list 
(M-x org-submit-bug-report).
The buffer is: todo.org_archive
Current command: org-agenda-archive-default-with-confirmation Disable showing 
Disable logging
--8<---cut here---end--->8---

I've not tried it on emacs -Q yet. For that, do I need to start afresh
and first delete the org-persist-directory?

Best wishes,

Colin.



Re: org-persist warning when archiving

2021-10-26 Thread Ihor Radchenko
Colin Baxter   writes:

> I'm running Org mode version 9.5 (release_9.5-178-gcf8906) on
> emacs-28.0.60. Unfortunately, I could not apply your patch ('patch would
> not apply') using either 'git apply /path/to/patch' or 'git a
> /path/to/patch'.

Oops. Try the updated patch. The old one was based on my working branch.

Best,
Ihor

>From 722f595c7bef4801e7d0e5f476ecbb9eb63a16ab Mon Sep 17 00:00:00 2001
Message-Id: <722f595c7bef4801e7d0e5f476ecbb9eb63a16ab.1635260679.git.yanta...@gmail.com>
From: Ihor Radchenko 
Date: Tue, 26 Oct 2021 19:19:57 +0800
Subject: [PATCH] org.el/org-mode: Do not inhibit `after-change-functions' when
 loading

* lisp/org.el (org-mode): Let-bind `buffer-undo-list' instead of using
`org-unmodified'.  The latter suppresses org-element-cache handling of
buffer changes.
---
 lisp/org.el | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 21b2c5470..e2a02c115 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4940,22 +4940,22 @@ (define-derived-mode org-mode outline-mode "Org"
 	 (= (point-min) (point-max)))
 (insert "#-*- mode: org -*-\n\n"))
   (unless org-inhibit-startup
-(org-unmodified
- (when org-startup-with-beamer-mode (org-beamer-mode))
- (when (or org-startup-align-all-tables org-startup-shrink-all-tables)
-   (org-table-map-tables
-	(cond ((and org-startup-align-all-tables
-		org-startup-shrink-all-tables)
-	   (lambda () (org-table-align) (org-table-shrink)))
-	  (org-startup-align-all-tables #'org-table-align)
-	  (t #'org-table-shrink))
-	t))
- (when org-startup-with-inline-images (org-display-inline-images))
- (when org-startup-with-latex-preview (org-latex-preview '(16)))
- (unless org-inhibit-startup-visibility-stuff (org-set-startup-visibility))
- (when org-startup-truncated (setq truncate-lines t))
- (when org-startup-numerated (require 'org-num) (org-num-mode 1))
- (when org-startup-indented (require 'org-indent) (org-indent-mode 1
+(let ((buffer-undo-list t))
+  (when org-startup-with-beamer-mode (org-beamer-mode))
+  (when (or org-startup-align-all-tables org-startup-shrink-all-tables)
+(org-table-map-tables
+	 (cond ((and org-startup-align-all-tables
+		 org-startup-shrink-all-tables)
+	(lambda () (org-table-align) (org-table-shrink)))
+	   (org-startup-align-all-tables #'org-table-align)
+	   (t #'org-table-shrink))
+	 t))
+  (when org-startup-with-inline-images (org-display-inline-images))
+  (when org-startup-with-latex-preview (org-latex-preview '(16)))
+  (unless org-inhibit-startup-visibility-stuff (org-set-startup-visibility))
+  (when org-startup-truncated (setq truncate-lines t))
+  (when org-startup-numerated (require 'org-num) (org-num-mode 1))
+  (when org-startup-indented (require 'org-indent) (org-indent-mode 1
 
   ;; Add a custom keymap for `visual-line-mode' so that activating
   ;; this minor mode does not override Org's keybindings.
-- 
2.32.0



Re: org-persist warning when archiving

2021-10-26 Thread Colin Baxter 
Hi Thor,
> Ihor Radchenko  writes:

> Colin Baxter   writes:
>> > Hello, Whenever I archive a DONE item via 'C-c C-x C-a' I get
>> the > warning:
>> 
>> > Warning (emacs): org-element--cache: Unregistered buffer >
>> modifications detected. Resetting.
>> 
>> > The archiving is successful, but I keep getting the warning and
>> > therefore wonder if there is some org-persist or cache setting
>> > that needs to be adjusted.
>> 
>> Thinking a little more about this, I have not yet had a chance of
>> archiving an item in a new emacs session. It may be that the
>> warning is temporary to the first session and will disappear if
>> and when I archive a DONE item in a new session.

> This message always indicates some problem. However, I cannot
> reproduce what you observe on my side. Did you try with emacs -Q?
> Also, you might not be running the latest Org. I have extended
> this warning in recent commits.

I'm running Org mode version 9.5 (release_9.5-178-gcf8906) on
emacs-28.0.60. Unfortunately, I could not apply your patch ('patch would
not apply') using either 'git apply /path/to/patch' or 'git a
/path/to/patch'. I then tried manually to apply it, but that produced
errors when I ran the command org-agenda. I may have messed up the
manual apply so I'll try again tonight.

Best wishes,

Colin.



Re: org-persist warning when archiving

2021-10-26 Thread Ihor Radchenko
Colin Baxter   writes:

> > Hello, Whenever I archive a DONE item via 'C-c C-x C-a' I get the
> > warning:
>
> > Warning (emacs): org-element--cache: Unregistered buffer
> > modifications detected. Resetting.
>
> > The archiving is successful, but I keep getting the warning and
> > therefore wonder if there is some org-persist or cache setting
> > that needs to be adjusted.
>
> Thinking a little more about this, I have not yet had a chance of
> archiving an item in a new emacs session. It may be that the warning
> is temporary to the first session and will disappear if and when I
> archive a DONE item in a new session.

This message always indicates some problem. However, I cannot reproduce
what you observe on my side. Did you try with emacs -Q? Also, you might
not be running the latest Org. I have extended this warning in recent
commits.

My crystal ball tells me that the attached patch might help. Can you try
it?

Best,
Ihor

>From da1e23bd1d8aaa673d034b288a6088868fe8abb7 Mon Sep 17 00:00:00 2001
Message-Id: 
From: Ihor Radchenko 
Date: Tue, 26 Oct 2021 19:19:57 +0800
Subject: [PATCH] org.el/org-mode: Do not inhibit `after-change-functions' when
 loading

* lisp/org.el (org-mode): Let-bind `buffer-undo-list' instead of using
`org-unmodified'.  The latter suppresses org-element-cache handling of
buffer changes.
---
 lisp/org.el | 32 
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 69ff7a8d4..a20be7aac 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4672,22 +4672,22 @@ (define-derived-mode org-mode outline-mode "Org"
 	 (= (point-min) (point-max)))
 (insert "#-*- mode: org -*-\n\n"))
   (unless org-inhibit-startup
-(org-unmodified
- (when org-startup-with-beamer-mode (org-beamer-mode))
- (when (or org-startup-align-all-tables org-startup-shrink-all-tables)
-   (org-table-map-tables
-	(cond ((and org-startup-align-all-tables
-		org-startup-shrink-all-tables)
-	   (lambda () (org-table-align) (org-table-shrink)))
-	  (org-startup-align-all-tables #'org-table-align)
-	  (t #'org-table-shrink))
-	t))
- (when org-startup-with-inline-images (org-display-inline-images))
- (when org-startup-with-latex-preview (org-latex-preview '(16)))
- (unless org-inhibit-startup-visibility-stuff (org-cycle-set-startup-visibility))
- (when org-startup-truncated (setq truncate-lines t))
- (when org-startup-numerated (require 'org-num) (org-num-mode 1))
- (when org-startup-indented (require 'org-indent) (org-indent-mode 1
+(let ((buffer-undo-list t))
+  (when org-startup-with-beamer-mode (org-beamer-mode))
+  (when (or org-startup-align-all-tables org-startup-shrink-all-tables)
+(org-table-map-tables
+	 (cond ((and org-startup-align-all-tables
+		 org-startup-shrink-all-tables)
+	(lambda () (org-table-align) (org-table-shrink)))
+	   (org-startup-align-all-tables #'org-table-align)
+	   (t #'org-table-shrink))
+	 t))
+  (when org-startup-with-inline-images (org-display-inline-images))
+  (when org-startup-with-latex-preview (org-latex-preview '(16)))
+  (unless org-inhibit-startup-visibility-stuff (org-cycle-set-startup-visibility))
+  (when org-startup-truncated (setq truncate-lines t))
+  (when org-startup-numerated (require 'org-num) (org-num-mode 1))
+  (when org-startup-indented (require 'org-indent) (org-indent-mode 1
 
   ;; Add a custom keymap for `visual-line-mode' so that activating
   ;; this minor mode does not override Org's keybindings.
-- 
2.32.0



Re: org-persist warning when archiving

2021-10-26 Thread Colin Baxter 
> Colin Baxter   writes:

> Hello, Whenever I archive a DONE item via 'C-c C-x C-a' I get the
> warning:

> Warning (emacs): org-element--cache: Unregistered buffer
> modifications detected. Resetting.

> The archiving is successful, but I keep getting the warning and
> therefore wonder if there is some org-persist or cache setting
> that needs to be adjusted.

Thinking a little more about this, I have not yet had a chance of
archiving an item in a new emacs session. It may be that the warning
is temporary to the first session and will disappear if and when I
archive a DONE item in a new session.

Colin.




org-persist warning when archiving

2021-10-26 Thread Colin Baxter 
Hello,

Whenever I archive a DONE item via 'C-c C-x C-a' I get the warning:

Warning (emacs): org-element--cache: Unregistered buffer modifications
detected. Resetting.

The archiving is successful, but I keep getting the warning and
therefore wonder if there is some org-persist or cache setting that
needs to be adjusted.

Best wishes,

Colin Baxter.