emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* bulk relative time shift (in org file)?
@ 2011-06-30 22:24 Michael Gilbert
  2011-07-01  3:36 ` Memnon Anon
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Gilbert @ 2011-06-30 22:24 UTC (permalink / raw)
  To: emacs-orgmode Mailinglist

Hi —

I've spent a fair amount of time with the manual and have hints that this might be possible, but I'm not piecing it together. Basically what I want to do is this:

- 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

Additional points:

- I would prefer to select the type of timestamp to change, but I can probably work with it changing all of them. (Note that some items have both Scheduled and Deadline timestamps. Some even have other, inactive timestamps. Plus, there are also timestamps in the Logbook on some items.)
- I would prefer to do this in the org file, not in the Agenda. This is a planning activity.
- I can see how I might do this by cloning the subtree, but that seems like an ugly hack, involving deleting the original.

Any guidance?

TIA!

— Michael


The Gilbert Center: http://gilbert.org
Nonprofit News: http://nonprofitnews.org

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

* Re: bulk relative time shift (in org file)?
  2011-06-30 22:24 bulk relative time shift (in org file)? Michael Gilbert
@ 2011-07-01  3:36 ` Memnon Anon
  2011-07-12 21:30   ` Memnon Anon
  0 siblings, 1 reply; 9+ messages in thread
From: Memnon Anon @ 2011-07-01  3:36 UTC (permalink / raw)
  To: emacs-orgmode

Hi Michael,

Michael Gilbert <mcg@gilbert.org> 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

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

* Re: bulk relative time shift (in org file)?
  2011-07-01  3:36 ` Memnon Anon
@ 2011-07-12 21:30   ` Memnon Anon
  2011-07-16 17:10     ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Memnon Anon @ 2011-07-12 21:30 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

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

Anyone?
This question might have gone down in the prerelease turmoil ...

Memnon

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

* Re: bulk relative time shift (in org file)?
  2011-07-12 21:30   ` Memnon Anon
@ 2011-07-16 17:10     ` Bastien
  2011-07-16 18:00       ` Memnon Anon
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2011-07-16 17:10 UTC (permalink / raw)
  To: Memnon Anon; +Cc: emacs-orgmode

Hi Memnon,

Memnon Anon <gegendosenfleisch@googlemail.com> writes:

>>> Any guidance?
>> Oh, guidance would be great: I'm curious what others will propose.
>
> Anyone?
> This question might have gone down in the prerelease turmoil ...

My Gnus .overview has been corrupted and I lost track of the question.

Can you restate it shortly here?

Thanks!

-- 
 Bastien

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

* Re: bulk relative time shift (in org file)?
  2011-07-16 17:10     ` Bastien
@ 2011-07-16 18:00       ` Memnon Anon
  2011-07-24 16:06         ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Memnon Anon @ 2011-07-16 18:00 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bzg@altern.org> writes:
> My Gnus .overview has been corrupted and I lost track of the question.
> Can you restate it shortly here?

,----[ Original request as short as I can get it ]
| Michael is looking for a way to "bulk re'timestamp'" items 
| relativ to the timestamp the item has currently.
| This should work on region, subtree etc.
| He wants to avoid cloning and would prefer doing this 
| directly in the file, not with the agenda.
`----

Example:
--8<---------------cut here---------------start------------->8---
Before:
* Project A
** Task A
   SCHEDULED: <2011-07-16 Sa> 
** Taks B
   SCHEDULED: <2011-07-19 Di> 
** Task C
   SCHEDULED: <2011-07-21 Do> 

After "Bulk re-timestamp schedule +7d scope subtree" :
* Project A
** Task A
   SCHEDULED: <2011-07-23 Sa> 
** Taks B
   SCHEDULED: <2011-07-26 Di> 
** Task C
   SCHEDULED: <2011-07-28 Do> 
--8<---------------cut here---------------end--------------->8---

I said that the agenda seems to me the easiest way to do it.
>But the agenda is in many ways another interface to the org file.
(i.e. Agenda can be more than a calendar like presentation)
>And it supports limiting to: Region, Subtree, etc.
out of the box!

Prototype bulkshift by date:
#+begin_src emacs-lisp
(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)))))))
#+end_src
Use: "M-15 B f my-org-bul<TAB>" 
in the agenda (limited to what you want, then marking the items.)

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

Memnon "This is not really short :(" Anon

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

* Re: bulk relative time shift (in org file)?
  2011-07-16 18:00       ` Memnon Anon
@ 2011-07-24 16:06         ` Bastien
  2011-07-26 19:44           ` Memnon Anon
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2011-07-24 16:06 UTC (permalink / raw)
  To: Memnon Anon; +Cc: emacs-orgmode

Hi Memnon,

Memnon Anon <gegendosenfleisch@googlemail.com> writes:

> ,----[ Original request as short as I can get it ]
> | Michael is looking for a way to "bulk re'timestamp'" items 
> | relativ to the timestamp the item has currently.
> | This should work on region, subtree etc.
> | He wants to avoid cloning and would prefer doing this 
> | directly in the file, not with the agenda.
> `----

This is now feasible as a general feature for org-schedule 
and org-deadline.

On an item, `C-c C-s' and `C-c C-d' now allows you to use
"+2d" to say "schedule in 2 days from today" or "++2d" to 
say "schedule in 2 days from existing timestamp".

In agenda, `B s' and `B d' will also understand this and
let you reschedule/redeadline items relatively.

