Subject: bug#22399: org-mode fontification

From: Kyle Meyer <[email-masked]>
Date: Wed, 20 Jan 2016 12:18:42 -0500

[email-masked] (Phillip Lord) writes:

> Rasmus <[email-masked]> writes:
>>
>> Kyle Meyer <[email-masked]> writes:
>>
>>>> However, it's easy enough to switch to using an org-font-lock-ensure
>>>> variant that avoids these issues, so I will do that (in an updated
>>>> patch and on Org's maint).
>>>
>>> I've attached updated patches against emacs-25.  If these are applied to
>>> the Emacs repo, I'll backport the new font-lock-ensure alias to Org's
>>> maint.
>>
>> Looks good, thanks.
>
>
> Just checking whether on who is going to apply the patches! They don't
> seem to be on emacs-25 yet.

I have copyright assignment with the FSF (for Org mode contributions),
but I haven't contributed to Emacs directly before.  I'm cc'ing Stefan
because these patches are touching his changes.

I've re-attached the most recent set of patches
(http://permalink.gmane.org/gmane.emacs.bugs/111756).

>From d9a8014e3919c328bf2b6acbe9d9127f3b06b5e1 Mon Sep 17 00:00:00 2001
From: Kyle Meyer <[email-masked]>
Date: Tue, 19 Jan 2016 12:53:04 -0500
Subject: [PATCH 1/2] org-compat: Fix font-lock-ensure alias

* lisp/org/org-compat.el (org-font-lock-ensure): Fix check for
font-lock-ensure.  Make compatibility function's arguments optional to
match with font-lock-ensure's.  (Bug#22399)
---
 lisp/org/org-compat.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index 6403d4d..cf6aafc 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.el
@@ -479,9 +479,9 @@ org-no-popups
       (not (null pos)))))
 
 (defalias 'org-font-lock-ensure
-  (if (fboundp 'org-font-lock-ensure)
+  (if (fboundp 'font-lock-ensure)
       #'font-lock-ensure
-    (lambda (_beg _end) (font-lock-fontify-buffer))))
+    (lambda (&optional _beg _end) (font-lock-fontify-buffer))))
 
 (defun org-floor* (x &optional y)
   "Return a list of the floor of X and the fractional part of X.
-- 
2.7.0

>From 7b2e8cd23ee5326ca2b0845bed8a5d111a2a3b17 Mon Sep 17 00:00:00 2001
From: Kyle Meyer <[email-masked]>
Date: Tue, 19 Jan 2016 12:53:22 -0500
Subject: [PATCH 2/2] org-src: Use font-lock-fontify-buffer for blocks

* lisp/org/org-src.el (org-src-font-lock-fontify-block): Use
font-lock-fontify-buffer because font-lock-ensure does not display
source block fonts.

This corresponds to 003a0f10695f035e844d844eacb1a86a6d2df934 in the Org
repo.
---
 lisp/org/org-src.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el
index 8e06aaa..5548f52 100644
--- a/lisp/org/org-src.el
+++ b/lisp/org/org-src.el
@@ -916,7 +916,9 @@ org-src-font-lock-fontify-block
 	    (delete-region (point-min) (point-max))
 	    (insert string " ") ;; so there's a final property change
 	    (unless (eq major-mode lang-mode) (funcall lang-mode))
-            (org-font-lock-ensure)
+	    ;; Avoid `font-lock-ensure', which does not display fonts in
+	    ;; source block.
+	    (font-lock-fontify-buffer)
 	    (setq pos (point-min))
 	    (while (setq next (next-single-property-change pos 'face))
 	      (put-text-property
-- 
2.7.0

--
Kyle