4

I'm trying to show certain icons to the left of TODO items in the agenda based on the presence of a property.

For example, if TODO item A has the "important" property, show an exclamation mark:

!  TODO A
   TODO B

It looks like this can be customized with org-agenda-prefix-format using the %(expression) syntax, but I encounter bizarre issues when using the following syntax:

(defun show-exclamation-if-important()
  (save-window-excursion
    (org-agenda-goto)
    (if (org-entry-properties (point) "important")
        "!"
      " ")))

This combined with using %(show-exclamation-if-important) returns user-error: Command not allowed in this line. It seems to be an issue with the excursion of some sorts?

Simply put, how can I get a return value of the properties of a TODO item while on the corresponding agenda entry?

3

The error you get is thrown by org-agenda-goto when it can't find an agenda entry corresponding to point. After some further investigation, it looks like this is because the function is actually not called from the agenda, but rather from the file containing the entry. That is, you're already where org-agenda-goto would put you, so you don't need either that or the save-window-excursion:

(defun show-exclamation-if-important () 
  (if (org-entry-properties (point) "important") "!" " "))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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