This might be interersting: For quite some time I used the code block below in my custom.el to make my own emphasis definitions. This worked up to org 9, I think. Then all of a sudden when I needed it again it stopped working. I found out that it had nothing to do with my config. So I filed a bug report. Then Nicolas Goaziou told me that it even if it worked in the past it is not supported meaning they won't fix it. He gave me the advice below, but without any knowlege of coding and lisp that ain't helping. What I need is quite simple. I want to define a character before and after a word or line and the defined face should be applied.Like: %Exampletext Bla Bla% Based on my codeblock this should turn into "org-habit-alert-face" which is more or less yellow. The % character should be invisible when set. Like ** for bold. So can anyone with knowlege of lisp help me out here?

My custom-set-variables block that worked before:

     ("!" org-habit-overdue-face)
     ("%" org-habit-alert-face)
     ("*" bold)
     ("/" italic)
     ("_" underline)
     ("=" org-verbatim verbatim)
     ("~" org-code verbatim)
     ("+" (:strike-through t))

Advice by Nicolas Goaziou:

You may want to tweak font-lock related variables, e.g., `org-font-lock-hook' to achieve that effect.

  • It still works in org-mode 9.0.5. It is very strange that they don't support it since it exists as customization in the original source file org.el of orgmode 9.0.5. – Tobias Sep 20 '17 at 5:15
  • Oh, it is already too late to edit my former comment. I wanted to be more specific about what works in org-mode 9.0.5: For testing I did just customize org-emphasis-alist. I did not fiddle around directly with custom-set-variables. – Tobias Sep 20 '17 at 5:25
  • Not so strange. Check out my case at http://lists.gnu.org/archive/html/emacs-orgmode/2017-09/msg00455.html He said that it is intended to change the existing emphasis, not to add new. Well I can't say for sure when it broke exactly. I think 9.1 broke it, it is definitivly broken in 9.1.1. That's what you get when you keep up with the bleeding edge. – Jens Lange Sep 20 '17 at 10:12
  • I nearly don't use customize at all, but this was the only one to make it work in the past without reloading org-mode. The org-emphasis-alist variable requires to reload org to make changes work. Using the customize system allowed it to to avoid that. I assume the customize variables are loaded before org mode is initialized. – Jens Lange Sep 20 '17 at 10:20
  • If they don't want items added to org-emphasis-alist they shouldn't use the repeat customization type which allows insertion and deletion. Furthermore, they should add a note about this restriction in the doc string of org-emphasis-alist. Maybe, you can give a follow-up in the bug-report about that. Nevertheless, I don't move a bit from my statement that it is very strange that this option does not work as sanely expected. It would be easy to construct a regexp for the parser from that list and work with that in the library. One shouldn't annoy ones users! – Tobias Sep 20 '17 at 10:24

I don't really have org-mode 9.1.1 installed. In org-mode 9.0.5 the following works:

(require 'org-habit nil t)

(defun org-add-my-extra-fonts ()
  "Add alert and overdue fonts."
  (add-to-list 'org-font-lock-extra-keywords '("\\(!\\)\\([^\n\r\t]+\\)\\(!\\)" (1 '(face org-habit-alert-face invisible t)) (2 'org-habit-alert-face) (3 '(face org-habit-alert-face invisible t))))
  (add-to-list 'org-font-lock-extra-keywords '("\\(%\\)\\([^\n\r\t]+\\)\\(%\\)" (1 '(face org-habit-overdue-face invisible t)) (2 'org-habit-overdue-face) (3 '(face org-habit-overdue-face invisible t)))))

(add-hook 'org-font-lock-set-keywords-hook #'org-add-my-extra-fonts)
  • That worked, thanks. I'll add your remarks above to the case, maybe they change their mind about that. I really would like to see the old functionality to come back. As a non programmer I like to avoid any extra functions that I have to maintain myself. – Jens Lange Sep 20 '17 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.