From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= Subject: Re: Two small org-src patches Date: Sun, 7 Aug 2016 15:22:07 -0400 Message-ID: <4e9720cb-58b7-cf0f-2199-c6f0e877ab70@gmail.com> References: <4355b0e5-1641-d01a-9c2f-9497f7cf48a0@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="A9LuVWHUauS7IKR7PDWUcqDLo6nbhs3Qj" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWTeN-0003xU-Gx for emacs-orgmode@gnu.org; Sun, 07 Aug 2016 15:22:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWTeK-0001P0-9D for emacs-orgmode@gnu.org; Sun, 07 Aug 2016 15:22:19 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:58408) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWTeJ-0001Oh-UO for emacs-orgmode@gnu.org; Sun, 07 Aug 2016 15:22:16 -0400 Received: from [18.189.62.146] ([18.189.62.146]) by mrelayeu.kundenserver.de (mreue004) with ESMTPSA (Nemesis) id 0MLTGA-1bVvPw3mks-000fI2 for ; Sun, 07 Aug 2016 21:22:15 +0200 In-Reply-To: <4355b0e5-1641-d01a-9c2f-9497f7cf48a0@gmail.com> 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) --A9LuVWHUauS7IKR7PDWUcqDLo6nbhs3Qj Content-Type: multipart/mixed; boundary="o9O20s3phN8S0MlRDkTuper6RmQmvM85P" From: =?UTF-8?Q?Cl=c3=a9ment_Pit--Claudel?= To: emacs-orgmode@gnu.org Message-ID: <4e9720cb-58b7-cf0f-2199-c6f0e877ab70@gmail.com> Subject: Re: [O] Two small org-src patches References: <4355b0e5-1641-d01a-9c2f-9497f7cf48a0@gmail.com> In-Reply-To: <4355b0e5-1641-d01a-9c2f-9497f7cf48a0@gmail.com> --o9O20s3phN8S0MlRDkTuper6RmQmvM85P Content-Type: multipart/mixed; boundary="------------44C782E88151038DD4BB3077" This is a multi-part message in MIME format. --------------44C782E88151038DD4BB3077 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable In 2016-08-07 15:16, Cl=C3=A9ment Pit--Claudel wrote: > The two attached patches add this feature. There was a small mistake in the first patch; I have reattached both of t= hem. --------------44C782E88151038DD4BB3077 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 41263e53a58fe43a123e00b5ee2ce459f1b1274e 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..5906721 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 (facep 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 --------------44C782E88151038DD4BB3077 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 f764ad7379a98ea31b9e492dfa5bd447a2135314 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 5906721..04f5f62 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 --------------44C782E88151038DD4BB3077-- --o9O20s3phN8S0MlRDkTuper6RmQmvM85P-- --A9LuVWHUauS7IKR7PDWUcqDLo6nbhs3Qj 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 iQIcBAEBCAAGBQJXp4pgAAoJEPqg+cTm90wj5BYQAKPApWw0GBhIs6QlvRlhXZ5i 9Qd3AiH3sAVQfRHxITs+zoqLAGhV3NleOjFryvyps97gztQ0pb3wJ6H1PvtZyc+K opjL06QEgLu130BzjQhdEyHi1OWFA8Q8Diei6KtlUkfOFnKqG+WVtaD3bubQswJp 6Sw73LDb1ksPYKqeHw784Ui4Ou3uTbfPR24wdPjjmmeYiD5jVaJLAzc6DkKn+SMs ipuQ5uyAMBIi46z+hBnFBqm9nI6fy6kenmM4008qeqKTSABVfIWf3bEJ4WVIgEZV gmx1OaN0Tgwkei+2v9l+DRl08Q4oqYObaqhnUoP/TicSUwGHPBr5un9RXgrpThKD yXpWLkqEt60drNxb3gOIJEpgSgtx+qu+/mX3fRtAyFvlZDyaS17QgG4E9Y1V5Tfg 1Yw9snzMoWG7q/7BgwxcMCYd/zMUgg8P+kJ4FodCDzxsSI6zzMvnYOztA85ZvuR7 oGxjPffomQgCm1sZjJpnjqpc0wbPKmMDfyGLBpTnYBr+bU33dGsqCHKtnt8RJzVA lwu0HK8IHcYkI+R8hlvfmmAmA43vR5amV4nZDSGq9/Wqn5piS+5LI9SC257FqNLA Sdwn7/hf4kKbMnJb5GfGPE7rl+7Bf4eevqLXHP3H7E8REdrbzHSvvWjqW9lkZWdf Rc/eLZsiuo89YS6RP10Z =/9uJ -----END PGP SIGNATURE----- --A9LuVWHUauS7IKR7PDWUcqDLo6nbhs3Qj--