0

How can I change only the format of current day (using Doom Emacs).

What I have:

Saturday   20 April 2024
Sunday     21 April 2024
Monday     22 April 2024 W17
Tuesday    23 April 2024

What I want:

Saturday   20 April 2024
Sunday     21 April 2024 <<<<<<<<<<<<
Monday     22 April 2024 W17
Tuesday    23 April 2024

(The arrows are pointing to today)

1 Answer 1

1

You can write a function that does what you want and add it to org-agenda-finalize-hook (you should read the doc string of this variable with C-h v org-agenda-finalize-hook):

#+begin_src elisp :results drawer :tangle foo.el
  (with-eval-after-load 'org-agenda
    (defun my/org-agenda-mod-today ()
      (save-excursion
        (beginning-of-buffer)
        (if (text-property-search-forward 'day (org-today) t)
            (insert " <<<<<<<<"))))

    (add-hook 'org-agenda-finalize-hook #'my/org-agenda-mod-today)

    ;; (remove-hook 'org-agenda-finalize-hook #'my/org-agenda-mod-today)
  )
#+end_src

This code should be added to your init file. The with-eval-after-load makes sure that org-agenda is loaded before the hook is modified. That's probably unnecessary (add-hook sets the value of the hook to nil if it is undefined), but I like the safety of belt-and-suspenders.

Basically, the function searches in the Org agenda buffer for the day text property whose value (the "absolute" day number) is equal to today and, if present, adds some text to the buffer at the end of the line. The add-hook call adds the function to the hook which causes the function to be called after the agenda is ready.

If you want to remove the function from the hook, just do C-x C-e after the closing parenthesis of the remove-hook form.

4
  • dude, this works. but in agenda buffer, when i press f or b to move to the previous / next agenda span, it adds an extra set of <<<<<<<<<<<<<<< and doesn't move at all. Once i remove the hook, i can see that it works well.
    – Saravana
    Commented Apr 21 at 14:05
  • org-agenda-goto-today is interacting with the rest of the earlier/later/goto-date functions. I need to replace it with a more lightweight mechanism and probably also check if the mark exists already or maybe add an overlay instead of modifying the agenda buffer. I'll take the answer offline for now.
    – NickD
    Commented Apr 21 at 17:14
  • @Saravana: This should work better and not trip up org-agenda-earlier/later, although it still might have other problems. It still inserts the marker into the buffer, but that does not seem to cause problems. Thanks for pointing out the problem and please let me know if you find more.
    – NickD
    Commented Apr 21 at 19:32
  • OP: Did you see this? Did you try it? Did it work?
    – NickD
    Commented Apr 23 at 13:52

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.