I'd like to create a way to toggle showing/hiding/changing text following a pattern in org-mode, but if it works generally, that's fine also.
A few examples of where this might be useful.
#+TITLE:and just leaving the actual title text in a larger font, or if there is no title text specified after the space, showing instead the text
Insert Title Here:____. (the latter is an example of changing the text).
#OPTIONS:.*completely (would use other font changes to indicate heading).
- Removing all headline
*'s (simply having headlines in larger fonts), etc.
- Highlighting text with a special character (e.g.
@foo@to highlight "foo").
Obviously, the underlying goal is to make a very clean org-mode environment for writing, but which you can easily toggle on and off to update the "metadata" and formatting info (perhaps just temporarily by entering
shift-select-mode, but that's for another day!).
Based off of this answer: How to make my own org-mode text emphasis work again?, I am able to do some of this, but there isn't a clear way to toggle this on and off within a session without at least reloading org-mode (which loses lots of editor state). E.g.:
(defun org-add-my-extra-fonts () (add-to-list 'org-font-lock-extra-keywords '("[^@\\w]\\(@\\)\\([^@\n\r\t]+\\)\\(@\\)[^@\\w]" (1 '(face irrelevant-face invisible t)) (2 'my-highlight-face t) (3 '(face irrelevant-face invisible t))) t)) (add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-fonts)
So how can you bind this sort of behavior to a minor-mode in a way that plays nice with org? (assuming it's possible)
EDIT: I am not asking for how to do any of these individual things. I'm giving examples of where it is useful. I am asking for how to do the general thing of creating invisible/modified text in a way that can be toggled on and off. The ways I know how do this, as shown above, cannot be toggled. I provided the code above as a starting point, since that was where I got stuck (it doesn't appear toggle-able), and it might useful for those trying to help.
It's possible that
org-font-lock-set-keywords-hook can somehow be toggled within a session without reloading org or other side effects, and would address all of these scenarios, in which case, showing how to do that would be a great answer!