From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id MJIhEnKFm2EJIAAAgWs5BA (envelope-from ) for ; Mon, 22 Nov 2021 12:56:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id yKbsDXKFm2G6UAAA1q6Kng (envelope-from ) for ; Mon, 22 Nov 2021 11:56:34 +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 B6DC511BEC for ; Mon, 22 Nov 2021 12:56:29 +0100 (CET) Received: from localhost ([::1]:53778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mp7vw-0007v7-Vm for larch@yhetil.org; Mon, 22 Nov 2021 06:56:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mp7vJ-0007ue-IY for emacs-orgmode@gnu.org; Mon, 22 Nov 2021 06:55:50 -0500 Received: from [2607:f8b0:4864:20::1029] (port=39708 helo=mail-pj1-x1029.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mp7vH-0001ew-Bm for emacs-orgmode@gnu.org; Mon, 22 Nov 2021 06:55:48 -0500 Received: by mail-pj1-x1029.google.com with SMTP id y14-20020a17090a2b4e00b001a5824f4918so16649204pjc.4 for ; Mon, 22 Nov 2021 03:55:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:references:user-agent:in-reply-to:message-id :mime-version; bh=IDgojv3a5kkwuYIJ5GRf6+sd6hunAwDPVHqjM25mC2E=; b=JdkojPg+7xUOU3na5BuPktpYLcfKIvLNMhA04P4E9/ojB8ciWNYVISudXBScjO7Pjy gIisj+EYc/4zy48VfyKTTXVuSH4kMlwtv0DXsLh9L+dNjqXhtJ5IKS7jhGZiznOwE09L NoNgWQ7tNLa+xseye6OEuYtIDAn10uhgeJO+jvHGKPu342WuGEr/8XgfPkjBjkizuuMO owRfWVUugZCuFdSqpwK4OWmRYH3VVYjwHQO51o4HvQLr6Q0hA3zGXpqrlGgnT4cHSORz 61OIGgdxtpQ3kJSm07OYD476fZ6BTDjyIBpmkjJRzVvDXtNyOGfku865TUoB0zqGkz4l K4HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:references:user-agent :in-reply-to:message-id:mime-version; bh=IDgojv3a5kkwuYIJ5GRf6+sd6hunAwDPVHqjM25mC2E=; b=PzJHSJqIz6nb39NgI79Wma/XQ6jit9Zgr0YDA4qhZpV0dRf39lnEQB8cbXd2xr7SsK QGgiUdTA9ur/333k0e8r1CYZC9fMjt1tHykr5z+vmrQNbQ7clAd4LdQ9mqlmhjQHHebk Szm97u6DuDmnSK3F8WRT1J3/M6emcd9BisNdWPuU8BGqe0/cBWvxuWWaTZ4XhX5cVP9G IO+GO6XJeNseGM9mFqVB5udzrsI6nWEdeyWRbzHtPOJSA8BfyNgaoWnXxgZe1ZpGa4Ne 70p0FMQmQ+4Kif7eCZQU0xzka9EbphhfobSP5m9oJ75ZXF8xaYDt8J2p+o6+2O46bWxh uT9w== X-Gm-Message-State: AOAM532YdcCVD/c9U82nbyXh2tJ2O0wY27XJKMl2CZudGVIaN+QHB84C 2R/ZYkfBkmFJmmsKhwoSFyWbatSbg+I= X-Google-Smtp-Source: ABdhPJxhqqw9qZBLf4TKom+unvkxohM9c5N7826YMsl+iFEY5kFDs/7Rws4u1mQcEzLDGe4xD6J0Qg== X-Received: by 2002:a17:90a:4d0c:: with SMTP id c12mr31005927pjg.151.1637582144339; Mon, 22 Nov 2021 03:55:44 -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 j7sm8929432pfc.74.2021.11.22.03.55.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Nov 2021 03:55:43 -0800 (PST) From: Timothy To: org-mode-email Subject: Re: [PATCH] Fontification for inline src blocks Date: Mon, 22 Nov 2021 19:52:54 +0800 References: <87pmzf4bd0.fsf@gmail.com> <87o86d7g05.fsf@gmail.com> User-agent: mu4e 1.6.9; emacs 28.0.50 In-reply-to: <87o86d7g05.fsf@gmail.com> Message-ID: <875ysk76bo.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::1029 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=tecosaur@gmail.com; helo=mail-pj1-x1029.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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1637582189; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=geCeavw0BaZxSqP/URZOLx3hHcXREqqRqhGD7bkbf2s=; b=OjizPPFVWRAmOJu53NzayQ89tWtgHkBOxDvIHZBrQpMxAwayyMcc6qbUbGcSBO/NMMxUdJ iujpFqODH5J0B9pL0H7RgpBu/PRyAl9syQYjxGGiKWmI3CUPc5hdq0LVMSvjzjXxKxfmMr GJL8VgtWgvWnexFKU2iQ0EysRAmqc0VPMPR7kIxuHUR921W9hVmlBX+/4x6+q4USFpd+cQ ElPBEHOzmGp1fame5e8lyr6/Ox8F4+/W/AwN7PNcmAnMF8oFdySKRZClt/HU0xd10aV1+7 TTouvVMy4eODK9MqRhM3nFs5ScpXuydQhcfp6vMX0f6KPLWAkffvSYR4fpn4kg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1637582189; a=rsa-sha256; cv=none; b=BCVVh9shaIbJex7ufAHa2tJlk60pFvTH10z7Wch0pnvjtMORp08qqeKZf0xTzpOfyOg+xc JN2FWZ5i4O1fyOCsvX3jcFgTExUqTbIrITIqeT1lHvNWGYOY4fd7U/pxQsWrPhrKI8awB8 +S2TOh1/ptP5P+tAcphQ/k93tGO2/2GMvTuSlgN1s/2jMEFHU3n1S+w5BIB1frRhAL+xb7 x3ukSY72bEOz05EqhnZvHLDw9uChGOcd716j90nARNwruhsTJByMjRKA10srrh9T4H+2Vk iZhc1Q+KE6ehwV+MbMsXTZez9KC4L48Rn4E4/7EO7do2hBcT/nQjK8HqGktvCQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=JdkojPg+; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.78 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=JdkojPg+; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: B6DC511BEC X-Spam-Score: -1.78 X-Migadu-Scanner: scn1.migadu.com X-TUID: Bcavah7GMfEx --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Everyone, I think there=E2=80=99s room in the future to add more faces for this, but = I it occurs to me that the main complaint raised in this thread can be resolved by addi= ng one new face: `org-inline-src-block' (which inherits from `org-block') by d= efault. See attached for a patch which just adds this face. I feel like this might = be the final version of this patch so I=E2=80=99d appreciate thoughts on this. All the best, Timothy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-src-Implement-native-inline-src-fontification.patch >From 133b7a90853f7f9062bae40af2efc8fd22781125 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'. (org-inline-src-fontify-max-length): Create a variable to limit the maximum length of an inline-src block fontified, to protect from lag spikes (e.g. when typing out src_lang{ and half of the buffer is fontified). * 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 | 46 ++++++++++++++++++++++++++++++++++++++++++++++ lisp/org.el | 18 ++++++++++++++++++ 3 files changed, 68 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..f2aff1f43 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -654,6 +654,52 @@ (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 + (progn + (org-fontify-inline-src-blocks-1 limit) + (org-fontify-inline-src-results 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 "\\_