瀏覽代碼

C-u B S now scatters tasks across weekdays only

John Wiegley 14 年之前
父節點
當前提交
4d575c8a03
共有 1 個文件被更改,包括 21 次插入2 次删除
  1. 21 2
      lisp/org-agenda.el

+ 21 - 2
lisp/org-agenda.el

@@ -7874,8 +7874,27 @@ The prefix arg is passed through to the command if possible."
 			 (fmakunbound 'read-string)))))))
 
      ((eq action '?S)
-      (let ((days (read-number "Scatter tasks across how many days: " 7)))
-	(setq cmd `(org-agenda-date-later (random ,(1+ days))))))
+      (let ((days (read-number
+		   (format "Scatter tasks across how many %sdays: "
+			   (if arg "week" "")) 7)))
+	(setq cmd
+	      `(let ((distance (random ,(1+ days))))
+		 (if arg
+		     (let ((dist distance)
+			   (day-of-week
+			    (calendar-day-of-week
+			     (calendar-gregorian-from-absolute (org-today)))))
+		       (dotimes (i (1+ dist))
+			 (while (member day-of-week org-agenda-weekend-days)
+			   (incf distance)
+			   (incf day-of-week)
+			   (if (= day-of-week 7)
+			       (setq day-of-week 0)))
+			 (incf day-of-week)
+			 (if (= day-of-week 7)
+			     (setq day-of-week 0)))))
+		 (org-agenda-date-later distance)))))
+
      (t (error "Invalid bulk action")))
 
     ;; Sort the markers, to make sure that parents are handled before children