GNU bug report logs - #22399
org-mode fontification

Previous Next

Packages: emacs, org-mode;

Reported by: phillip.lord <at> russet.org.uk (Phillip Lord)

Date: Mon, 18 Jan 2016 14:00:02 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Kyle Meyer <kyle <at> kyleam.com>
Cc: 22399 <at> debbugs.gnu.org, Rasmus <rasmus <at> gmx.us>, Phillip Lord <phillip.lord <at> russet.org.uk>
Subject: bug#22399: org-mode fontification
Date: Mon, 25 Jan 2016 09:30:37 -0500
> Sure.  With
>
> --8<---------------cut here---------------start------------->8---
>
> #+BEGIN_SRC elisp
>   (require 'cl-lib)
>   (message "test")
> #+END_SRC
> --8<---------------cut here---------------end--------------->8---
>
> in /tmp/scratch.org, run
>
>   emacs -Q --eval "(setq org-src-fontify-natively t)" --visit /tmp/scratch.org
>
> Go to the code block and hit C-c ' (org-edit-special), and then exit
> with another C-c '.  Without this change, the source block is no longer
> highlighted as elisp code when I return to the buffer.

I see the problem.  org-src-font-lock-fontify-block is using buffers
named " org-src-fontification:<major-mode>" in an unusual way:
they're updated via normal buffer modifications, but they're not put in
font-lock-mode, so all the font-lock machinery which tries to keep the
fontification up-to-date is short-circuited, so it triggers a bug in
font-lock-ensure where we made incorrect assumptions.

I installed the patch below into emacs-25, which should fix this
problem,


        Stefan


--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1074,7 +1074,13 @@ font-lock-flush
 
 (defvar font-lock-ensure-function
   (lambda (_beg _end)
-    (unless font-lock-fontified (font-lock-default-fontify-buffer)))
+    (unless font-lock-fontified
+      (font-lock-default-fontify-buffer)
+      (unless font-lock-mode
+        ;; If font-lock is not enabled, we don't have the hooks in place to
+        ;; track modifications, so a subsequent call to font-lock-ensure can't
+        ;; assume that the fontification is still valid.
+        (setq font-lock-fontified nil))))
   "Function to make sure a region has been fontified.
 Called with two arguments BEG and END.")
 




This bug report was last modified 9 years and 158 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.