emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Visher <tim.visher@gmail.com>
To: Emacs Org Mode mailing list <emacs-orgmode@gnu.org>
Subject: Refiling All 'Terminal TODO State' Entries to a Particular Heading
Date: Thu, 6 May 2021 10:23:37 -0400	[thread overview]
Message-ID: <CAHa53uyAgajfOk4NhovGDJ4f1OVvFf03XxwbgR89jgJ1M0K3Ew@mail.gmail.com> (raw)

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

Hi Everyone,

Partly because I think it's neat and partly to ask for ways that I could
improve it I figured I'd share my latest little snippet of org elisp with
the list.

I maintain my primary TODO list as an org file with top-level headings like *
This Week, * Delegated, * Scheduled, * Deferred, etc. These all contain
TODOs or potential TODOs.

Anything I intend to work on near term I refile into * This Week and that's
then the primary heading that I'm burning down throughout my day.

I do weekly reflection/projections and 6 week reflection/projections. When
I do a weekly reflection I go through another heading * Done to remind
myself what I accomplished in the past week. When I do a 6 week
reflection/projection I review the Done heading one more time and then I
refile all the entries currently there into an * Archive heading. Then
every now and then I actually archive entries in Archive into an
*.org_archive file. * Done and * Archive are both tagged with ARCHIVE.

In an effort to start automating some of this effort I wrote the following
elisp to refile all the Level 2 entries to the Done heading:

(defun timvisher-org-refile-done-entry-position
    ()
  (save-excursion
    (goto-char (point-min))
    (re-search-forward "^\\* Done")))

(defun timvisher-org-refile-done-entry
    ()
  (org-refile nil
              (current-buffer)
              (list "* Done"
                    (buffer-file-name)
                    nil
                    (timvisher-org-refile-done-entry-position))))

(defun timvisher-org-refile-done-entries
    ()
  (interactive)
  (length
   (org-map-entries #'timvisher-org-refile-done-entry
                    "LEVEL=2/+DONE|+CANCELLED"
                    nil
                    'archive)))

I'm doing Level 2 only because for long running projects I tend to have a
single Level 2 heading with many subheadings representing the project's
breakdown and I don't want them to be refiled out of the project.

Opportunities for improvement would be:

   1. Is there a better way to find the * Done entry than searching for it
   every time?
   2. Am I using org-refile correctly there? It's functional but it also
   seems needlessly complicated.

Hope this finds you all well. :)

--

In Christ,

Timmy V.

https://blog.twonegatives.com
http://five.sentenc.es

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

             reply	other threads:[~2021-05-06 14:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 14:23 Tim Visher [this message]
2021-05-11  4:56 ` Refiling All 'Terminal TODO State' Entries to a Particular Heading Ihor Radchenko
2021-05-12 13:35 ` Tim Visher
2021-05-12 14:54   ` 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=CAHa53uyAgajfOk4NhovGDJ4f1OVvFf03XxwbgR89jgJ1M0K3Ew@mail.gmail.com \
    --to=tim.visher@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).