0

Can you change categories based on their files? For example there is a file todo.org in an orgzly folder and another todo.org in a local folder. Could you change org-agenda-prefix-format (or something else) so that entries in these org files show up in org-agenda as orgzly and local instead of both showing up as todo? enter image description here

3
  • 1
    Add #+CATEGORY: orgzly at the top of the first one and #+CATEGORY: local at the top of the second one.
    – NickD
    Feb 25 at 18:34
  • Thanks @NickD, that worked. Strange, I always append new entries to the beginning of the .org file in orgzly (to have them show up at the top instead of scrolling to the bottom), so I thought that adding #+CATEGORY: orgzly will get overwritten by the subsequent entries. It turns out it gets picked up by org-agenda even if it's added in the middle. Good stuff! Feb 28 at 23:38
  • 1
    Keywords have global scope, no matter where they are defined. But it's best to keep them visible, so adding them to the beginning of the file is recommended.
    – NickD
    Feb 29 at 3:17

1 Answer 1

0

Execute C-h v org-agenda-prefix-format RET in Emacs, you will find the answer. Actually, you will find that you can use any elisp expression you want:

  %(expression) Eval EXPRESSION and replace the control string
                by the result

Based on that, you can use the below expression to replace %c there, it will serve your need: %(file-name-nondirectory (directory-file-name (file-name-directory (buffer-file-name))))

1
  • That's not enough to do what is asked: you have to conditionally make the category orgzly or local depending on the pathname. But as mentioned in my comment, it is simpler to set the category of each file explicitily.
    – NickD
    Feb 25 at 18:36

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.