Skip to content

Instantly share code, notes, and snippets.

@whhone
Last active January 5, 2025 20:00
Show Gist options
  • Save whhone/214fa34d57ec6eebc09f3c45bc153378 to your computer and use it in GitHub Desktop.
Save whhone/214fa34d57ec6eebc09f3c45bc153378 to your computer and use it in GitHub Desktop.
Past Solution with "org-agenda-finalize-hook"
;; Past solution for https://whhone.com/posts/org-agenda-repeated-tasks/
(defun my/org-agenda-entry-get-repeat ()
"Get the repeater of the current entry with 'org-get-repeat'."
(when-let ((marker (org-get-at-bol 'org-marker))
(buffer (marker-buffer marker))
(pos (marker-position marker)))
(with-current-buffer buffer
(goto-char pos)
(org-get-repeat))))
(defun my/org-agenda-update-repeated-entry()
"Update the scheduled leader to repeater for current entry.
e.g., Replace 'Scheduled:' to 'Rept .+1d:'."
(save-excursion
(when-let ((org-repeat (my/org-agenda-entry-get-repeat))
(rept-str (format "Rept %4s: " org-repeat))
(scheduled-leader (car org-agenda-scheduled-leaders)))
(when (search-backward scheduled-leader (pos-bol) t)
(delete-forward-char (length scheduled-leader))
(insert-and-inherit rept-str)))))
(defun my/org-agenda-update-repeated-entries ()
"Update the scheduled leader to repeater for all entries."
(save-excursion
(goto-char (point-min))
(while (text-property-search-forward 'type "scheduled" t)
(my/org-agenda-update-repeated-entry))))
(add-hook 'org-agenda-finalize-hook #'my/org-agenda-update-repeated-entries)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment