emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: phillip.lord@russet.org.uk
Cc: 22399@debbugs.gnu.org, Org Mode <emacs-orgmode@gnu.org>
Subject: Re: bug#22399: org-mode fontification
Date: Tue, 19 Jan 2016 01:32:49 -0500	[thread overview]
Message-ID: <8737tu13la.fsf@kyleam.com> (raw)
In-Reply-To: <87d1syvgc7.fsf@kyleam.com> (Kyle Meyer's message of "Mon, 18 Jan 2016 14:27:04 -0500")

[-- Attachment #1: Type: text/plain, Size: 1214 bytes --]

Kyle Meyer <kyle@kyleam.com> writes:
> Rasmus <rasmus@gmx.us> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-compat-Use-different-font-lock-ensure-alias.patch --]
[-- Type: text/x-diff, Size: 4525 bytes --]

From 6072152a45bcdebbadbe7ec8f7589fce4bc341f2 Mon Sep 17 00:00:00 2001
From: Kyle Meyer <kyle@kyleam.com>
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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-org-src-Use-font-lock-fontify-buffer-for-blocks.patch --]
[-- Type: text/x-diff, Size: 1164 bytes --]

From 212c3131def8d765e7ae4698f931530033cb9144 Mon Sep 17 00:00:00 2001
From: Kyle Meyer <kyle@kyleam.com>
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


[-- Attachment #4: Type: text/plain, Size: 9 bytes --]


--
Kyle

  reply	other threads:[~2016-01-19  6:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87oacjng36.fsf@russet.org.uk>
     [not found] ` <87ziw36khb.fsf@gmx.us>
2016-01-18 18:05   ` bug#22399: org-mode fontification Phillip Lord
     [not found]   ` <87a8o2zrtm.fsf@russet.org.uk>
2016-01-18 18:48     ` Rasmus
2016-01-18 19:27       ` Kyle Meyer
2016-01-19  6:32         ` Kyle Meyer [this message]
2016-01-19 11:25           ` Phillip Lord
2016-01-19  6:32         ` Kyle Meyer
2016-01-19  6:32         ` Kyle Meyer
2016-01-19  8:51           ` Rasmus
2016-01-19 15:33             ` Kyle Meyer
2016-01-19 18:04               ` Kyle Meyer
2016-01-19 19:05               ` Rasmus
2016-01-20 11:39                 ` Phillip Lord
     [not found]                 ` <874me8pjii.fsf__7050.42196573249$1453290031$gmane$org@russet.org.uk>
2016-01-20 17:18                   ` Kyle Meyer
     [not found]                   ` <87ziw0goel.fsf_-_@kyleam.com>
2016-01-20 22:02                     ` Stefan Monnier
     [not found]                     ` <jwvtwm7kj32.fsf-monnier+emacsbugs@gnu.org>
2016-01-21  0:44                       ` Kyle Meyer
2016-01-25 14:30                         ` Stefan Monnier
     [not found]                         ` <jwvio2hycfw.fsf-monnier+emacsbugs@gnu.org>
2016-01-26  6:58                           ` Kyle Meyer
     [not found]                           ` <87lh7cu8r0.fsf@kyleam.com>
2016-01-26 13:06                             ` Stefan Monnier
     [not found]                             ` <jwvmvrsv6ci.fsf-monnier+emacsbugs@gnu.org>
2016-01-26 15:27                               ` Kyle Meyer
     [not found]                               ` <87a8nstl75.fsf@kyleam.com>
2016-02-01 13:50                                 ` Stefan Monnier
     [not found]                                 ` <jwvpowgmthh.fsf-monnier+emacsbugs@gnu.org>
2016-02-03  6:38                                   ` Bastien Guerry
     [not found]                                   ` <87si1auwlx.fsf@free.fr>
2016-02-03  6:51                                     ` Kyle Meyer
     [not found]                                     ` <8760y6wak7.fsf@kyleam.com>
2016-02-03  6:55                                       ` Bastien Guerry
     [not found]                                       ` <87bn7yuvt5.fsf@gnu.org>
2016-02-11 18:18                                         ` Phillip Lord

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8737tu13la.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=22399@debbugs.gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=phillip.lord@russet.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).