From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kyle Meyer Subject: Re: bug#22399: org-mode fontification Date: Tue, 19 Jan 2016 01:32:49 -0500 Message-ID: <8737tu13la.fsf__45919.81909839$1453185231$gmane$org@kyleam.com> References: <87oacjng36.fsf@russet.org.uk> <87ziw36khb.fsf@gmx.us> <87a8o2zrtm.fsf@russet.org.uk> <87bn8i7mha.fsf@gmx.us> <87d1syvgc7.fsf@kyleam.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39137) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLPqc-00044d-9B for emacs-orgmode@gnu.org; Tue, 19 Jan 2016 01:32:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLPqZ-0004ah-0D for emacs-orgmode@gnu.org; Tue, 19 Jan 2016 01:32:58 -0500 Received: from pb-smtp0.int.icgroup.com ([208.72.237.35]:53516 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLPqY-0004aa-RQ for emacs-orgmode@gnu.org; Tue, 19 Jan 2016 01:32:54 -0500 In-Reply-To: <87d1syvgc7.fsf@kyleam.com> (Kyle Meyer's message of "Mon, 18 Jan 2016 14:27:04 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: phillip.lord@russet.org.uk Cc: 22399@debbugs.gnu.org, Org Mode --=-=-= Content-Type: text/plain Kyle Meyer writes: > Rasmus writes: > > [...] > >> Note, this change only lives it the Emacs version of Org. It was added in >> this commit: >> >> 6711a21f1125c0047c56eb266eb374c1ec90a967 [...] > > This commit was backported in Org commit d81e6b5, and then followed up > by c115c7b (org-compat: Use different font-lock-ensure alias, > 2015-07-26), which defined the alias as > > (unless (fboundp 'font-lock-ensure) > (defalias 'font-lock-ensure 'font-lock-fontify-buffer)) I've attached two patches against emacs-25 that would get the Org and Emacs repos in similar states wrt font-lock-ensure. The first patch replaces the font-lock-ensure compatibility alias from 6711a21f1 with the one currently used in the Org repo (from commit e6883dd03). The new alias is limited to being called with no arguments, but, at the moment, no Org code calls font-lock-ensure with any arguments. The second patch reverts a part of 6711a21f1 that modified org-src-font-lock-fontify-block to use font-lock-ensure rather than font-lock-fontify-buffer. In this particular case, using font-lock-ensure instead of font-lock-fontify-buffer fails to highlight the source block. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org-compat-Use-different-font-lock-ensure-alias.patch >From 6072152a45bcdebbadbe7ec8f7589fce4bc341f2 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 26 Jul 2015 23:29:14 -0400 Subject: [PATCH 1/2] org-compat: Use different font-lock-ensure alias * lisp/org/org-compat.el (org-font-lock-ensure): Remove in favor of font-lock-ensure alias from Org's e6883dd. (Bug#22399) * lisp/org/org-clock.el (org-clock-get-clocktable): * lisp/org/org-src.el (org-src-font-lock-fontify-block): * lisp/org/org.el (org-fontify-like-in-org-mode): * lisp/org/ox-html.el (org-html-fontify-code): * lisp/org/ox-odt.el (org-odt-do-format-code): * lisp/org/ox-org.el (org-org-publish-to-org): Use new alias. Instead of org-font-lock-ensure alias introduced in 6711a21, use font-lock-ensure alias added in Org's e6883dd ("org-compat: Provide compatibility definition for font-lock-ensure", 2014-06-01). This corresponds to c115c7b4e86b68fe4f903636252a8b22b46a044f in the Org repo. --- lisp/org/org-clock.el | 2 +- lisp/org/org-compat.el | 7 +++---- lisp/org/org-src.el | 2 +- lisp/org/org.el | 2 +- lisp/org/ox-html.el | 2 +- lisp/org/ox-odt.el | 2 +- lisp/org/ox-org.el | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el index 9374f5f..217e97e 100644 --- a/lisp/org/org-clock.el +++ b/lisp/org/org-clock.el @@ -1931,7 +1931,7 @@ org-clock-get-clocktable (org-mode) (org-create-dblock props) (org-update-dblock) - (org-font-lock-ensure) + (font-lock-ensure) (forward-line 2) (buffer-substring (point) (progn (re-search-forward "^[ \t]*#\\+END" nil t) diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el index 6403d4d..863197b 100644 --- a/lisp/org/org-compat.el +++ b/lisp/org/org-compat.el @@ -478,10 +478,9 @@ org-no-popups (looking-at (concat "\\(?:" regexp "\\)\\'"))))) (not (null pos))))) -(defalias 'org-font-lock-ensure - (if (fboundp 'org-font-lock-ensure) - #'font-lock-ensure - (lambda (_beg _end) (font-lock-fontify-buffer)))) +;; `font-lock-ensure' is only available from 24.4.50 on +(unless (fboundp 'font-lock-ensure) + (defalias 'font-lock-ensure 'font-lock-fontify-buffer)) (defun org-floor* (x &optional y) "Return a list of the floor of X and the fractional part of X. diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el index 8e06aaa..1bcc202 100644 --- a/lisp/org/org-src.el +++ b/lisp/org/org-src.el @@ -916,7 +916,7 @@ 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) + (font-lock-ensure) (setq pos (point-min)) (while (setq next (next-single-property-change pos 'face)) (put-text-property diff --git a/lisp/org/org.el b/lisp/org/org.el index 960b874..bb3a89e 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -6375,7 +6375,7 @@ org-fontify-like-in-org-mode (insert s) (let ((org-odd-levels-only odd-levels)) (org-mode) - (org-font-lock-ensure) + (font-lock-ensure) (buffer-string)))) (defvar org-m nil) diff --git a/lisp/org/ox-html.el b/lisp/org/ox-html.el index 1ca360c..b229423 100644 --- a/lisp/org/ox-html.el +++ b/lisp/org/ox-html.el @@ -1855,7 +1855,7 @@ org-html-fontify-code (funcall lang-mode) (insert code) ;; Fontify buffer. - (org-font-lock-ensure) + (font-lock-ensure) ;; Remove formatting on newline characters. (save-excursion (let ((beg (point-min)) diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el index f2b0c91..4f9760d 100644 --- a/lisp/org/ox-odt.el +++ b/lisp/org/ox-odt.el @@ -3140,7 +3140,7 @@ org-odt-do-format-code (with-temp-buffer (insert code) (funcall lang-mode) - (org-font-lock-ensure) + (font-lock-ensure) (buffer-string)))) (fontifier (if use-htmlfontify-p 'org-odt-htmlfontify-string 'org-odt--encode-plain-text)) diff --git a/lisp/org/ox-org.el b/lisp/org/ox-org.el index 6221c70..bc4eff9 100644 --- a/lisp/org/ox-org.el +++ b/lisp/org/ox-org.el @@ -254,7 +254,7 @@ org-org-publish-to-org (work-buffer (or visitingp (find-file-noselect filename))) newbuf) (with-current-buffer work-buffer - (org-font-lock-ensure) + (font-lock-ensure) (show-all) (org-show-block-all) (setq newbuf (htmlize-buffer))) -- 2.7.0 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-org-src-Use-font-lock-fontify-buffer-for-blocks.patch >From 212c3131def8d765e7ae4698f931530033cb9144 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 4 Aug 2015 23:50:59 -0400 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 1bcc202..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)) - (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 --=-=-= Content-Type: text/plain -- Kyle --=-=-=--