From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WLThNPQppWFmcAAAgWs5BA (envelope-from ) for ; Mon, 29 Nov 2021 20:28:52 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id ONJqMPQppWGgTQAAbx9fmQ (envelope-from ) for ; Mon, 29 Nov 2021 19:28:52 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 652CDFD85 for ; Mon, 29 Nov 2021 20:28:52 +0100 (CET) Received: from localhost ([::1]:50238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mrmKZ-0000Jt-DE for larch@yhetil.org; Mon, 29 Nov 2021 14:28:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mrmIA-0000Gu-2u for emacs-orgmode@gnu.org; Mon, 29 Nov 2021 14:26:22 -0500 Received: from [2607:f8b0:4864:20::629] (port=42747 helo=mail-pl1-x629.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mrmI7-0002bt-NJ for emacs-orgmode@gnu.org; Mon, 29 Nov 2021 14:26:21 -0500 Received: by mail-pl1-x629.google.com with SMTP id u17so12984556plg.9 for ; Mon, 29 Nov 2021 11:26:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:references:user-agent:in-reply-to :message-id:mime-version; bh=+mYPCn7Mkq1aZXLy3rKLR1IRgWQTpW6/CNY8hqZx9SM=; b=ZRm/XW2R10g5yDD7Hq8UgHrKArZMGztlQpkg2POgQ4lD9jq+OwGsHygykuRbforwRL APC5bWegVYZtv85iXNCqjdeKZE+GBtj9KEVK3q3tJHy2UsKwFG3APBp/LUUxhzkp7v7s BtKuMeKGvgiGeRv3i0/xKB70qf9sso4atyOD/WQBj8+8licEDV+saKzedOgkBi3d2Gd9 zg2ebTtlxVGXzXep0wciJDEKSBhs1S1biy4gju55dZQcwgSMmvFUj+D+WfN7cY3UG6dN C6qXjskCY0Rksbo69FAuoGT3yULoMKIJWqpgVTRXD/bTv6xwYh8bqdecQlLBpdLZy4ou cgzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:references:user-agent :in-reply-to:message-id:mime-version; bh=+mYPCn7Mkq1aZXLy3rKLR1IRgWQTpW6/CNY8hqZx9SM=; b=ZvwkXNEZc5ys/5/KICfEGPysPcdas3Oq/udjFc+faYKDg3tEPMT8Fh0c6vNyipN50p exx/DD5rEgFim7HeNG4bLyedSBwz1olO7IpufriRF3zApO2qqDv8cV0+Q9rdzpQM6T7v cpQ15zK/8uuyNlSwovhDI3A/tf0YD1O9vaGQjdWu1ziVMc8uni4YsnBzsHIWTAxr+4Tu UrlMkn1nAqjKzXJiyMAW1uFRJLBapWy2ouW4V5ctB+lBhEJpwUwGa8fpLnuNxMK4xrIn uF2nkLTeImnMCroCflLlU+Y3A8beEyglpcqE/1q73wNo7dSnZdOelY3NmCll2FEsas+V EMPw== X-Gm-Message-State: AOAM533nUgVrY+8goPk+Q49aSAwR9VVfdGhBcEgclt/Mpxcgg4qzUOSf m/NzcCQecVkRU78HPUXfDnM= X-Google-Smtp-Source: ABdhPJyktkrgIDrUOGQhGVvncBjPeq5qhe83D2MT2KN2m2QbXdIWm2vbD1IaXfJxGJ2VlkG2V4U1hg== X-Received: by 2002:a17:902:ea09:b0:141:ec88:4410 with SMTP id s9-20020a170902ea0900b00141ec884410mr64102846plg.51.1638213978254; Mon, 29 Nov 2021 11:26:18 -0800 (PST) Received: from localhost (61-245-128-160.3df580.per.nbn.aussiebb.net. [61.245.128.160]) by smtp.gmail.com with ESMTPSA id nv17sm114672pjb.55.2021.11.29.11.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 11:26:17 -0800 (PST) From: Timothy To: Ihor Radchenko Subject: Re: [PATCH] Fontification for inline src blocks Date: Tue, 30 Nov 2021 03:21:24 +0800 References: <87pmzf4bd0.fsf@gmail.com> <87o86d7g05.fsf@gmail.com> <875ysk76bo.fsf@gmail.com> <87a6hwpeew.fsf@localhost> <87zgpw5lt9.fsf@gmail.com> <87k0h0b6mv.fsf@localhost> <87y25g5jip.fsf@gmail.com> <87wnkzf186.fsf@localhost> User-agent: mu4e 1.6.9; emacs 28.0.50 In-reply-to: <87wnkzf186.fsf@localhost> Message-ID: <877dcqpxux.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::629 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=tecosaur@gmail.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: org-mode-email Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1638214132; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=laqhNNNq5CVn+v6CtmvNJyQs3m9SPBiTufQWdUq+0vI=; b=gMD+tvjwWxc6GVvsRRBDVswGtS5BFEYbgtYmwZwQxah9KoL6WIa21MviEj9RuwX/peP10L n+jt4mPSSeGOZToiypwUhxWzgpZXa2NBlmZjjTbxcYjIxWzNzc5oCHQqUQbHMZB6MFi7Gb fUWZPLeKfOLfdDeanxDjyLGonXgjsnlC5RCITtsP5oH+6hhJ8fR/GUYn7wtQNtP/s8E/Im uL2svyZV8vb7PnQqCbZWpGQa5KKmNoTAXIYKVLp2LLaXh7Cs61BPdmic9C0TzoOuAaJcMV lO52glwpgFwCldmkqL7QX4eEmhmvo8plfig9vMOxPbrMFYNEwf4hySb/VE27gw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1638214132; a=rsa-sha256; cv=none; b=WyKAt8J2lBEiUmVXIAfSR5ocOR8ztZqv6/Bb3lrmT5AVBxaLJBd3KNQmYoAxc4EhPHmuUq 8ObB6c1N2553mkQXZVVqEg2tEjhAg0c2lq5hPShiBMwlwQlHKMWNocAKPIpI/KoXb7B615 UjjHyQU0hB/qICctCRInSWsIjHkBlNtUQYDxXl8KGUOVNrUiBZxoFocMTyhluEmWIx1wK3 dbIOxCimiM91HC4/ycbcajKZhqONMvmnPTIcnom8wAnfibxdVFEJBRPT7nSC6ieJGPPXkm ZRllmgLAJojyRBfKFRyR9RfBQIytOMj92LrB8F2eNLF2XyafYqCTo6K1wZMWpg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b="ZRm/XW2R"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.81 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b="ZRm/XW2R"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 652CDFD85 X-Spam-Score: -1.81 X-Migadu-Scanner: scn0.migadu.com X-TUID: BHp2Iivixa+h --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Ihor, > That=E2=80=99s an option. Though you should also consider a paragraph end= ing at > EOB. Searching for =E2=80=9C=E2=80=9D will fail with error then. Don=E2=80=99t worry, that=E2=80=99s just a snippet. The full logic is as fo= llows =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 (min limit (or (save-excursion (and (search-forward "\n" limit t = 2) (point))) =E2=94=82 (point-max))) =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 >> [use org-element] Ah right. We now also have the new thread about using org-element. I think = that sounds like a great change overall, but am still keen for this patch to go through for the moment =E2=80=94 just as a stop gap till org-element expose= s all the necessary information and there are some nice examples of using it for fontification. I=E2=80=99ve attached the latest version of the patch. At this point I cons= ider it fairly well-reviewed, so I=E2=80=99ll push it tomorrow if I don=E2=80=99t h= ear of any last-minute issues. All the best, Timothy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-src-Implement-native-inline-src-fontification.patch >From 690718bd2a31f9293572aa7a583a31a0615d18c8 Mon Sep 17 00:00:00 2001 From: TEC Date: Tue, 13 Jul 2021 02:43:29 +0800 Subject: [PATCH] org-src: Implement native inline src fontification * lisp/org-src.el (org-fontify-inline-src-blocks, org-fontify-inline-src-blocks-1): Create a function to search the buffer up to a limit for inline src blocks. Light fontification is applied to matched inline src blocks. When `org-src-fontify-natively' is set, `org-src-font-lock-fontify-block' is applied to the content. * lisp/org.el (org-set-font-lock-defaults): Add `org-fontify-inline-src-blocks' to `org-font-lock-extra-keywords', which is locally bound inside `org-set-font-lock-defaults'. * lisp/org-faces.el: Introduce a new face `org-inline-src-block' which inherits from `org-block' by default. --- lisp/org-faces.el | 4 ++++ lisp/org-src.el | 44 ++++++++++++++++++++++++++++++++++++++++++++ lisp/org.el | 1 + 3 files changed, 49 insertions(+) diff --git a/lisp/org-faces.el b/lisp/org-faces.el index b151045a9..272762789 100644 --- a/lisp/org-faces.el +++ b/lisp/org-faces.el @@ -459,6 +459,10 @@ (defface org-block-end-line '((t (:inherit org-block-begin-line))) "Face used for the line delimiting the end of source blocks." :group 'org-faces) +(defface org-inline-src-block '((t (:inherit org-block))) + "Face used for inline source blocks as a whole." + :group 'org-faces) + (defface org-verbatim '((t (:inherit (fixed-pitch shadow)))) "Face for fixed-with text like code snippets." :group 'org-faces diff --git a/lisp/org-src.el b/lisp/org-src.el index 51dde602d..639a447e8 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -654,6 +654,50 @@ (defun org-src-font-lock-fontify-block (lang start end) '(font-lock-fontified t fontified t font-lock-multiline t)) (set-buffer-modified-p modified))))) +(defun org-fontify-inline-src-blocks (limit) + "Try to apply `org-fontify-inline-src-blocks-1'." + (condition-case nil + (org-fontify-inline-src-blocks-1 limit) + (error (message "Org mode fontification error in %S at %d" + (current-buffer) + (line-number-at-pos))))) + +(defun org-fontify-inline-src-blocks-1 (limit) + "Fontify inline src_LANG blocks, from `point' up to LIMIT." + (let ((case-fold-search t) + (initial-point (point))) + (while (re-search-forward "\\_