Skip to content

Instantly share code, notes, and snippets.

@davemq
Created October 8, 2024 21:02
Show Gist options
  • Save davemq/aed050eade20e070ecdb7189460131d1 to your computer and use it in GitHub Desktop.
Save davemq/aed050eade20e070ecdb7189460131d1 to your computer and use it in GitHub Desktop.
Org agenda bulk deadline scatter
;; org agenda bulk action for random scatter for deadlines
(defun drm:org-agenda-deadline ()
(unless (org-agenda-check-type nil 'agenda 'todo)
(user-error "Can't scatter tasks in \"%s\" agenda view" org-agenda-type))
(let ((days (read-number "Scatter tasks across how many days: " 7)))
(let ((distance (1+ (random days))))
;; Silently fail when try to replan a sexp entry.
(ignore-errors
(let* ((date (calendar-gregorian-from-absolute
(+ (org-today) distance)))
(time (encode-time 0 0 0 (nth 1 date) (nth 0 date)
(nth 2 date))))
(org-agenda-deadline nil time)
)
)
)
)
)
;; I tried setting this through customize, but it didn't seem to work
(setq org-agenda-bulk-custom-functions
'((?D drm:org-agenda-deadline)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment