emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Mathena <jmmathena@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [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/)]
Date: Tue, 28 Dec 2021 10:39:26 -0600	[thread overview]
Message-ID: <CADywB5KOJ1p0NpvA=iX-ybHsO=huGA8qL3xMpUTETmS2qp7_ng@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2021-12-28 16:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28 16:39 John Mathena [this message]
2021-12-29  3:48 ` [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/)] Ihor Radchenko
2022-01-01  6:36   ` Ihor Radchenko
2022-01-06 22:42     ` John Mathena
2022-01-07 14:20       ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADywB5KOJ1p0NpvA=iX-ybHsO=huGA8qL3xMpUTETmS2qp7_ng@mail.gmail.com' \
    --to=jmmathena@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).