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 4N1uD2RUmmFObAAAgWs5BA (envelope-from ) for ; Sun, 21 Nov 2021 15:15:00 +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 kHIkC2RUmmGodgAA1q6Kng (envelope-from ) for ; Sun, 21 Nov 2021 14:15:00 +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 8304E2D1A4 for ; Sun, 21 Nov 2021 15:14:59 +0100 (CET) Received: from localhost ([::1]:52300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1moncQ-00019F-LO for larch@yhetil.org; Sun, 21 Nov 2021 09:14:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1monbv-000195-LF for emacs-orgmode@gnu.org; Sun, 21 Nov 2021 09:14:27 -0500 Received: from [2607:f8b0:4864:20::630] (port=43642 helo=mail-pl1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1monbt-0001w4-TI for emacs-orgmode@gnu.org; Sun, 21 Nov 2021 09:14:27 -0500 Received: by mail-pl1-x630.google.com with SMTP id m24so11866521pls.10 for ; Sun, 21 Nov 2021 06:14:24 -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=pxGxY7vOTpiix7eDnC+ZvK1Bj3KnX9xc3yuH/8872h8=; b=ZkX8KLR2psocQiL5docstsPBVUphL/fxpQ0Q5jHB0+/DdMNln3iTs8naWh77sR8faM /XQdQAwFT31BGLDHMAVxwJ8BoeMgcff+u7o8pH2WV6Zk7gdArhn1xExaM1A1Hg4QoE/3 KNZbCpPVKTHvbaWVSFL/L2oFS+PQwctBK6OBiKSU2Czy+/cHy4WPbttr7BC99LvAAFGv 2+q598wc3AzjUfdeGQlKzyFRyYCIaEnFkTkRIYdWf0tpOZFNopG1EKg/LS7WWwEMUScb U8NRHWPnh2L61xFCVotBawWITqx0Cj9ZxAuVtTWFW6eR6q4tfdaDCayIbEg9acHh/z1P bzkw== 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=pxGxY7vOTpiix7eDnC+ZvK1Bj3KnX9xc3yuH/8872h8=; b=5iYI3QzwM5qUUMeh2xsLOgpWaUIBgJegT5cietA2MXo6uFsqp6inVT42LmIew3ZxSI UnTggZ3MoQgeMZNRzVwqbnAh0e2gORusXrDVA9QV/yM8IdLI5d5Kd8Vc4D8sEm9xW5yS xk4aNR3Kk6+pp4/+28BN7oEMCUOCBXov5CWd7EBT4cfjoAu6OkuYjpM1Zz9o61e36rXa 7MzqX/nZdMIeYN+tq3PeCnMKZ+SIoFuuyPRSgj3L2Z/5P67MSayPJzn5arRQUyua1M29 54OogDFXmNX2BId3esZLW7ke3LTAqKCYka8/lTu5git7ugM9Yx1KcEut1kEC789yD/KV KRvA== X-Gm-Message-State: AOAM533lVA/7Jt0EfZyXjV12TMZsUXWkqH+yTmX648x0lqdcW4HELtjP ltH231EwE8S2T1H4zSH7ZMIsLu9bGlo= X-Google-Smtp-Source: ABdhPJzOzCWJHejIjP1fEjo/FitHDaijOiMerfFBIKRpl8Yn9tqVbthoxod28xYuCayvkNYuMtehyg== X-Received: by 2002:a17:90b:3d3:: with SMTP id go19mr21439615pjb.23.1637504063360; Sun, 21 Nov 2021 06:14:23 -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 95sm4648530pjo.2.2021.11.21.06.14.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Nov 2021 06:14:22 -0800 (PST) From: Timothy To: org-mode-email Subject: Re: [PATCH] Fontification for inline src blocks Date: Sun, 21 Nov 2021 22:09:30 +0800 References: <87pmzf4bd0.fsf@gmail.com> User-agent: mu4e 1.6.9; emacs 28.0.50 In-reply-to: <87pmzf4bd0.fsf@gmail.com> Message-ID: <87o86d7g05.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::630 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=tecosaur@gmail.com; helo=mail-pl1-x630.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=1637504099; 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=stAxWdSq68E4BrgvJP0ZayDlvmzmKMn6YiIBozZ5C7s=; b=gJi1C9P93JPn5f9kVwkjBksQGjYCSxpL12z3m8UlLt+x+J1ArxnNuAlB7oCYtdj6FUEASv rW+Yo0Osj6DJM7mxSVyX6NuCklfjifTC3TuouWcOSOHnFb8x7BKmPHqR97lKzWAVFbI2L3 4JkpeJnfZ7xsvf3w6TVVAo3vC9r9vmyIwfppnqvzX5ryNldRurCPdlQApWX5iz+51La/+p BGNSnIZSuCI5CtNBaxyXibWTpyYEvk7axZTOPuEuxJxYBL0IaQfDIlkRYo+dQuPOW8OwuY 9UAXYVxX3VMbklPxi/TKxq41TOTdCjwgvW/khkwBFJBCz7n1oJGpUPGST5ETEw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1637504099; a=rsa-sha256; cv=none; b=C0kbHhvaMMMBa/yCGqj/SeXU6FQwyfAbPZQH6BGXpqf8bT15MEnrbQF/tMAo8TBikg6FjH 2BI9EEbhdx99c88iJe4RHQD1Tp6Ytnu99+2b+PM3KlWW3YgCrKucfi7ujbTapwj8JzzzPE K2a6aPIaZXbGTdSZuYCeucugwRnNKYyILHTVGyqUSa/hEIU5GOM33+qsiZ/XN4hYcW6tmI HN03nE2uxvt2sbQKgJz4zH57LO8pYRUSD5lFIwFIkwx2FfcKY08pzaAq4GHg9OsPcC4Aeo kzLPsjgMW9L/YFxM8xhjNg03IuZq9umISXi3khm16/UB9p9N0pbtsP5lj9p9uQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=ZkX8KLR2; 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=ZkX8KLR2; 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: 8304E2D1A4 X-Spam-Score: -1.78 X-Migadu-Scanner: scn1.migadu.com X-TUID: 8Idx7n7TQ7ip --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi All, Since the contentious component of my previous patches has been the `{{{results()}}}' prettification, I=E2=80=99ve prepared an alternate versio= n that I=E2=80=99m hoping everybody will be fairly happy with (fingers crossed!) that tosses o= ut the results prettification for now. I think Protesilaos=E2=80=99 comments on making some new faces deserve cons= ideration, but could easily be done subsequently, as I=E2=80=99m quite keen to get thi= s merged for now. All the best, Timothy --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-src-Implement-native-inline-src-fontification.patch >From 53d2851e248c4f4e4076878a999cbf647b401578 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-src.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++ lisp/org.el | 18 ++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/lisp/org-src.el b/lisp/org-src.el index 51dde602d..c3a6a40bc 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))) + (when (re-search-forward "\\_