summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2011-04-13 09:57:49 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2011-04-14 00:10:56 +0200
commite20166eb29ac80aab808f4b13313a0f2b236e9b1 (patch)
treef73b6357f4a8b59d8122255be1853eccb8ba936e
parent2c8e964b70bf22ae70ef824b422fb12e1783f8a2 (diff)
downloadorg-mode-e20166eb29ac80aab808f4b13313a0f2b236e9b1.tar.gz
Fix the bulk scatter command to always schedule
* lisp/org-agenda.el (org-agenda-bulk-action): Allow bulk scatter in all possible agenda views. Use `org-agenda-schedule' instead of `org-agenda-date-later'. The bulk scatter command so far shifted the date that was causing an entry to appear in the agenda. However, the true intend was to reschedule onto dates in the near future. This patch fixes this issue. A side effect is that you can now bulk scatter tasks that to not yet have a date, for example also tasks picked from the TODO list.
-rw-r--r--doc/org.texi4
-rw-r--r--lisp/org-agenda.el20
2 files changed, 18 insertions, 6 deletions
diff --git a/doc/org.texi b/doc/org.texi
index 769c113..dc62b8f 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -8079,8 +8079,8 @@ t @r{Change TODO state. This prompts for a single TODO keyword and}
s @r{Schedule all items to a new date. To shift existing schedule dates}
@r{by a fixed number of days, use something starting with double plus}
@r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
-S @r{Reschedule randomly by N days. N will be prompted for. With prefix}
- @r{arg (@kbd{C-u B S}), scatter only accross weekdays.}
+S @r{Reschedule randomly into the coming N days. N will be prompted for.
+ @r{With prefix arg (@kbd{C-u B S}), scatter only accross weekdays.}
d @r{Set deadline to a specific date.}
f @r{Apply a function to marked entries.}
@r{For example, the function below sets the CATEGORY property of the}
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 5571838..a65d2d1 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7933,8 +7933,18 @@ This will remove the markers, and the overlays."
"Execute an remote-editing action on all marked entries.
The prefix arg is passed through to the command if possible."
(interactive "P")
- (unless org-agenda-bulk-marked-entries
- (error "No entries are marked"))
+ ;; Make sure we have markers, and only valid ones
+ (unless org-agenda-bulk-marked-entries (error "No entries are marked"))
+ (mapc
+ (lambda (m)
+ (unless (and (markerp m)
+ (marker-buffer m)
+ (buffer-live-p (marker-buffer m))
+ (marker-position m))
+ (error "Marker %s for bulk command is invalid" m)))
+ entries)
+
+ ;; Prompt for the bulk command
(message "Bulk: [r]efile [$]arch [A]rch->sib [t]odo [+/-]tag [s]chd [S]catter [d]eadline [f]unction")
(let* ((action (read-char-exclusive))
(org-log-refile (if org-log-refile 'time nil))
@@ -7999,7 +8009,7 @@ The prefix arg is passed through to the command if possible."
(fmakunbound 'read-string)))))))
((equal action ?S)
- (if (not (org-agenda-check-type nil 'agenda 'timeline))
+ (if (not (org-agenda-check-type nil 'agenda 'timeline 'todo))
(error "Can't scatter tasks in \"%s\" agenda view" org-agenda-type)
(let ((days (read-number
(format "Scatter tasks across how many %sdays: "
@@ -8022,7 +8032,9 @@ The prefix arg is passed through to the command if possible."
(setq day-of-week 0)))))
;; silently fail when try to replan a sexp entry
(condition-case nil
- (org-agenda-date-later distance)
+ (org-agenda-schedule nil
+ (days-to-time
+ (+ (org-today) distance)))
(error nil)))))))
((equal action ?f)