0

I recently made the following modification to my init.el to show :LOGBOOK: entries in the org-agenda time-grid:

(use-package org
  (setq org-agenda-log-mode-items '(closed clock state)))

The only problem is that the entries for these :LOGBOOK: items are in a different format than the rest of the closed tasks in the time-grid.

NORMAL : Closed: 12:30-13:45 routine: DONE Eat lunch

LOGBOOK: State: (CLOSED) 12:30-13:45 routine: DONE Eat lunch

How can I fix it so that the (CLOSED) bit doesn't get added, or perhaps moved to a place where it doesn't affect the alignment of the timestamps?

I've tried the following:

  • I tried messing with org-agenda-prefix-format.

  • I tried searching for help pages for any variable or function named *agenda*log*, and none of the ones I found applied to this.

1
  • The formats are hardwired. You'd have to change the code.
    – NickD
    Nov 9, 2023 at 2:11

1 Answer 1

0

Thanks to @NickD for telling me where to find it. Indeed the solution is to change the definition of (org-agenda-get-progress). The part to be changed is about 20 lines up from the end of the function.

This has been edited after @NickD pointed out that the original was a bad solution. Hope this works better.

Change the following:

...
(setq txt (org-agenda-format-item
           (cond
            (closedp "Closed:   ")
            (statep (concat "State:     (" state ")"))
            (t (concat "Clocked:   (" clocked ")")))
...

To this:

...
(setq txt (org-agenda-format-item
           (cond
            (closedp (concat "Closed:       " (spaces-string 12))
            (statep (concat "State:      (" state ")" (spaces-string (- 12 (length state)))))
            (t (concat "Clocked:    (" clocked ")" (spaces-string (- 12 (length clocked))))))
...

The number 12 in (spaces-string 12) and (spaces-string (- 12 (length state))) can be whatever you want it to be, and maybe there's a way to calculate the "correct" value without hard-coding it, but it works for me. It's just for alignment. Also on the subject of alignment:

Make sure to modify org-agenda-prefix-format to make the rest of the time-grid entries align properly based on the number of spaces added to the ones above. I calculated it needs 14 extra spaces, but it might be different for others.

6
  • I think the resulting output would be misleading: you'd get State: 12:30-13:45 routine: DONE Eat lunch without any indication of what state the item is in. I would not recommend that you do it this way.
    – NickD
    Nov 9, 2023 at 14:02
  • You are right, I'm working on something a little better which retains both the extra information and the alignment. Nov 9, 2023 at 20:59
  • If you fork the code, you should also think carefully about how to maintain your changes in the long run; otherwise, you'll be chasing your tail every time you upgrade Org (whether you do the upgrade yourself or whether your distro does it for you) - DAMHIKT...
    – NickD
    Nov 9, 2023 at 21:32
  • Any advice on what would be a good way to maintain it? I have never forked/maintained a project before but I'm eager to learn. Nov 9, 2023 at 22:44
  • Yes: don't if you can avoid it. Either figure out a good way to do what you want and submit it as a suggested change (see How to contribute) - if it is accepted, you are home free. If not, maybe you decide that you can live with the code as is, despite the formatting problem. If neither of these is palatable to you, then it depends on how you do your upgrades. The trouble is that the question is off-topic for this site;also this is a wide and open-ended question which doesn't really work for any SE site. Maybe reddit is the best place to ask.
    – NickD
    Nov 10, 2023 at 3: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.