By customizing org-agenda-confirm-kill, I am able to get confirmation when I kill a task in an agenda view. I can set this to t to always ask for confirmation (which I don't want to do, because I usually just kill one off tasks instead of marking them DONE), or to a number n so that I have to confirm when a TODO spans n or more lines. I currently have this set as follows:

(setq org-agenda-confirm-kill 2)

This will prevent me from accidentally removing a TODO with notes or other information that I am not seeing when in agenda view. However, I am also worried about accidentally deleting repeating tasks. Is there any way to get confirmation in the agenda views before killing repeating tasks?

1 Answer 1


Advise org-agenda-kill to check org-get-repeat and prompt if there is a repeater. Use a :before-while advice so that execution stops if the querying function returns false. Since we're doing this from the agenda we will first have to find and go to the actual location to check the repeater.

(defun org-agenda-repeating-p ()
  (let ((pos (get-text-property 0 'org-marker (thing-at-point 'line))))
      (org-goto-marker-or-bmk pos)

(defun query-if-repeating (&rest args)
  (if (not (org-agenda-repeating-p))
    (y-or-n-p "Entry repeats.  Kill?"))

(advice-add 'org-agenda-kill :before-while 'query-if-repeating)
  • This works great for TODOs with a repeater, but for some reason prevents me from killing any tasks without a repeater.
    – elethan
    Nov 29, 2016 at 18:56
  • @elethan query-if-repeating needs to return t if the task isn't repeating, which it wasn't. I edited in a fix.
    – erikstokes
    Nov 29, 2016 at 23:34
  • One more little hiccup...Now if I press "n" when prompted, it will still kill the line...
    – elethan
    Nov 30, 2016 at 2:47
  • Fixed again. Try this version
    – erikstokes
    Dec 1, 2016 at 0:18
  • That did it. Thanks for all the work!
    – elethan
    Dec 1, 2016 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.