From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Subject: Two small org-src patches Date: Sun, 7 Aug 2016 15:16:05 -0400 Message-ID: <4355b0e5-1641-d01a-9c2f-9497f7cf48a0@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dORUsDci3NiNIA7WFficXvEeLDbH9HHXA" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWTYY-0001Me-JN for emacs-orgmode@gnu.org; Sun, 07 Aug 2016 15:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWTYV-0000f4-Cw for emacs-orgmode@gnu.org; Sun, 07 Aug 2016 15:16:18 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:58625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWTYU-0000er-UT for emacs-orgmode@gnu.org; Sun, 07 Aug 2016 15:16:15 -0400 Received: from [18.189.62.146] ([18.189.62.146]) by mrelayeu.kundenserver.de (mreue104) with ESMTPSA (Nemesis) id 0MPGgy-1batOn0hl2-004OwO for ; Sun, 07 Aug 2016 21:16:13 +0200 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" To: emacs-orgmode@gnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --dORUsDci3NiNIA7WFficXvEeLDbH9HHXA Content-Type: multipart/mixed; boundary="1KeeLM0CTXP0GawBqXGmKlSBm2VsHLmCM" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: emacs-orgmode@gnu.org Message-ID: <4355b0e5-1641-d01a-9c2f-9497f7cf48a0@gmail.com> Subject: Two small org-src patches --1KeeLM0CTXP0GawBqXGmKlSBm2VsHLmCM Content-Type: multipart/mixed; boundary="------------E75499A3C446DE98E8E8C317" This is a multi-part message in MIME format. --------------E75499A3C446DE98E8E8C317 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi emacs-orgmode, I use prettify-symbols-mode heavily, and prettification isn't currently c= opied by org-src's native fontification. The two attached patches add thi= s feature. You can test them by enabling global-prettify-symbols-mode and= creating an emacs-lisp code block in org-mode. I already have FSF papers= on file. The first one is not strictly necessary, but it makes the second one easi= er to write, and it fixes (what I think is) a bug in the current implemen= tation (if the 'face in the fontified buffer is already a list, say '(a b= ), then org-src will construct an invalid face '(:inherit (a b) org-block= )) instead of (:inherit (a b org-block))=E2=80=94which could really just = be (a b org-block), as done by patch 1).=20 Cheers, Cl=C3=A9ment. --------------E75499A3C446DE98E8E8C317 Content-Type: text/x-diff; name="0001-Use-font-lock-append-text-property-to-apply-org-src-.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Use-font-lock-append-text-property-to-apply-org-src-.pa"; filename*1="tch" =46rom 1ee0c94dba1519d7a32161a826421b455cea75b8 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Cl=3DC3=3DA9ment=3D20Pit--Claudel?=3D Date: Sun, 7 Aug 2016 14:59:05 -0400 Subject: [PATCH 1/2] Use font-lock-append-text-property to apply org-src = faces * lisp/org-src.el (org-src-font-lock-fontify-block): Replace anonymous faces with inheritance by lists of faces constructed by `font-lock-add-text-property`. This properly deals with cases when the source buffer's `face' property is already a list. --- lisp/org-src.el | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index 892c52e..9392e58 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -492,10 +492,7 @@ as `org-src-fontify-natively' is non-nil." (when (fboundp lang-mode) (let ((string (buffer-substring-no-properties start end)) (modified (buffer-modified-p)) - (org-buffer (current-buffer)) - (block-faces (let ((face-name (intern (format "org-block-%s" lang))= )) - (append (and (facep face-name) (list face-name)) - '(org-block))))) + (org-buffer (current-buffer))) (remove-text-properties start end '(face nil)) (with-current-buffer (get-buffer-create @@ -509,14 +506,14 @@ as `org-src-fontify-natively' is non-nil." (while (setq next (next-single-property-change pos 'face)) (let ((new-face (get-text-property pos 'face))) (put-text-property - (+ start (1- pos)) (1- (+ start next)) 'face - (list :inherit (append (and new-face (list new-face)) - block-faces)) + (+ start (1- pos)) (1- (+ start next)) 'face new-face org-buffer)) - (setq pos next)) - ;; Add the face to the remaining part of the text. - (put-text-property (1- (+ start pos)) end 'face - (list :inherit block-faces) org-buffer))) + (setq pos next)))) + ;; Add org faces + (let ((face-name (intern (format "org-block-%s" lang)))) + (when face-name + (font-lock-append-text-property start end 'face face-name)) + (font-lock-append-text-property start end 'face 'org-block)) (add-text-properties start end '(font-lock-fontified t fontified t font-lock-multiline t)) --=20 2.7.4 --------------E75499A3C446DE98E8E8C317 Content-Type: text/x-diff; name="0002-Copy-all-font-lock-properties-in-org-src-not-just-fa.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0002-Copy-all-font-lock-properties-in-org-src-not-just-fa.pa"; filename*1="tch" =46rom 6a586ffca728f78d9a0dbb5b27eb3388e5fdd49f Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Cl=3DC3=3DA9ment=3D20Pit--Claudel?=3D Date: Sun, 7 Aug 2016 15:03:55 -0400 Subject: [PATCH 2/2] Copy all font-lock properties in org-src, not just f= ace * lisp/org-src (org-src-font-lock-fontify-block): Loop over `font-lock-extra-managed-props', thus copying other properties that might be applied using font-lock. An example is composition, applied by `prettify-symbols-mode'. --- lisp/org-src.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index 9392e58..33eee4b 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -503,11 +503,12 @@ as `org-src-fontify-natively' is non-nil." (unless (eq major-mode lang-mode) (funcall lang-mode)) (org-font-lock-ensure) (let ((pos (point-min)) next) - (while (setq next (next-single-property-change pos 'face)) - (let ((new-face (get-text-property pos 'face))) - (put-text-property - (+ start (1- pos)) (1- (+ start next)) 'face new-face - org-buffer)) + (while (setq next (next-property-change pos)) + (dolist (prop (cons 'face font-lock-extra-managed-props)) + (let ((new-prop (get-text-property pos prop))) + (put-text-property + (+ start (1- pos)) (1- (+ start next)) prop new-prop + org-buffer))) (setq pos next)))) ;; Add org faces (let ((face-name (intern (format "org-block-%s" lang)))) --=20 2.7.4 --------------E75499A3C446DE98E8E8C317-- --1KeeLM0CTXP0GawBqXGmKlSBm2VsHLmCM-- --dORUsDci3NiNIA7WFficXvEeLDbH9HHXA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXp4j1AAoJEPqg+cTm90wjy+AP/jspZ+fF8SLCFKqTr1kT8LDX 0XNlb6+29Ofy7FgaJkOYO8xRV4+NY8c1MMqqoRLg/xlSwVPoZ7o/xiZ9lpnHYIRU TjNah5PtCSd2UZeLJBh/cy21KPNbjpRAbD6sKXtZeA16RH4ih1csrtsD1Lxb2DZd XnysdIwV14ZPCeEpIptXTNun3wG6b010tewHIzl7Gy6cn0YRdKqrUt2mbRRBQ1lR zznDsEKaAOiiu0jBTYufcQUohuD/2EgykXpc5RYPdLhGE4RkzJheUQHUeUhgSDVU Udul8H3pLVfygibyG1S5ont8hBR/UJbqxbK0KHMDkeewSrjYaZ+h2VGzxrrhKC6q TM1ZN4D30+LVauUCao5cCkeRRPindQRjOzhktfEo+VRnvxqxyYGm3CBPoAnfPgiu oflW+Jh583fUxt65oDEX16vxICKzAj7M5Xh1oVwV48/SqrHQk7ZTDgibxLlT2MJh TLkD1HOZfrNX9BaBYsNWSB/g7DkUgU2h4d4AtpvjRqhRdo/RSPAV8ULQOX8v49ck /+0X+oRTcBkmowGvu0HC3DU5wtzAXrQkPB/GeXIGuqUgTzckNxF1EnwLKCO2iY1S SyHnrQ3P/kQAXQjMGjQtWK9ggR1HoPYDyvOmN5XjVMkDJXMsD48a43Ch5lN8u0GO YZmd0LrsgyLsTlJSXySq =xUNL -----END PGP SIGNATURE----- --dORUsDci3NiNIA7WFficXvEeLDbH9HHXA--