Let me know if this works okay for you -- and thanks for
bringing this up again!

-- 
 Bastien

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

* Re: bulk relative time shift (in org file)?
  2011-07-24 16:06         ` Bastien
@ 2011-07-26 19:44           ` Memnon Anon
  2011-07-28  2:01             ` Michael C Gilbert
  0 siblings, 1 reply; 9+ messages in thread
From: Memnon Anon @ 2011-07-26 19:44 UTC (permalink / raw)
  To: emacs-orgmode

Hi Bastien,

Bastien <bzg@altern.org> writes:

> On an item, `C-c C-s' and `C-c C-d' now allows you to use
> "+2d" to say "schedule in 2 days from today" or "++2d" to 
> say "schedule in 2 days from existing timestamp".
>
> In agenda, `B s' and `B d' will also understand this and
> let you reschedule/redeadline items relatively.
>
> Let me know if this works okay for you -- and thanks for
> bringing this up again!

"++" looks very useful!

I pinged Michael who started this thread, I hope we'll get an update
on his perspective. 

Thanks alot!

Memnon

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

* Re: bulk relative time shift (in org file)?
  2011-07-26 19:44           ` Memnon Anon
@ 2011-07-28  2:01             ` Michael C Gilbert
  2011-07-28 15:47               ` Memnon Anon
  0 siblings, 1 reply; 9+ messages in thread
From: Michael C Gilbert @ 2011-07-28  2:01 UTC (permalink / raw)
  To: emacs-orgmode Mailinglist

On Jul 26, 2011, at 12:44 PM, Memnon Anon wrote:

>  Bastien <bzg@altern.org> writes:
> 
>> On an item, `C-c C-s' and `C-c C-d' now allows you to use
>> "+2d" to say "schedule in 2 days from today" or "++2d" to 
>> say "schedule in 2 days from existing timestamp".
>> 
>> In agenda, `B s' and `B d' will also understand this and
>> let you reschedule/redeadline items relatively.
>> 
>> Let me know if this works okay for you -- and thanks for
>> bringing this up again!
> 
> "++" looks very useful! I pinged Michael who started this thread, I hope we'll get an update
> on his perspective. 

I missed the ++ usage in this context completely. Yes, this gets me close to what I was looking for.

Ideally, something like this should be available in the org file, rather than in the agenda. The reason being is that it is a common project planning task to shift all related tasks back by some set period of time. I can see expanding the notion to take dependencies into account, but that is not critical. I'm just looking for a way to do this routine in the project management & planning contexts in my own work and in my organization....

But if I shift back and forth to the agenda, then I can make this work. I'm assuming that the 'Cc C-s' and 'C-c C-d' commands don't work on regions or on everything under a heading?

— Michael

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

* Re: bulk relative time shift (in org file)?
  2011-07-28  2:01             ` Michael C Gilbert
@ 2011-07-28 15:47               ` Memnon Anon
  0 siblings, 0 replies; 9+ messages in thread
From: Memnon Anon @ 2011-07-28 15:47 UTC (permalink / raw)
  To: emacs-orgmode

Michael C Gilbert <mcg@gilbert.org> writes:

> Ideally, something like this should be available in the org file,
> rather than in the agenda. [...]
>
> But if I shift back and forth to the agenda, then I can make this
> work. I'm assuming that the 'Cc C-s' and 'C-c C-d' commands don't work
> on regions or on everything under a heading?

It may be feasible to make scheduling and deadlining act on region;
lets wait what Bastien thinks when he is back from well
deserved vacation.

I have been experimenting to get this done with a simple function
one could bind to e.g. `C-s M-s'. (Or one could defadvice
the proper functions (?), I have to read up on that ...)

In my first tests, it somewhat works, but the logbook
is updated only on the last item, not sure why that is, yet.

I will investigate later if no one jumps in and improves/replaces
this prototype:

--8<---------------cut here---------------start------------->8---
(defun my-org-schedule-shift ()
  (interactive)
  (let* ((acton (if (org-region-active-p) "region" 
		  "tree"))
	 (val (read-string (concat "shift "acton" by: "))))
    (if (equal acton "region")
	(org-map-region '(lambda () 
			   (org-schedule nil val)) (region-beginning) (region-end))
      (org-map-tree '(lambda () 
		       (org-schedule nil val))))))

(defun my-org-schedule-shift-region ()
  (interactive)
  (let ((val (read-string "Shift region by: ")))
   (org-map-region '(lambda () 
		      (org-schedule nil val)) (region-beginning) (region-end))))

(defun my-org-schedule-shift-tree ()
  (interactive)
  (let ((val (read-string "Shift region by: ")))
   (org-map-tree '(lambda () 
		      (org-schedule nil val)))))
--8<---------------cut here---------------end--------------->8---

Memnon

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

end of thread, other threads:[~2011-07-28 15:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-30 22:24 bulk relative time shift (in org file)? Michael Gilbert
2011-07-01  3:36 ` Memnon Anon
2011-07-12 21:30   ` Memnon Anon
2011-07-16 17:10     ` Bastien
2011-07-16 18:00       ` Memnon Anon
2011-07-24 16:06         ` Bastien
2011-07-26 19:44           ` Memnon Anon
2011-07-28  2:01             ` Michael C Gilbert
2011-07-28 15:47               ` Memnon Anon

Code repositories for project(s) associated with this 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).