emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] bulk relative time shift (in org file)?


From: Memnon Anon
Subject: Re: [O] bulk relative time shift (in org file)?
Date: Fri, 1 Jul 2011 03:36:04 +0000 (UTC)

Hi Michael,

Michael Gilbert <address@hidden> writes:

> - select a number of items with time stamps in an org file (either by
> region or, if I must, all items subsidiary to a headline) 
> - change all of their deadlines (or some other time stamp) by a set
> number of days, relative to the date they currently have - the result
> is a bulk rescheduling, with the relative timing of the items
> remaining intact

This is interesting! Elisp fun, where is my *scratch*?!

[Later ... much later]

When I heard Bulk rescheduling, I naturally turned to the agenda.
(To be honest, I would probably have tried another way if I had read
your mail more carefully the first time)

I know, you said:
> - I would prefer to do this in the org file, not in the Agenda. This
> is a planning activity.

But the agenda is in many ways another interface to the org file.
And it supports limiting to: Region, Subtree, etc.

So, based on the example in the manual, I made this prototype for
deadlines:

--8<---------------cut here---------------start------------->8---
(defun my-org-bulkshift-deadline ()
  "Shift the deadline of marked items in the agenda by 
  n days. Set n via Prefix Arg!"
  (interactive "P")
  (let* ((marker (or (org-get-at-bol 'org-hd-marker)
                     (org-agenda-error)))
         (buffer (marker-buffer marker))
         )
    (with-current-buffer buffer
      (save-excursion
        (save-restriction
          (widen)
          (goto-char marker)
          (org-back-to-heading t)
          (when (and (org-entry-get (point) "DEADLINE") ; There is a deadline 
there
                     (numberp current-prefix-arg))      ; And 
current-prefix-arg is a number
            (re-search-forward org-deadline-time-regexp)
            (org-timestamp-change current-prefix-arg 'day)))))))
--8<---------------cut here---------------end--------------->8---

So, if you have a Project like this one:

* Proj a
** NEXT Task 1                  :TAGA:TAGB:
** TODO Task 2                  :TAGC:
** Task 3                       :TAGD:
** TODO [#A] Task 4                                                
** TODO [#A] Task 5                                                

Use the agenda and its filtering and limiting support to 
a) limit to subtree, to region or limit to buffer
b) include/exlude TAGa/b/c
c) include/exclude state WAITING/NEXT/whatever
d) etc.etc.etc.
(and there are custom agendas as well :)

And when you have what you want, you just <m>ark 'em up
and do "M-15 B f my-org-bul<TAB>" and its done.

You can use many levels of filtering, but you don't have to of course.

Sleepy me did only minimal testing so far, but the prototype
seems to work and my-org-bulkshift-scheduled, -plain et al. can be easily 
added and/or combined into one function.

Seems to me that using the agenda is the most flexible approach...

> Any guidance?

Oh, guidance would be great: I'm curious what others will propose.

Memnon "off to bed" Anon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]