I'm interested in changing my org-mode buffers to have a better looking logbook. My ideal state to end up in is that text that looks like this:

- State "WAITING"    from "WAITING"    [2018-11-16 Fri 16:00] \\
  description of why this task is still waiting
- State "WAITING"    from "WAITING"    [2018-11-16 Fri 11:20]
- State "WAITING"    from "NEXT"       [2018-11-15 Thu 11:55] \\
  Addressed feedback Bump on 2018-11-19 if not approved yet.

instead is formatted to look like this

- WAITING [2018-11-16 Fri 16:00] \\
  description of why this task is still waiting
- WAITING [2018-11-16 Fri 11:20]
- WAITING [2018-11-15 Thu 11:55] \\
  Addressed feedback Bump on 2018-11-19 if not approved yet.

I've gotten pretty close to what I want with this code:

(defface mjh-subdued `((t :background ,mjh-base03 :foreground ,mjh-base02))
    "Subdued face for text that shouldn't be very visible.")
(font-lock-add-keywords
   'org-mode
   '(
     ("\\(State +\"\\)\\(TODO\\)\\(\" +from.*\\)$"     (1 'mjh-subdued) (2 'mjh-subdued)  (3 'mjh-subdued))
     ("\\(State +\"\\)\\(NEXT\\)\\(\" +from.*\\)$"     (1 'mjh-subdued) (2 'mjh-subdued)  (3 'mjh-subdued))
     ("\\(State +\"\\)\\(WAITING\\)\\(\" +from.*\\)$"  (1 'mjh-subdued) (2 'mjh-waiting)  (3 'mjh-subdued))
     ("\\(State +\"\\)\\(DONE\\)\\(\" +from.*\\)$"     (1 'mjh-subdued) (2 'mjh-subdued)  (3 'mjh-subdued))
     ("\\(State +\"\\)\\(CANCELED\\)\\(\" +from.*\\)$" (1 'mjh-subdued) (2 'mjh-canceled) (3 'mjh-subdued))
 ))

With this, the text isn't invisible, but it is subdued so it doesn't draw much attention. Ideally, I want the text that is currently formatted as mjh-subdued to be invisible (and zero-width).

But I'm stuck. I can't figure out how to add the 'invisible text property to the matched groups. According to search based fontification, I should be able to add text properties for the (matcher . facespec) form, but I can't figure out how I need to get it worked. Changing one of the (1 'mjh-subdued) to (1 (face 'mjh-subdued :invisible t)) does not work. (and breaks what I do have working)

Any ideas on where I should look for this? I tried looking through the source for font-lock-add-keywords, but it's pretty dense.

I can add the code for the other faces if it matters, but they just change the TODO keywords to be colored differently.

  • Should that say (1 (face mjh-subdued :invisible t)) rather than font? – rpluim Nov 19 at 10:09
  • @rpluim - yes, thanks. Edited. – diminishedprime Nov 19 at 19:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.