codygman
codygman

Reputation: 832

Bulk reschedule org agenda items preserving date

I sometimes forget to do one or more of my daily habits that happen at the same time each day and need to bring them current so I can get orgzly notifications of them.

I am able to shift a single item in org agenda preserving the date with M-x org-agenda-date-later and it reschedules that to the current date with whatever time existed.

If I try to use it as a bulk action by marking an item and doing B f org-agenda-date-later I get:

Debugger entered--Lisp error: (wrong-number-of-arguments #f(compiled-function (arg &optional what) (interactive "p") #<bytecode 0x1ad5eed>) 0)
  org-agenda-date-later()
  org-agenda-bulk-action(nil)
  funcall-interactively(org-agenda-bulk-action nil)
  call-interactively(org-agenda-bulk-action nil nil)
  command-execute(org-agenda-bulk-action)

This tells me that org-agenda-date-later wasn't written to be used as a bulk action. One solution for this could be writing a bulk action that calls org-agenda-date-later multiple times but I do not know how to do that.

I searched for other solutions and I found something recommended by the author of org mode from the org mode FAQ:

(defun org-agenda-reschedule-to-today ()
  (interactive)
  (flet ((org-read-date (&rest rest) (current-time)))
    (call-interactively 'org-agenda-schedule)))

This works as a bulk action but it loses the time the item was scheduled. That means I would have to go through my habits and reschedule the time for each one after doing this which is inconvenient.

Upvotes: 1

Views: 387

Answers (1)

Rorschach
Rorschach

Reputation: 32446

There is the org-agenda-bulk-custom-functions to which you can add a key-binding and an associated function. So, for example, adding a binding for D after calling org-agenda-bulk-action, you could use

(setq org-agenda-bulk-custom-functions
      `((?D (lambda () (call-interactively 'org-agenda-date-later)))
        ,@org-agenda-bulk-custom-functions))

It will pass the prefix on, allowing C-u -1 B D to reshedule the tasks a day earlier at the same time, for example.

Upvotes: 1

Related Questions