1

I'm using a script to translate my calendars from ics to an org file, so that scheduled events appear in my agenda. An entry in the org file has the following format, with CALENDAR being an agenda keyword:

* CALENDAR event description
SCHEDULED: <2021-12-14 10:00-11:00>

In the agenda, this might show up between two scheduled tasks, one closed and one still open, as follows:

SomeOrgFile     09:00       Scheduled: DONE SomeTask
CalendarOrgFile 10:00-11:00 Scheduled: CALENDAR event description
SomeOrgFile     11:00       Scheduled: TODO SomeOtherTask

When checking with describe-char, the org-agenda-done face applies to the DONE task and the CALENDAR event, while the org-scheduled-today face applies to the 3rd (TODO) line.

What I want is the second line (i.e., the file name, the time, "Scheduled", and the event description) to be a different color from both the first and the 3rd line. How can I achieve this?

4
  • Hello! You might find what you want in this answer. The idea is to add new keywords in org-todo-keyword-faces.
    – Lalylulelo
    Commented Nov 30, 2021 at 9:40
  • @Lalylulelo Thanks, but that only applies to changing the color/face of the keyword itself, not the agenda item.
    – Zhao Nan
    Commented Nov 30, 2021 at 15:44
  • There are multiple faces applying to each line of the agenda: do C-u C-x = on each character and examine the faces. Then update the question to specify exactly what you want to accomplish: the best way is to provide an example agenda item with a description of what each part of it should look like. The default format for an agenda item is described by the variable org-agenda-prefix-format.
    – NickD
    Commented Nov 30, 2021 at 16:57
  • 1
    Thanks for your reply, @NickD. I edited my question as proposed by you and hope I made it a bit more clear.
    – Zhao Nan
    Commented Dec 1, 2021 at 9:25

1 Answer 1

0

I recently returned to this question and solved it with the help of user yantar92 on the orgmode subreddit. I'll post the solution in case anyone wants to do something similar:

(defface org-agenda-cal-highlight-face `((t :foreground "deep sky blue"))
    "Face used to highlight CalendarOrgFile entries in agenda view.")
  (defun org-agenda-highlight-cal-entry ()
    "Highlight calendar items in agenda."
    (let ((inhibit-read-only t))
      (save-excursion
        (goto-char (point-min))
        (while (re-search-forward "CALENDAR" nil t)
            (font-lock-prepend-text-property (line-beginning-position) (line-end-position) 'face 'org-agenda-cal-highlight-face)))))
  (add-hook 'org-agenda-finalize-hook #'org-agenda-highlight-cal-entry)

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.