emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Setting org-map-continue from to avoid skipping headings while archiving no longer works [9.5.2 (9.5.2-gd01235 @ /home/john/.emacs.d/straight/build/org/)]
@ 2021-12-28 16:39 John Mathena
  2021-12-29  3:48 ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: John Mathena @ 2021-12-28 16:39 UTC (permalink / raw)
  To: emacs-orgmode

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

It's a common workflow to iterate over all Org headings in a given file,
archiving those marked with the "DONE" keyword. The only problem is that
archiving changes the structure of the file you're operating on, so if you
have test.org:

    * DONE A
    * DONE B
    * DONE C
    * DONE D

A will be archived, moving [B, C, D] up, with point on B. Then, point is
advanced to the next heading, so B gets skipped in favor of C getting
archived. The end result is B and D remaining in the file instead of being
archived.

In Org 9.4.4, you can fix this issue with a snippet like this:

(defun my-org-archive-done-tasks ()
  "Archive all top-level tasks with the DONE keyword in the current file."
  (interactive)
  (org-map-entries
   (lambda ()
     (org-archive-subtree)
     (setq org-map-continue-from (org-element-property :begin
(org-element-at-point))))
   "LEVEL=1/DONE"
   'file))

...where you set org-map-continue-from in order to avoid skipping every
other heading. However, upon updating to Org 9.5.2-gd01235, this function
no longer works - if you have a file like test.org above, eval
"my-org-archive-done-tasks", and try to run it on the file, every other
heading is still skipped. I verified this by trying this function on
test.org twice, first after running "emacs -Q", and then after doing "emacs
-Q -l ~/.emacs.d/straight/repos/straight.el/bootstrap.el" and "M-x
straight-use-package org"

I believe this is a result of recent additions in org-scan-tags - I hit a
dead end there while trying to determine the exact cause of the change (the
caching stuff that was added is spooky for a new user like me).

Is the snippet above no longer expected to work in Org 9.5.2 due to the
logic for mapping over entries having changed, or is this a bug? If it's
the former, what's the intended way of archiving all DONE tasks in a file
now?

Emacs   : GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.27, cairo version 1.17.4) of 2021-03-26
Package: Org mode version 9.5.2 (9.5.2-gd01235 @
/home/john/.emacs.d/straight/build/org/)

(And the function above *does* work in Package: Org mode version 9.4.4
(release_9.4.4 @ /usr/share/emacs/27.2/lisp/org/))

Best,
John

[-- Attachment #2: Type: text/html, Size: 2574 bytes --]

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

end of thread, other threads:[~2022-01-07 14:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-28 16:39 [BUG] Setting org-map-continue from to avoid skipping headings while archiving no longer works [9.5.2 (9.5.2-gd01235 @ /home/john/.emacs.d/straight/build/org/)] John Mathena
2021-12-29  3:48 ` Ihor Radchenko
2022-01-01  6:36   ` Ihor Radchenko
2022-01-06 22:42     ` John Mathena
2022-01-07 14:20       ` Ihor Radchenko

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