emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Bug: Add option to fontify latex blocks [9.1.9 (release_9.1.9-65


From: Carlos Pita
Subject: Re: [O] Bug: Add option to fontify latex blocks [9.1.9 (release_9.1.9-65-g5e4542 @ /home/carlos/local/stow/emacs-26/share/emacs/26.1.50/lisp/org/)]
Date: Wed, 28 Nov 2018 13:55:10 -0300

> all fontification is lost for the entire environment and never reapplied

The problem is with the limit argument passed by the font locking
framework to org-do-latex-and-related .

Once you natively fontified the environment this limit arg became non
nil and it's in general not enough to match the entire latex
environment. I assume this is because of the way native fontification
annotates the code which makes the framework think it would be enough
to look up to some limit. But this is not true anymore when you have
this hybrid syntax that forces to refontify the entire fragment in a
temporary buffer.

So in order to get native fontification working for inline latex you need to:

1. Ignore the limit argument.
2. Replace the calls to font-lock-prepend-text-property and
add-text-properties by a single call to
org-src-font-lock-fontify-block
3. Also this makes most sense if org-highlight-latex-and-related is
set to '(latex).

Maybe an option could be added that did something like 1, 2 and 3
above, in case the user prefers native fontification for inline latex.

In any case, here is an advice that will do the trick:

(advice-add 'org-do-latex-and-related
            :around (lambda (f limit)
                      (cl-letf
                          (((symbol-function 'font-lock-prepend-text-property)
                            (lambda (start end &rest args)
                              (org-src-font-lock-fontify-block "latex"
start end))))
                        (funcall f nil))))

Regards
---
Carlos



reply via email to

[Prev in Thread] Current Thread [Next in Thread]