From unknown Wed Jun 18 23:12:42 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#78396 <78396@debbugs.gnu.org> To: bug#78396 <78396@debbugs.gnu.org> Subject: Status: [PATCH] Add option for not highlight parens inside comments or strings. Reply-To: bug#78396 <78396@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:12:42 +0000 retitle 78396 [PATCH] Add option for not highlight parens inside comments o= r strings. reassign 78396 emacs submitter 78396 Elijah Gabe P=C3=A9rez severity 78396 normal tag 78396 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon May 12 14:52:16 2025 Received: (at submit) by debbugs.gnu.org; 12 May 2025 18:52:16 +0000 Received: from localhost ([127.0.0.1]:54772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uEYG7-0003Aw-Ka for submit@debbugs.gnu.org; Mon, 12 May 2025 14:52:16 -0400 Received: from lists.gnu.org ([2001:470:142::17]:48664) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uEYG4-0003Ae-Kk for submit@debbugs.gnu.org; Mon, 12 May 2025 14:52:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uEYFz-0007I2-0P for bug-gnu-emacs@gnu.org; Mon, 12 May 2025 14:52:07 -0400 Received: from mail-oo1-xc41.google.com ([2607:f8b0:4864:20::c41]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uEYFs-0005mr-SX for bug-gnu-emacs@gnu.org; Mon, 12 May 2025 14:52:06 -0400 Received: by mail-oo1-xc41.google.com with SMTP id 006d021491bc7-604ad0347f5so1134489eaf.2 for ; Mon, 12 May 2025 11:52:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747075919; x=1747680719; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Yvwfwn3idpECSJ9Fi57u38z+KxK1wEqyLaq4SK+rH4Y=; b=R747S46V8M+JSB5TPrYgFiszZVbXycx0oxTNjeUuxmamx35wNUM2nptNCeEEqLKPEQ GoFvSQQ+iz+p7pjCtMcwQVUmN5EeYXGK60eCzAoSXckWy4R9M/ChBR0wrJLarIsXKLmk 7YfHW7xWYyTGARmEms/8z213SBYgFL1ng7YuY0T55/8ANPnkr+rrCa2GHDwe9jhgHMcm mA0lVjLERngVz0hThrQUhdVUKRQUf7ygm5Pcxi1Il7SsKIJ8HPauFzCxwPOWEn7I811M jZvyPvJEr+goPooW/xy3hVIi7Z3q7X0beIgtX7qwsFaKRnwbDSRTZHRO5EXkIqKxsq+4 ZK7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747075919; x=1747680719; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Yvwfwn3idpECSJ9Fi57u38z+KxK1wEqyLaq4SK+rH4Y=; b=Dr4BG+Y8owf/ol5PJ2J7r3kPmXzBkxt6NeGKj0zT09IH4iyvd+CcLivqErMdHfVvq0 5kmboLvDIBTwmfNZQ33Z2LJS5wG1KHTjtN2oZ1ZTafSqUNec9OKgTjHT1f7cYNkZVW5C bj5X0Hx+s2Ogq5ZLEOMFhZAn/HVgpIwM6Kdd/95P7lJjEifh9JTkhtR4pYcixPNZpCh8 5alvZU7RyuyVP+6QXIlH8FUumZtr9pJHgpyvSPe2UtDp4CLBiJ3a/Jdygt4GU8dZePOG uro8OmXkR/1Z8HyFmK+0eI78vrDpIV7d03yEZERAv/AsTcAbIJ7QUwuDTl4PIDPAI4hR xZUQ== X-Gm-Message-State: AOJu0YzAc0F0q26xlyYNLrdBjB+J+sh6+jGP8HMBaUNlft3oIp2YRX9t cz/GtWI1L29CGT/Ynuy0Q7pQF8zKzZq4J5ibiamXlMRcJKAJ88QLjA5dRuL4 X-Gm-Gg: ASbGncvAoz8BoI0ndhDgs4a911Dv00fjaU+WFJTI8ETLaxNM2LfNBwDn6oyPUx1+Py1 WlmP10J+YHU5aWkhiHzVqT2x+5O3IO2YypwBw+ZRbbTTzgt8z5YRzvbseCh40oT78ehN5+JWRY0 C1jEpnOwTU0WFtgO+FUxHkL7oVQs0iz+J8zA7D2thquzNJiftkb0yR+9GFnriU+LiLfqngdidB+ r2weLyyq4Ub0BS3KU7IUIlQvXJ25HqXgVXP2rwhxLkA2J2n6Nk6Tftk373OkxLtKTs60XdzkkuW 0fxP88AJ6sh3pZ7DXPY= X-Google-Smtp-Source: AGHT+IGzbvaQtRWNFaUEpq/lMakxkLWHlm4F+YDthKsCja4gLZiizxRznfF0BDOICFa3ASsmyjFS/g== X-Received: by 2002:a05:6808:2f0a:b0:403:25bd:ca6c with SMTP id 5614622812f47-4038005b46cmr7688946b6e.14.1747075918938; Mon, 12 May 2025 11:51:58 -0700 (PDT) Received: from fedora ([2806:10ae:e:7379::1]) by smtp.gmail.com with ESMTPSA id 5614622812f47-40380398facsm1657942b6e.42.2025.05.12.11.51.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 May 2025 11:51:58 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: bug-gnu-emacs@gnu.org Subject: [PATCH] Add option for not highlight parens inside comments or strings. X-Debbugs-Cc: Date: Mon, 12 May 2025 12:51:57 -0600 Message-ID: <87o6vxbr1u.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::c41; envelope-from=eg642616@gmail.com; helo=mail-oo1-xc41.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Tags: patch Sometimes show-paren will highlight the parens that are inside a comment/string which looks annoying and somewhat confusing. e.g. show-paren will highlight this paren: Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (eg642616[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (eg642616[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org] X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) --=-=-= Content-Type: text/plain Tags: patch Sometimes show-paren will highlight the parens that are inside a comment/string which looks annoying and somewhat confusing. e.g. show-paren will highlight this paren: ;; :^)| <- cursor ^ paren highlighted as mismatch or: v ( ;; )| <- cursor ^ both parens highlighted I've made an option for disable/control this behavior, by default its disabled but I wonder if this should be activated instead. --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-option-for-not-highlight-parens-inside-comments-.patch >From cf70180ae5ffe895c44ca84ac7670ab583334495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= Date: Mon, 12 May 2025 12:04:46 -0600 Subject: [PATCH] Add option for not highlight parens inside comments or strings. * lisp/paren.el (show-paren-not-in-comments-or-strings): New user option. (show-paren-function): Enclose code in catch function. * etc/NEWS: Announce changes. * doc/emacs/programs.texi: Document new option. --- doc/emacs/programs.texi | 7 ++ etc/NEWS | 7 ++ lisp/paren.el | 183 ++++++++++++++++++++++------------------ 3 files changed, 116 insertions(+), 81 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index f3cdc1b8e6c..5da6c263f0d 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -1056,6 +1056,13 @@ Matching that contains the opening delimiter, except if the opening delimiter is on its own line, in which case the context includes the previous nonblank line. + +@item +@vindex show-paren-not-in-comments-or-strings +@code{show-paren-not-in-comments-or-strings}, If set to @code{all}, do +not highlight all the parens that are inside comments or strings. If +set to @code{on-mismatch}, only don't highlight if paren mismatched. If set +to @code{nil} (by default), highlight the paren wherever it is. @end itemize @cindex Electric Pair mode diff --git a/etc/NEWS b/etc/NEWS index d1b0189da0c..f9314af8036 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -471,6 +471,13 @@ setting is an alternative to 'help-at-pt-display-when-idle'. Customize this to nil to disable starting new asynchronous native compilations while AC power is not connected. +** New user option 'show-paren-not-in-comments-or-strings' +This option tells show-paren don't highlight the parens that are inside +a comment or string. If set to 'all', do not highlight all the parens +that are inside comments or strings. If set to 'on-mismatch', only +don't highlight if paren mismatched. If set to nil (by default), +highlight the paren wherever it is. + * Editing Changes in Emacs 31.1 diff --git a/lisp/paren.el b/lisp/paren.el index 9d7f131e043..ee5501a9726 100644 --- a/lisp/paren.el +++ b/lisp/paren.el @@ -110,6 +110,18 @@ show-paren-context-when-offscreen (const :tag "In child-frame" child-frame)) :version "29.1") +(defcustom show-paren-not-in-comments-or-strings nil + "Do not highlight the parens that are inside a comment or string. +If set to `all', do not highlight all the parens that are inside comments +or strings. +If set to `on-mismatch', only don't highlight if paren mismatched. +If set to nil (by default), highlight the paren wherever it is." + :type '(choice + (const :tag "Enable" all) + (const :tag "Only on mismatch" on-mismatch) + (const :tag "" nil)) + :version "31.1") + (defvar show-paren--idle-timer nil) (defvar show-paren--overlay (let ((ol (make-overlay (point) (point) nil t))) (delete-overlay ol) ol) @@ -450,88 +462,97 @@ show-paren-function (setq show-paren--last-pos (point))) ;; Found something to highlight. - (let* ((here-beg (nth 0 data)) - (here-end (nth 1 data)) - (there-beg (nth 2 data)) - (there-end (nth 3 data)) - (mismatch (nth 4 data)) - (highlight-expression - (or (eq show-paren-style 'expression) - (and there-beg - (eq show-paren-style 'mixed) - (let ((closest (if (< there-beg here-beg) - (1- there-end) (1+ there-beg)))) - (not (pos-visible-in-window-p closest)))))) - (face - (cond - (mismatch - (if show-paren-ring-bell-on-mismatch - (beep)) - 'show-paren-mismatch) - (highlight-expression 'show-paren-match-expression) - (t 'show-paren-match)))) - ;; - ;; If matching backwards, highlight the closeparen - ;; before point as well as its matching open. - ;; If matching forward, and the openparen is unbalanced, - ;; highlight the paren at point to indicate misbalance. - ;; Otherwise, turn off any such highlighting. - (if (or (not here-beg) - (and (not show-paren-highlight-openparen) - (> here-end (point)) - (<= here-beg (point)) - (integerp there-beg))) - (delete-overlay show-paren--overlay-1) - (move-overlay show-paren--overlay-1 - here-beg here-end (current-buffer)) - ;; Always set the overlay face, since it varies. - (overlay-put show-paren--overlay-1 'priority show-paren-priority) - (overlay-put show-paren--overlay-1 'face face)) - ;; - ;; Turn on highlighting for the matching paren, if found. - ;; If it's an unmatched paren, turn off any such highlighting. - (if (not there-beg) - (delete-overlay show-paren--overlay) - (if highlight-expression - (move-overlay show-paren--overlay - (if (< there-beg here-beg) here-end here-beg) - (if (< there-beg here-beg) there-beg there-end) - (current-buffer)) - (move-overlay show-paren--overlay - there-beg there-end (current-buffer))) - ;; If `show-paren-context-when-offscreen' is non-nil and - ;; point is at a closing paren, show the context around the - ;; opening paren. - (let ((openparen (min here-beg there-beg))) - (when (and show-paren-context-when-offscreen - (not (eql show-paren--last-pos (point))) - (< there-beg here-beg) - ;; Either OPENPAREN position is fully visible... - (not (or (pos-visible-in-window-p openparen) - (let ((dfh4 (* 0.25 (default-font-height))) - (part - (pos-visible-in-window-p openparen - nil t))) - ;; ...or partially visible, and the - ;; invisible part is less than 1/4th - ;; of the default font height - (and (>= (length part) 4) - (< (nth 2 part) dfh4) - (< (nth 3 part) dfh4)))))) - (let ((context (blink-paren-open-paren-line-string - openparen)) - (message-log-max nil)) + (catch 'sp-exit + (let* ((here-beg (nth 0 data)) + (here-end (nth 1 data)) + (there-beg (nth 2 data)) + (there-end (nth 3 data)) + (mismatch (nth 4 data)) + (highlight-expression + (or (eq show-paren-style 'expression) + (and there-beg + (eq show-paren-style 'mixed) + (let ((closest (if (< there-beg here-beg) + (1- there-end) (1+ there-beg)))) + (not (pos-visible-in-window-p closest)))))) + (face (cond - ((eq show-paren-context-when-offscreen 'child-frame) - (show-paren--show-context-in-child-frame context)) - ((eq show-paren-context-when-offscreen 'overlay) - (show-paren--show-context-in-overlay context)) - (show-paren-context-when-offscreen - (minibuffer-message "Matches %s" context)))))) - (setq show-paren--last-pos (point)) - ;; Always set the overlay face, since it varies. - (overlay-put show-paren--overlay 'priority show-paren-priority) - (overlay-put show-paren--overlay 'face face)))))) + (mismatch + (if (and (eq show-paren-not-in-comments-or-strings 'on-mismatch) + (save-excursion + (syntax-ppss-context (syntax-ppss here-beg)))) + (throw 'sp-exit nil)) + (if show-paren-ring-bell-on-mismatch + (beep)) + 'show-paren-mismatch) + (highlight-expression 'show-paren-match-expression) + (t 'show-paren-match)))) + (if (and (eq show-paren-not-in-comments-or-strings 'all) + (save-excursion + (syntax-ppss-context (syntax-ppss here-beg)))) + (throw 'sp-exit nil)) + ;; + ;; If matching backwards, highlight the closeparen + ;; before point as well as its matching open. + ;; If matching forward, and the openparen is unbalanced, + ;; highlight the paren at point to indicate misbalance. + ;; Otherwise, turn off any such highlighting. + (if (or (not here-beg) + (and (not show-paren-highlight-openparen) + (> here-end (point)) + (<= here-beg (point)) + (integerp there-beg))) + (delete-overlay show-paren--overlay-1) + (move-overlay show-paren--overlay-1 + here-beg here-end (current-buffer)) + ;; Always set the overlay face, since it varies. + (overlay-put show-paren--overlay-1 'priority show-paren-priority) + (overlay-put show-paren--overlay-1 'face face)) + ;; + ;; Turn on highlighting for the matching paren, if found. + ;; If it's an unmatched paren, turn off any such highlighting. + (if (not there-beg) + (delete-overlay show-paren--overlay) + (if highlight-expression + (move-overlay show-paren--overlay + (if (< there-beg here-beg) here-end here-beg) + (if (< there-beg here-beg) there-beg there-end) + (current-buffer)) + (move-overlay show-paren--overlay + there-beg there-end (current-buffer))) + ;; If `show-paren-context-when-offscreen' is non-nil and + ;; point is at a closing paren, show the context around the + ;; opening paren. + (let ((openparen (min here-beg there-beg))) + (when (and show-paren-context-when-offscreen + (not (eql show-paren--last-pos (point))) + (< there-beg here-beg) + ;; Either OPENPAREN position is fully visible... + (not (or (pos-visible-in-window-p openparen) + (let ((dfh4 (* 0.25 (default-font-height))) + (part + (pos-visible-in-window-p openparen + nil t))) + ;; ...or partially visible, and the + ;; invisible part is less than 1/4th + ;; of the default font height + (and (>= (length part) 4) + (< (nth 2 part) dfh4) + (< (nth 3 part) dfh4)))))) + (let ((context (blink-paren-open-paren-line-string + openparen)) + (message-log-max nil)) + (cond + ((eq show-paren-context-when-offscreen 'child-frame) + (show-paren--show-context-in-child-frame context)) + ((eq show-paren-context-when-offscreen 'overlay) + (show-paren--show-context-in-overlay context)) + (show-paren-context-when-offscreen + (minibuffer-message "Matches %s" context)))))) + (setq show-paren--last-pos (point)) + ;; Always set the overlay face, since it varies. + (overlay-put show-paren--overlay 'priority show-paren-priority) + (overlay-put show-paren--overlay 'face face))))))) (provide 'paren) -- 2.49.0 --=-=-= Content-Type: text/plain -- - E.G via GNU Emacs and Org. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 17 05:24:23 2025 Received: (at 78396) by debbugs.gnu.org; 17 May 2025 09:24:23 +0000 Received: from localhost ([127.0.0.1]:45731 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uGDmI-0003V2-Hu for submit@debbugs.gnu.org; Sat, 17 May 2025 05:24:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35244) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uGDmF-0003Ud-6s for 78396@debbugs.gnu.org; Sat, 17 May 2025 05:24:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uGDm9-0000mo-Qv; Sat, 17 May 2025 05:24:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=ltYNgav8q/i1rEQtvume2I3K0i9YyUZ2ZDk1PPna35E=; b=T006KAL6GBValk493vQy +wOZ3th7h0N1FrWq9B4h18SqYTlCLmsLKE0bb8r3UtTRWw7VLoit1iqpYQA64uSNiVKJ2rvWHY8r2 e93PGNB8KIHRaLUwEBwKCCAOiVwM+7UwBZXublN6jwfVFpH7zt0fQ6o+m/Gmqu6hRchrpJV9DQcbc 13dOROGzw5qIcLQ8H2bVYvs214k8cAOFqKYre2mLpLulg7UpjdUOWkTdTYCtY4e/qhrOfbf8WwhSB XkUDPDIrBdgkiiARsA0Cbp0e0jX/ieU1h4BMdednGAouCtC8nv7cUCDcUCR+GWf4jG0N7WnD7IZWG 5H6Tq38m76earA==; Date: Sat, 17 May 2025 12:24:11 +0300 Message-Id: <867c2fwpxg.fsf@gnu.org> From: Eli Zaretskii To: Elijah Gabe =?iso-8859-1?Q?P=E9rez?= , Stefan Monnier In-Reply-To: <87o6vxbr1u.fsf@gmail.com> (message from Elijah Gabe =?iso-8859-1?Q?P=E9rez?= on Mon, 12 May 2025 12:51:57 -0600) Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. References: <87o6vxbr1u.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78396 Cc: 78396@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Elijah Gabe Pérez > Date: Mon, 12 May 2025 12:51:57 -0600 > > Sometimes show-paren will highlight the parens that are inside a > comment/string which looks annoying and somewhat confusing. > > e.g. > show-paren will highlight this paren: > > ;; :^)| <- cursor > ^ paren highlighted as mismatch > > or: > v > ( > ;; )| <- cursor > ^ both parens highlighted > > I've made an option for disable/control this behavior, by default its > disabled but I wonder if this should be activated instead. I'm worried by using syntax-ppss-context here: couldn't it sometimes significantly slow down the highlighting of parens? Stefan, WDYT? > +@vindex show-paren-not-in-comments-or-strings > +@code{show-paren-not-in-comments-or-strings}, If set to @code{all}, do ^^ That "If" should be in lower case. > +not highlight all the parens that are inside comments or strings. If > +set to @code{on-mismatch}, only don't highlight if paren mismatched. If set > +to @code{nil} (by default), highlight the paren wherever it is. The style here is not appropriate for the manual, it is a style for the doc string. I'd use something like If the value of @code{show-paren-not-in-comments-or-strings} is @code{all}, delimiters inside comments and strings will not be highlighted. > +** New user option 'show-paren-not-in-comments-or-strings' The period at the end of this heading line is missing. > +This option tells show-paren don't highlight the parens that are inside ^^^^^^^^^^^^^^^ "not to highlight" > +(defcustom show-paren-not-in-comments-or-strings nil > + "Do not highlight the parens that are inside a comment or string. > +If set to `all', do not highlight all the parens that are inside comments > +or strings. > +If set to `on-mismatch', only don't highlight if paren mismatched. > +If set to nil (by default), highlight the paren wherever it is." > + :type '(choice > + (const :tag "Enable" all) "Enable" is not a good tag here, because this feature actually _disables_ highlighting. I would use "Never highlight" instead. > + (const :tag "Only on mismatch" on-mismatch) And here I'd use "Don't highlight when mismatched". From debbugs-submit-bounces@debbugs.gnu.org Mon May 19 22:54:27 2025 Received: (at 78396) by debbugs.gnu.org; 20 May 2025 02:54:27 +0000 Received: from localhost ([127.0.0.1]:50117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uHD7a-0008WN-NM for submit@debbugs.gnu.org; Mon, 19 May 2025 22:54:26 -0400 Received: from mail-oo1-xc44.google.com ([2607:f8b0:4864:20::c44]:60794) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uHD7X-0008Vz-Mi for 78396@debbugs.gnu.org; Mon, 19 May 2025 22:54:24 -0400 Received: by mail-oo1-xc44.google.com with SMTP id 006d021491bc7-6065251725bso3653025eaf.1 for <78396@debbugs.gnu.org>; Mon, 19 May 2025 19:54:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747709657; x=1748314457; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=SoEGdPRQ8UYrzd82MfdvRuYCabDWI2j3p340Bju/WJU=; b=Z/pQtOzKaE9vgxQ51rMG0fU7N1O9XgKUqcBFrxtN+brDzHZ4ClWkj6U09aJEdGAj6V nXqmEWZI//2PKXmSJEUZiWhPmZ7wvQk+Wm2HPHCGowoi8rdyQisT1fX+YLExSBNj/xo+ +3rG/EzAyON/edMoKcfOwObcLH62JuPUnz4cBmoyTu8nPqbA04+blL+TFilHjPE5Co4r 3kyp74nO0A64NDqdWhBFncNX0rLSSnty6glrfURCvCyxPxtsF1R2Awg7KnzXHf/Jyv0A V0Ly2M0lH/mIw+LxAIykaLG/8Mh92RHtVuQHHA2HesTYzrk89o01xeufP9J/TWtovVXo iCMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747709657; x=1748314457; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SoEGdPRQ8UYrzd82MfdvRuYCabDWI2j3p340Bju/WJU=; b=fhK9WWqD9nrdvGSZx2JiaW+L6N9QLTvma2pYdUcOL+mEdn7bU6x4tJCb8d8/2yi9zA D3C7L6a47nwPOjS1WYIQeABSC2OoYdXXBMLpQK+2QSQZtrhmzrxCQg9Q3ohELa00DoXR FJipQA9B0s2tiXY8IUeDbnywZV2/dNPCboJV241SLx6b+tvmxIDN4sZkbb/MFvnnX2/+ E8lBlcq0o7LIOcrmemsM7dnJNdZtZeGq2pVWAiVzm72M2gXDH2nFgMOSL4A0LGHWy9Vw c7/wC2GYDO5ZJAv9j/f1iAcVufqAyoI0NSwrO4XfUIm+0FzPZOwoWshBpfLFJuYuofSg VOvg== X-Forwarded-Encrypted: i=1; AJvYcCV4MCTKUkJXv3H9JDgNQv6dmu3WIl2/FCHHaAgbxpSkJHUQY7qFmyvR0QP9QkFBVF91HvI2PQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0YwNu6de1tCNuR0896o4QH58if5Ki1nqUE/uSIrVHkl5LCuZuemR NKsIvzHkG5xuIu057pPGNhGqKyrq4Y1cprGXbO/2IkwheoIHLHhRiSDrb5fhacpG X-Gm-Gg: ASbGncs1hDr/sdbFQqgSL9fFk3BYoc2nt67oDBIZWNbD9OPzBOo27yBb4aaxWu8JiEX +UoofPOxiEbMs2MwX480MmB3/+NacXV/vtzDnuVxzlWeyGj4U2Pr7I2hlBHCWteAx+KjASZdMU8 gpzB2ik6dA2G9WE6+FFHV3baa4RNYWN3BLP5AMQ51T5fVVVDSb2rHIlVGJOo32+Lxa0H7IjMlUS 2+yPFU0L4Th7D/xlmMgUyaCPddhY6y2RxVpnu+IlCPe9H28IveTEzOACazNSoEVOks6yadzTe2b iAbtD5XeezSr5bg1IrI= X-Google-Smtp-Source: AGHT+IFCNbKzy6usnif2RrVKyZG9jesraORyz8Zi1RcbMsFYEilxtszPJ/u3v49iMhM3p/52hczCGA== X-Received: by 2002:a05:6871:a902:b0:2c1:44a9:fc16 with SMTP id 586e51a60fabf-2e3c1f83049mr8502996fac.38.1747709657259; Mon, 19 May 2025 19:54:17 -0700 (PDT) Received: from fedora ([2806:10ae:e:7f0c::1]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2e3c06bada4sm2013526fac.15.2025.05.19.19.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 May 2025 19:54:16 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: Eli Zaretskii Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. In-Reply-To: <867c2fwpxg.fsf@gnu.org> References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> Date: Mon, 19 May 2025 20:54:15 -0600 Message-ID: <87bjrokn54.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 78396 Cc: Stefan Monnier , 78396@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Eli Zaretskii writes: >> I've made an option for disable/control this behavior, by default its >> disabled but I wonder if this should be activated instead. > > I'm worried by using syntax-ppss-context here: couldn't it sometimes > significantly slow down the highlighting of parens? I've tried it but haven't noticed any slow down (maybe because of the machine I have(?)) But if syntax-ppss is slow, isn't there a better alternative? -- - E.G via GNU Emacs and Org. From debbugs-submit-bounces@debbugs.gnu.org Wed May 21 07:12:06 2025 Received: (at 78396) by debbugs.gnu.org; 21 May 2025 11:12:06 +0000 Received: from localhost ([127.0.0.1]:45994 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uHhMj-00047m-Ig for submit@debbugs.gnu.org; Wed, 21 May 2025 07:12:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42610) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uHhMg-00046g-61 for 78396@debbugs.gnu.org; Wed, 21 May 2025 07:12:02 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhMa-00054y-BV; Wed, 21 May 2025 07:11:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=HYIdS3eyI6+0eqMRpPYMsghXd9uj4a29A84dY5C8d1s=; b=VCWInWyZR9D6MdvTzSet k9ZGanxBGMTldX+fAvVnt/1rQzbRL/7+/FytozK0ITyg6RoJoC80dEVBvazwkIUO7m9DdXR3madUG Bx//yarsWwo7TFkT5Q06YZ06UcElzwuQbc5V/KrlA84/E9/dMmuHOdoXFCXoodeD710kMG/uTyj/F j68eV68UnCm1J2l82Y60FT4+qcRB4O4djqo8gFpIKCrG+kAcsXsOKmw7DCxbSOD1B6JeIAkdc36q6 6D5ZcHBv+2wb5ppPywQ82eC/3JBf3B3RqLacSu0BiIdtclwLgSq4yCDV3b8iokILJVMuMwvDipXvr kFPLxuRouW//eA==; Date: Wed, 21 May 2025 14:11:41 +0300 Message-Id: <86h61e8bgy.fsf@gnu.org> From: Eli Zaretskii To: Elijah Gabe =?iso-8859-1?Q?P=E9rez?= In-Reply-To: <87bjrokn54.fsf@gmail.com> (message from Elijah Gabe =?iso-8859-1?Q?P=E9rez?= on Mon, 19 May 2025 20:54:15 -0600) Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> <87bjrokn54.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78396 Cc: monnier@iro.umontreal.ca, 78396@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Elijah Gabe Pérez > Cc: Stefan Monnier , 78396@debbugs.gnu.org > Date: Mon, 19 May 2025 20:54:15 -0600 > > Eli Zaretskii writes: > > >> I've made an option for disable/control this behavior, by default its > >> disabled but I wonder if this should be activated instead. > > > > I'm worried by using syntax-ppss-context here: couldn't it sometimes > > significantly slow down the highlighting of parens? > > I've tried it but haven't noticed any slow down (maybe because of the > machine I have(?)) > > But if syntax-ppss is slow, isn't there a better alternative? I hope Stefan will chime in and provide his opinions on this. From debbugs-submit-bounces@debbugs.gnu.org Tue May 27 17:02:32 2025 Received: (at 78396) by debbugs.gnu.org; 27 May 2025 21:02:32 +0000 Received: from localhost ([127.0.0.1]:45152 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uK1RP-0003uS-2X for submit@debbugs.gnu.org; Tue, 27 May 2025 17:02:31 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:41954) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uK1RL-0003td-Jb for 78396@debbugs.gnu.org; Tue, 27 May 2025 17:02:28 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CD8264419C0; Tue, 27 May 2025 17:02:21 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1748379740; bh=05bjsmp3UTCwD1DFtWWnVlExrfnuC5JUY4ZlxyaGhNA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=TtIM8smKJGFacPiTCrUvMOzyLwtg8D9TVh556i9RdiPMozEYUzJMLGE2lH4qyjBi5 9mMaHPw6DKNAlDvu00vnOXzQXkXpyepDZmeJ3nEjCS3AJsANJ9Q2NYOtw7RwwdeVsa ZvQi2dw7pkqnFXRtkJZTLFq6CtFbZ/07w4qH0wY8K7ELBXDFjb1HkZbrWBCji5Qn3n APsyCLVFzMzhnpZ7a3QyCXlZh5cDkLebQYkQxWLWxgi8M1nVqasw8eIQUc16aGm4Ox RycwC8zTWAUZfemFt9n3ZnnDRZgXEGS2MMES346VJ8gWCbYIVBVHCnR7HhRf+qwdpq TLhaRqUMXAfZw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CA0B14419E5; Tue, 27 May 2025 17:02:20 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B83181202C7; Tue, 27 May 2025 17:02:20 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. In-Reply-To: <867c2fwpxg.fsf@gnu.org> Message-ID: References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> Date: Tue, 27 May 2025 17:02:20 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.161 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78396 Cc: Elijah Gabe =?windows-1252?Q?P=E9rez?= , 78396@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> Sometimes show-paren will highlight the parens that are inside a >> comment/string which looks annoying and somewhat confusing. >> >> e.g. >> show-paren will highlight this paren: >> >> ;; :^)| <- cursor >> ^ paren highlighted as mismatch >> >> or: >> v >> ( >> ;; )| <- cursor >> ^ both parens highlighted Ideally, we'd want to match closing-parens-in-comments with opening-parens-in-comments. But yes, it's good to refrain from giving the above bogus highlighting. >> I've made an option for disable/control this behavior, by default its >> disabled but I wonder if this should be activated instead. > I'm worried by using syntax-ppss-context here: couldn't it sometimes > significantly slow down the highlighting of parens? Stefan, WDYT? `syntax-ppss` is not cheap, but here it's not used inside a loop and should be called only once per user-interaction so I'm not worried. I see there are two calls, tho, so I'd try to consolidate them so we call it at most once. Stefan From debbugs-submit-bounces@debbugs.gnu.org Tue May 27 19:07:16 2025 Received: (at 78396) by debbugs.gnu.org; 27 May 2025 23:07:16 +0000 Received: from localhost ([127.0.0.1]:45998 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uK3O7-0004Xf-KF for submit@debbugs.gnu.org; Tue, 27 May 2025 19:07:15 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:1506) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uK3O3-0004XH-6h for 78396@debbugs.gnu.org; Tue, 27 May 2025 19:07:13 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 54RLNEOa012027; Tue, 27 May 2025 23:07:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2025-04-25; bh=3fd6rPnsz7c8OzFJeEzaw4BX9x8ow/h0zC+8TcGSkVo=; b= Vd9SNav6QhN00WHngv+HMRUT1VOIWAltUaUkfyIQKOG16wCuM1uk96M07CQZil0D u6aXP2B2nVtWv9DGxwm66BDZHgHvEzTbLXasa/DoX9OStvzBdm8jsoF7tO2sCokO pcvcREO3hEyFp0NbxZP9G8gKWhid2b9nA4CYsT5tyj0OnG0lmKUyvaTe1SqkmE6O ruTMCuMvssvG7MVUD2S632lgyVcooyLqV/Fb1HFHeXKwcge69F6iAYcpx0ZH1CIa /1RF5i8HNPDeO5OdIwFrwqPuXD+xJety32w3z/bfT1rCuMpY8f8Yr4eQ00QlVXU9 LPRfAzV6Fnd6VJZKeljjvA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 46v46tvnn4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 May 2025 23:07:09 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 54RMkRRG007322; Tue, 27 May 2025 23:07:08 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10on2070.outbound.protection.outlook.com [40.107.92.70]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 46u4j9x07b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 May 2025 23:07:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BKbiAZ81kCBr1a43oWOFM3QlIYZt8fJihvrjb4LNSRIyOAe5KLSLdB0mAqyjtXp8eJabSPAuU7hf/RRPIGhGPIvt6fqwImcpcR3cNx9xHEN64eP2W4aWpdCblJRiUIOj0KX0Cza7c6Td32fpgq7cU2WrslqHh56lycokSKte3lEIKVn1O7q19mY88u1VqFAsdJw8IjnU5FDfOp0ZQeRcbK9NFbCOFe90GulQx07uQ3CsDuteS+w+4FIX0JjDVbbGzAeaMkSAEsPvydyCJMHWfjo3eHA+xtqCUacAABIPleHF3agOWr5Rc/UNAltWW09yGnmmVLtq7uhnQYdSDIA7dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3fd6rPnsz7c8OzFJeEzaw4BX9x8ow/h0zC+8TcGSkVo=; b=r0cD1HOiS0lLmGXgAgkUqD8O6kCNipZIoWnKQjVLRexQOSyw2hGgz6iUMflVVV+pwKaxd9GKTCFHbXAGBj3a//OgDzqu49A/mQiQwySH3PZEBc3G2LE03KxGycwH5MxxejVWSiZFSruaybR18ampjDq5X5t1RunbL4t2ehetB468Mq6KPSJpB19o+0MVxCBsYqe3GMmClEwMGca0JSq1dWhUFfsatqxzEZlckp0aMk9K5yfLi2lBS4GI0rHYKdk7wKBGwUCa2WwPga4UYA5SkcvMjpS5Jrqsj15AFlO8QOa553i5UXJgGCOQ9WHdkQlYrFvB/HKbBz4htfcK+xYlKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3fd6rPnsz7c8OzFJeEzaw4BX9x8ow/h0zC+8TcGSkVo=; b=W1I8NCH2A/sZPEiZXsrg1FQnBcBkRao5AnJnlLdLrYaw0gZOO4IuiCh16knI/5F2Tq4Xx5bVYq13WwgcWi/uVLbJlmF1Ifb/olUyAsBaTe6CBS3dHlRJKn+3F+96QszMHPFu+H9K3ErUNpD1NtmpZjuK8y7kSuuwXxMUxvlMVNw= Received: from DS7PR10MB5232.namprd10.prod.outlook.com (2603:10b6:5:3aa::24) by DS4PPF26D9E501B.namprd10.prod.outlook.com (2603:10b6:f:fc00::d11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8746.31; Tue, 27 May 2025 23:07:05 +0000 Received: from DS7PR10MB5232.namprd10.prod.outlook.com ([fe80::8303:658f:14f8:2324]) by DS7PR10MB5232.namprd10.prod.outlook.com ([fe80::8303:658f:14f8:2324%7]) with mapi id 15.20.8746.035; Tue, 27 May 2025 23:07:05 +0000 From: Drew Adams To: Stefan Monnier , Eli Zaretskii Subject: RE: [External] : bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. Thread-Topic: [External] : bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. Thread-Index: AQHbz0ro+d6tv7JycUa4NUinx01G+bPnF14w Date: Tue, 27 May 2025 23:07:05 +0000 Message-ID: References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS7PR10MB5232:EE_|DS4PPF26D9E501B:EE_ x-ms-office365-filtering-correlation-id: 24923b4d-2427-433f-3454-08dd9d733295 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?iso-8859-1?Q?Pj80PiHG0LZ1nvv0iK/FRXmzBUNh8qm1Dq/cxoSY4lPAfmqNXTW1Gxc/UQ?= =?iso-8859-1?Q?G9/reKVNxkpgNuexdyAiBdd1LP82SQgA2ZZZZiACA5qiGtsbRBqbMzaykE?= =?iso-8859-1?Q?E0zY6a7sn1d+OaDjfPZ/5q04CfELXNG1mO21RBWlU/1CZaTeFf5TdFxG+q?= =?iso-8859-1?Q?zGgiQv+6jXLLzEKLFsVMYgusj6a+Uw0WAF30RTNNb7ytIMg8jNcPDTWtt1?= =?iso-8859-1?Q?275dhkd2XFE9l+Am6zgREbTkph0R94VHF2ONu2kUyTY+uR/Cy46jvMYnJk?= =?iso-8859-1?Q?N5Pm58d7Ys0fG7Q5ohi8NuDb0+52dxwlWgBkPAALXoCRdzHbnWGOJDnG5z?= =?iso-8859-1?Q?ArDHmfCrCNUiVoTRcGOXiENedyQDfgHhQKkL1XXj3ErlzQhg3/QPexUpV0?= =?iso-8859-1?Q?QVHk+NOv3uXOjnIlvuRJIr8TlCxu8lfRqkDPNFFj3aieEKG2g0gHLIzT2I?= =?iso-8859-1?Q?nX4faBw5ITGC0xFikke55Iu6GLs1LWqq5syxf2dL2rySUZ+2pPDn2dCggv?= =?iso-8859-1?Q?4ZY7sFrqF5n5yvHuszEDJ/ySZtLI3qin8avQ6x7nTJS/1qdmMJ+cVaOaSi?= =?iso-8859-1?Q?zM1ccxcKVmsOnZIfsT4ypntnjndEBB4eQbuUWDJDIuuJLElKmxy2qfTEKQ?= =?iso-8859-1?Q?wQqPn/bXq2SI6N1D4O3FSJXKgxQq7bD2SCMvww93eTeswgOgPXe0Tnuk/W?= =?iso-8859-1?Q?CSOV0V5gFPTAZUfLc/XqBGc1rK145H23Dt/j+pFK+KuCn/8IJfY2YrAdLO?= =?iso-8859-1?Q?r9dRXoPDdEcKEu9efNho+m/oHaFOCk1eIO3hjnTXx7AyB7+NdfNm8/vWWm?= =?iso-8859-1?Q?MUJxIiFcFVtzZRSrqpX81ehCWeLBSJonR2A71JRbblyMKgHaDTLm40KA0t?= =?iso-8859-1?Q?WRm2lV0S94k/3kW2JJnGe5bk/Ph/9SKHskM7U8lxddbAJsZZ0zLP4Unk/U?= =?iso-8859-1?Q?3ZF/CV0dIcUMOYBs/JTc8QLXFkkm38NeOztLE7Wc7XQTKhfEfdC9HT9pjL?= =?iso-8859-1?Q?rrwpYIaSbMtpPFMpeWNcoX3fn2Y/x3DS1KHAQjmHNcDphHKPpO2LQgzhEy?= =?iso-8859-1?Q?2LOELcrc7TIzPrtY0RHaWX587WdeXbE3C70IN+4wVNIOOch6UQwxpi7YZ8?= =?iso-8859-1?Q?REr2bglskYKpZRu522sMd+1Exae/RFGYHWHctMXn2hXZ4cdAD4bRMuvoml?= =?iso-8859-1?Q?PdasaMaZ31VQf+mz4UQqFPkh7eQGCDI51w0Uf5XnqG6poCueUi37hmFVhN?= =?iso-8859-1?Q?wVm7BuHckJ/ztN9MeXg6i3Yin5JWiuUigAmAfBZVXehJXvUmeMRc8XZwoe?= =?iso-8859-1?Q?VwdMr4d/XvobMr7De+PwGR996FS8ad4GvURlq9RJV+uhu+OqXoIckt9Pld?= =?iso-8859-1?Q?kRxYBaE9zl8pk3bkZTDK59QCdFMeLYtFVjMt5slmKrDZ+QyvIzkIdFHOSQ?= =?iso-8859-1?Q?kAUuCOU6P6RUPhoG+VmHqNuwv8OtitJx5goc4p+4tmx3czYEZkSj5P61Dp?= =?iso-8859-1?Q?CSAog43VCOvC0Gx1rX+nzwuTiQsroSVqbQnsmr+TEbriO4+H5MldvEzLG1?= =?iso-8859-1?Q?8dWUp5c=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR10MB5232.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?vi8JylVtYgFp8twcCETCrlJZ76CjW0l8WbQtN00wU5XVMJk4cxA5MZPWKX?= =?iso-8859-1?Q?Huxtla5ZCniEq4eV0SUDpNl2x9THu2iXo2Y/vb9LQ0hsGDNgEr6+dKyzcM?= =?iso-8859-1?Q?JJwB81TNFlLwzOzzb+xGcpWQoRe74x7+YgJSOAKLih7BIEJ2wayupptXB3?= =?iso-8859-1?Q?Df9V1RKM83sGCIkkNPsWqq3nrGybmialN4mDhJ+DzqFNBs7k72OR/FhTVX?= =?iso-8859-1?Q?JNrB84YdKJ6Pvn8zP8CGGWQfqfNJkOyHJTLJlwonaM692JsuZZP+4hvbyE?= =?iso-8859-1?Q?7NzDUdY0bDbz5BNWxJosiZfmPS+DUPzwJd3qm4ON4zs4Fviwvwm4ZdVdFo?= =?iso-8859-1?Q?TRYmlTaVvtK60f73bTP68Qx1mzsYdL2oLh5mrINi5GyyHHRUkiLbretYAT?= =?iso-8859-1?Q?w/APPMDsdFWaTnBo2uYjRDqgKecNpaInhLtm5Qu8ioTGOyf6jaUYRxFgCe?= =?iso-8859-1?Q?UA6iph7phLfr/CPOHYU8knEAdHNLKmAl8sYPlv9s+O+dxkxtV1pC6+qvEY?= =?iso-8859-1?Q?CsbXRYHg8519yHsxajbJJz1JH/nENIGCXfYlPP7auxct/1SXkRzsjeF7fu?= =?iso-8859-1?Q?QpP+1vItzi6annFcxfeGHPXMDulg5AHjQQCp/+ME0PK0t6CmdQKD+iZRAI?= =?iso-8859-1?Q?cmX/1Z1NIQIgt6cfQB72xpX2GgysWAXgbtQ/y45MpyYjIo3REqZAXuk9lS?= =?iso-8859-1?Q?7NgzBKzu8SfUbqN2yNItyQckq/xmkwfqL2Ofb6ift/UyqncioQpO8lK3Vz?= =?iso-8859-1?Q?1Ve09NGS/3O4wKUSQdDEwR+IZUTFmECbdwsOorWKzgwOYd6uMbF8HtjThV?= =?iso-8859-1?Q?lz2DOg+M92XEF7kRNIMOiP+l3pymnvKn2TanYkniZDvB0dE+BUUiLDS4ne?= =?iso-8859-1?Q?ag06XLHFIY79ZQHklE3S7Gbg+9cq0WVpRKp12rd4GfydV3nhn2eMLUmQOD?= =?iso-8859-1?Q?j3iUWj2pblsMfjDj4ax9lkc4gXP1J1N9NMjwwXRmO61kgr1uLIxBd6+rDu?= =?iso-8859-1?Q?CPP5WyZAloD3FpiJYDa/qK0LJjL8eK07ShNPJLr0QSNg5UzWHrGdK7cZ9y?= =?iso-8859-1?Q?7GoGi6A2iIJ8ASJ0WOWX+pw9hADzlcrZEyELK7ZSELKVs7TzkHNoYAzmHU?= =?iso-8859-1?Q?jiDxkAKS0GftxaDflN9BZp8lfP0HTo67o/ViMXtTyWbnAtgVhQNW8IQ0kJ?= =?iso-8859-1?Q?q1MBUwzxPBJapm5Jm/5EUUX/6ZJmy6BwGo8Lo7zRCI9U1C8D95HDHH05sM?= =?iso-8859-1?Q?PvpN1sQCaCXeN+ElcJOpxGXNPWEuN3EwCUUGIPW9XDpl49CXxxvpYyFJuJ?= =?iso-8859-1?Q?rei0/kN8j14jWdwlULPkpHOPLiuBXBqcz/CNiR6gHD8LS2ARo94aPDgITq?= =?iso-8859-1?Q?KNzSaaSzdDScd5vEDGI8kFpg76jjLV1KIjTCNcdDfXLMk0eeihEddqzSIs?= =?iso-8859-1?Q?6ThI1Av2iMQTcc/wv5HZAHn509KnPCBbyKU+RD79rQLRTyKVh0hDyr3Yyc?= =?iso-8859-1?Q?+pGKRbE8zBx13ZraYeO5j37lKysur82X7S13nFZ9jkEmbxLHswiiLFxFRk?= =?iso-8859-1?Q?otGWDxYEHw627PocJiLVqt/rRIXWdpKL9ZGguM1CT3yQ5XdepW98y6S5QP?= =?iso-8859-1?Q?oxdUTTDPgoLh7miEEtNMFUVJDKJLd/i1GZ?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ItrbTe7mlxWdc/KguCfKRNC+PTljT4MO7LGexfFImEZloqXKo7k9IJwOPXzB7lDNsClGJuFXkosClweYD0Dl6e833bqQE06K+eUrI+Yw5KHRB8Pe3JfXRrmiIGLZFHCM9qg7T3IE1luoV/o5ybw3PMzjx57bWfZQucmG+L7RRtg2eTxBDdqCz29DNxMdnCVxWmYs0zvUPHC05UWbxZfQQYJzALSQR00N/YEXtSS3KTBkux/Jsn3SwAZSL1IfNdBBZlOBoWSKrAstdnq6aLqPItY+U/m5HpoWiYZVeUsKvbn+s88cVxBcoSJbzKZv+mqLrVtTPC7QfcO2bYiKiLb8CvhRfrDxtm10QcIrnt1rx5Axww7Ie6+FvYm/an3XXAufXafl/Dfx4+ANjZuEtimf/m8Yg0fKIYfmj9RgCi5Od6HzKblgFBvp3LUOhmGK/8EnxOQUcOkVGJxmVSHf2vxTdV/utZL37LVHrk6TIpSI5OXqnN6TNQ3Kv55WtsPLF+bS+efvX2x2KaLpDtVr0ZZGUMnNMWIlDJo2pS2wNmuZKyAbz22lISi8CJJR53PmBNbxvF7xmzFWc5F4m7iX1XaNz8W35CxINvugYA3xBLyrdz0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5232.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24923b4d-2427-433f-3454-08dd9d733295 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 May 2025 23:07:05.1575 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iM76NwJlbcSAMcQ9RWZHs/kOtUWD6rCvmmD3nh5WZSsPnjXH1piFsE6OUtYxq16GB72tWU9eVMcFnCiUmXHcgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS4PPF26D9E501B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-27_11,2025-05-27_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2505160000 definitions=main-2505270195 X-Proofpoint-GUID: xO6EyTD-csMDbITMzQBAyh_nxxWdZrcF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNTI3MDE5NSBTYWx0ZWRfX2bxvLsIVAb8g 4Skf3xh6GQJj2D3qYtTfFKsy37tHASo7Lp6Xt9P3unGra0U3liyZ7uCMiuY3WorhTA9nE/DsVDT 7PWPM0iR3L5s2e+BhjhZawjVNHvaIJX1Ho64xe4UcLOd4vPhAhcZMQonjsk6i8gTsbjhUjdLPLa 8ZO8duqffD9q7eoYcygViJWfHEyCYgElj3qeYDeiUzmN+YL7C11mFbucn5Bi/0tnOklxAUuHcG2 c2TIC+LPjuDvEM0xo0JPvjCo7XsqcozBcDzAHbCFKnyXCSOKJrdz51xW3nh1Cc8x/DPVZSxqyim iQxVGn/f1PZ4OwaR+NpYZNO7aeNRHaHZu+4S7AxukK6YY0qyrPyBomIh0UVSOtjVu1KT5cAKQ3C m/XKQK2OBSAloGnBik5semhrCXIwA2Ve/bYJbT8GMEjcQvtmH2zHM2vq8RgebrHweEJU1e1z X-Authority-Analysis: v=2.4 cv=VskjA/2n c=1 sm=1 tr=0 ts=6836459d b=1 cx=c_pps a=WeWmnZmh0fydH62SvGsd2A==:117 a=WeWmnZmh0fydH62SvGsd2A==:17 a=lCpzRmAYbLLaTzLvsPZ7Mbvzbb8=:19 a=wKuvFiaSGQ0qltdbU6+NXLB8nM8=:19 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=8nJEP1OIZ-IA:10 a=dt9VzEwgFbYA:10 a=GoEa3M9JfhUA:10 a=ooPZTO_I5rYE4NTlgDMA:9 a=wPNLvfGTeEIA:10 X-Proofpoint-ORIG-GUID: xO6EyTD-csMDbITMzQBAyh_nxxWdZrcF X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 78396 Cc: =?iso-8859-1?Q?Elijah_Gabe_P=E9rez?= , "78396@debbugs.gnu.org" <78396@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > Ideally, we'd want to match closing-parens-in-comments with > opening-parens-in-comments. We would? A comment can contain anything. A paren in a comment isn't necessarily a delimiter. "Parsing" comments in an a priori way is misguided, on the whole. What we'd really want is a way _to be able_ to match closing parens (or other closing delimiters, per the major mode) within comments. IOW, this should be an option (and preferably opt-in, not out). Just one opinion. And caveat: I'm not following this thread - piping up in ignorance of context, including knowing what might be important for this bug report.=20 From debbugs-submit-bounces@debbugs.gnu.org Sat May 31 07:48:10 2025 Received: (at 78396) by debbugs.gnu.org; 31 May 2025 11:48:10 +0000 Received: from localhost ([127.0.0.1]:56452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uLKh7-0006dh-O4 for submit@debbugs.gnu.org; Sat, 31 May 2025 07:48:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58526) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uLKh5-0006dH-Rb for 78396@debbugs.gnu.org; Sat, 31 May 2025 07:48:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uLKh0-0000oc-Hs; Sat, 31 May 2025 07:48:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=z52bTJvZCX1lCXDgBhiQN+LSyFOoWRGtAsj7SJWrdR8=; b=rojai6KR0to8EtfRFJhL FUAHaIHhMv3FsRuREFM2aSkvgl5RvkNdY0GGMRLiYAgAmJtUaBzotXKYbECSn/EJSBBwkwPVW8Dzj +O95IfypNd1x59AIDuXUM4VEvPtxojHjGZ/lHJeXvBo4YVfbXhjaZkbaOOc5TuToIvdiGwpg2g1Qx B7L9ME9IlDr39RSp/0+l9VBV+tFBXzudxjRAzYJUcODUsxtkYHHT7+uTYI6E/0dei736c/bzVgpDj WKiyO8rkzKZFjwnL47FYCHJOGgjOEyS2r6biTSWsKDP5huhLSS8no8HSiTHDCGCCOY4HiHDkJSwsN +/eLrL1sq611yg==; Date: Sat, 31 May 2025 14:48:00 +0300 Message-Id: <865xhhrogf.fsf@gnu.org> From: Eli Zaretskii To: Stefan Monnier In-Reply-To: (message from Stefan Monnier on Tue, 27 May 2025 17:02:20 -0400) Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78396 Cc: eg642616@gmail.com, 78396@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: Elijah Gabe PĂ©rez , > 78396@debbugs.gnu.org > Date: Tue, 27 May 2025 17:02:20 -0400 > > Ideally, we'd want to match closing-parens-in-comments with > opening-parens-in-comments. But yes, it's good to refrain from giving > the above bogus highlighting. > > >> I've made an option for disable/control this behavior, by default its > >> disabled but I wonder if this should be activated instead. > > I'm worried by using syntax-ppss-context here: couldn't it sometimes > > significantly slow down the highlighting of parens? Stefan, WDYT? > > `syntax-ppss` is not cheap, but here it's not used inside a loop and > should be called only once per user-interaction so I'm not worried. > I see there are two calls, tho, so I'd try to consolidate them so we call > it at most once. Thanks. Elijah, would you like to update your patch as suggested by Stefan above? From debbugs-submit-bounces@debbugs.gnu.org Sat May 31 10:58:05 2025 Received: (at 78396) by debbugs.gnu.org; 31 May 2025 14:58:05 +0000 Received: from localhost ([127.0.0.1]:58796 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uLNev-0001AP-GG for submit@debbugs.gnu.org; Sat, 31 May 2025 10:58:05 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:10508) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uLNet-00019O-CP for 78396@debbugs.gnu.org; Sat, 31 May 2025 10:58:04 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 396F31000BC; Sat, 31 May 2025 10:57:57 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1748703476; bh=J7SH43CA0nc2HF2kT6XCD6d46WhQ657XqxaObqVVInE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=o3mInaA8nqzI3s27tan/rWzWHlN4jz3exYO4u+wdo4EsgPElhVYAZJGMgkT/U1sHD qBnjCDwuWo6ActoWCEfFcyrtt92ZTGhMl4toEBJ9VqbbXcB33aXCcyuniohTIuD45v 3fG4Gj5NWnA/xT9m9ScWvY02kLd6BF08VIhK/RoyxzLVJ7/6tR/4KE6yAQaK6+ukEv aiezEjQzT32t78oW3Uyp58SwLoEX0MHiF7F9zsqgU9i4ypvrtBLRoLdy6bL5cJ393D lNI2vlJ/jOfmdIo7aSSjjth3RGo2oy4lJbYggl0zNZyJcX+ei1gm1UUAKIuR5qNVbp 8nlt3Nv3T0Iiw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5C86C10002E; Sat, 31 May 2025 10:57:56 -0400 (EDT) Received: from alfajor (unknown [104.247.225.139]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 24DC212028D; Sat, 31 May 2025 10:57:56 -0400 (EDT) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. In-Reply-To: <865xhhrogf.fsf@gnu.org> Message-ID: References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> <865xhhrogf.fsf@gnu.org> Date: Sat, 31 May 2025 10:57:55 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.344 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78396 Cc: eg642616@gmail.com, 78396@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> `syntax-ppss` is not cheap, but here it's not used inside a loop and >> should be called only once per user-interaction so I'm not worried. >> I see there are two calls, tho, so I'd try to consolidate them so we call >> it at most once. > > Thanks. > > Elijah, would you like to update your patch as suggested by Stefan > above? Actually, I now see that the two calls can never happen at the same time, so there's no change necessary. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat May 31 14:21:08 2025 Received: (at 78396) by debbugs.gnu.org; 31 May 2025 18:21:08 +0000 Received: from localhost ([127.0.0.1]:59798 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uLQpM-0006Mh-4n for submit@debbugs.gnu.org; Sat, 31 May 2025 14:21:07 -0400 Received: from mail-oo1-xc43.google.com ([2607:f8b0:4864:20::c43]:59653) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uLQpI-0006Kc-Kj for 78396@debbugs.gnu.org; Sat, 31 May 2025 14:21:02 -0400 Received: by mail-oo1-xc43.google.com with SMTP id 006d021491bc7-6060200710bso1413139eaf.3 for <78396@debbugs.gnu.org>; Sat, 31 May 2025 11:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748715654; x=1749320454; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=x6DxQqkR5zINA0B9S/Ik/MJ6ZxW7w+CU6jg9gy8lgJE=; b=fDG55UiEu0Gf/fGtO+jd1PiGgxEgK5zi7Luqhns6IDi+Va4RWaJBDBXtGDO6QOlsxB XGvs62wUNCVqq1ylcZjqnOq+97MR/WSVX7mCh7Dnp6AqzQcvQfUlSFhvSSwZxVrA+u4O TLTTzp1qfnHg458UoesN5hnbDYPBnBKiSf7rdFyZTd28JHQfCyLeWAuoNHRhGPWosYG3 3ChaenHLt1c/mqFH1p2YTGpBEORDc24nuZPZFAKEeTWE+QjEqNP5zPCnTbvKuSvXLUem pcPQ37iZWEUA5tX8yPdy5aWqoAJS5USQggh2GkArFIrphNLVi5cHYx5dQBUWUZztGnwg AT2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748715654; x=1749320454; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=x6DxQqkR5zINA0B9S/Ik/MJ6ZxW7w+CU6jg9gy8lgJE=; b=jcdH2LSPpn7RnvyEtJfoKLgUH6gyyltVhu3by0SAn3GfqWgQFiCsfhDjiLxKma+HWv I8ejemjmS7vBr0L2UzJHKP1TamD/owdoVECD03uN0ZjnrtzPzX3/w7yqw+6JUtCG4hTi 1i2fK0f/EO8pGJkPG4yahOA08O3cru+apb5nApEvDQUy+OkLzMHkI1hUyY/CsufOzJfx 3jx4ShabHwhXkqTPaWAL+SA6EzFyxsFQyiqUjHmT0VctC8nOQtk1mThbYPeOGAs1/IxN Qu0/sFtwo2FGH7YCeoAhmdjljD8CmuOcd4i5+f/KpZX8rJPps/pOwgNKY1d0idIVN0hx g0jg== X-Forwarded-Encrypted: i=1; AJvYcCVwIanvLs4l1nRwDQTc2u8KyRuSXAoeujPLuEwGiQmGvBAMpkeHCYbgx/3BqXGyC5Ve+PqAzQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxKx2wQDIaKTi9cgqFXw74SwrrhM2RmwHkRZpL/73mN+NltUEQ8 8t0bQ3GHlYAFJC+gbLJauaTc+FO1dGGV4kKLGnRiBhW8bl0ast0RDiQrtxHxE0BB X-Gm-Gg: ASbGnctb9MTbuZP1gRfyW56AqRy5Yilf+8VFXwiFH7spO6LcIoG4deqcMYQSjZXmQWG 1H3e35Iq3UvBjad0mHIoTTuysAYtCxGkHS1MlcGc+aA5R25Z/J455H2rDdR8EH/FaapGbLfJpxA UYC2cbDWIsE9BqDCHV1fbYoEyffvYYEPO96Mk+S+1B8PeUMrqUrAXbRmXZ82ONdSFN2Z521A+BQ D5hmxdjY4XI0Vpgi2m/ab/Q6F7RWbtF5XqPJBkoi7rBnULZIFjM3tfmO9vnw3ZAiAULf+p9NKFJ z3gpSmXD+XWJg519KcA= X-Google-Smtp-Source: AGHT+IF3jKIRpfUz60ZalJ3/XYIIAjXN6MhoTrEyZs9/20siFVZzOS+wpQtU9nvOgneE1XOVprIfhw== X-Received: by 2002:a05:6830:6609:b0:72b:946e:ccc9 with SMTP id 46e09a7af769-73758b64062mr1948710a34.8.1748715654441; Sat, 31 May 2025 11:20:54 -0700 (PDT) Received: from fedora ([2806:10ae:e:8825::1]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-735af82cffdsm987303a34.14.2025.05.31.11.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 May 2025 11:20:53 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: Stefan Monnier Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. In-Reply-To: References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> <865xhhrogf.fsf@gnu.org> Date: Sat, 31 May 2025 12:20:52 -0600 Message-ID: <87tt508wvv.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 78396 Cc: Eli Zaretskii , 78396@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain Stefan Monnier writes: >> Thanks. >> >> Elijah, would you like to update your patch as suggested by Stefan >> above? > > Actually, I now see that the two calls can never happen at the same > time, so there's no change necessary. Anyways I'm sending here an updated version of the patch with Eli's suggestions --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-option-for-not-highlight-parens-inside-comments-.patch >From c4b3ec8111bd56f521129c8a3e9ed209ccf2ac2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= Date: Mon, 12 May 2025 12:04:46 -0600 Subject: [PATCH] Add option for not highlight parens inside comments or strings * lisp/paren.el (show-paren-not-in-comments-or-strings): New user option. (bug#78396) (show-paren-function): Enclose code in `catch` function. * etc/NEWS: Announce changes. * doc/emacs/programs.texi: Document new option. --- doc/emacs/programs.texi | 7 ++ etc/NEWS | 7 ++ lisp/paren.el | 184 ++++++++++++++++++++++------------------ 3 files changed, 117 insertions(+), 81 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index f3cdc1b8e6c..9ceca9129e5 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -1056,6 +1056,13 @@ Matching that contains the opening delimiter, except if the opening delimiter is on its own line, in which case the context includes the previous nonblank line. + +@item +@vindex show-paren-not-in-comments-or-strings +If the value of @code{show-paren-not-in-comments-or-strings} is +@code{all}, delimiters inside comments and strings will not be +highlighted. Otherwise if the value is set to @code{on-mismatch}, the +delimiters mismatched inside comments will not be highlighted. @end itemize @cindex Electric Pair mode diff --git a/etc/NEWS b/etc/NEWS index d1b0189da0c..d498c314ceb 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -471,6 +471,13 @@ setting is an alternative to 'help-at-pt-display-when-idle'. Customize this to nil to disable starting new asynchronous native compilations while AC power is not connected. +** New user option 'show-paren-not-in-comments-or-strings' +This option tells show-paren not to highlight the paren that are inside +a comment or string. If set to 'all', do not highlight the paren that +are inside comments or strings. If set to 'on-mismatch', the paren +mismatched inside comments will not be highlighted. If set to nil (by +default), highlight the paren wherever it is. + * Editing Changes in Emacs 31.1 diff --git a/lisp/paren.el b/lisp/paren.el index 9d7f131e043..986576a8e1d 100644 --- a/lisp/paren.el +++ b/lisp/paren.el @@ -110,6 +110,19 @@ show-paren-context-when-offscreen (const :tag "In child-frame" child-frame)) :version "29.1") +(defcustom show-paren-not-in-comments-or-strings nil + "Do not highlight the paren that are inside a comment or string. +If set to `all', do not highlight the paren that are inside comments +or strings. +If set to `on-mismatch', the paren mismatched inside comments will not be +highlighted. +If set to nil (by default), highlight the paren wherever it is." + :type '(choice + (const :tag "Never highlight" all) + (const :tag "Don't highlight when mismatched" on-mismatch) + (const :tag "Always highlight" nil)) + :version "31.1") + (defvar show-paren--idle-timer nil) (defvar show-paren--overlay (let ((ol (make-overlay (point) (point) nil t))) (delete-overlay ol) ol) @@ -450,88 +463,97 @@ show-paren-function (setq show-paren--last-pos (point))) ;; Found something to highlight. - (let* ((here-beg (nth 0 data)) - (here-end (nth 1 data)) - (there-beg (nth 2 data)) - (there-end (nth 3 data)) - (mismatch (nth 4 data)) - (highlight-expression - (or (eq show-paren-style 'expression) - (and there-beg - (eq show-paren-style 'mixed) - (let ((closest (if (< there-beg here-beg) - (1- there-end) (1+ there-beg)))) - (not (pos-visible-in-window-p closest)))))) - (face - (cond - (mismatch - (if show-paren-ring-bell-on-mismatch - (beep)) - 'show-paren-mismatch) - (highlight-expression 'show-paren-match-expression) - (t 'show-paren-match)))) - ;; - ;; If matching backwards, highlight the closeparen - ;; before point as well as its matching open. - ;; If matching forward, and the openparen is unbalanced, - ;; highlight the paren at point to indicate misbalance. - ;; Otherwise, turn off any such highlighting. - (if (or (not here-beg) - (and (not show-paren-highlight-openparen) - (> here-end (point)) - (<= here-beg (point)) - (integerp there-beg))) - (delete-overlay show-paren--overlay-1) - (move-overlay show-paren--overlay-1 - here-beg here-end (current-buffer)) - ;; Always set the overlay face, since it varies. - (overlay-put show-paren--overlay-1 'priority show-paren-priority) - (overlay-put show-paren--overlay-1 'face face)) - ;; - ;; Turn on highlighting for the matching paren, if found. - ;; If it's an unmatched paren, turn off any such highlighting. - (if (not there-beg) - (delete-overlay show-paren--overlay) - (if highlight-expression - (move-overlay show-paren--overlay - (if (< there-beg here-beg) here-end here-beg) - (if (< there-beg here-beg) there-beg there-end) - (current-buffer)) - (move-overlay show-paren--overlay - there-beg there-end (current-buffer))) - ;; If `show-paren-context-when-offscreen' is non-nil and - ;; point is at a closing paren, show the context around the - ;; opening paren. - (let ((openparen (min here-beg there-beg))) - (when (and show-paren-context-when-offscreen - (not (eql show-paren--last-pos (point))) - (< there-beg here-beg) - ;; Either OPENPAREN position is fully visible... - (not (or (pos-visible-in-window-p openparen) - (let ((dfh4 (* 0.25 (default-font-height))) - (part - (pos-visible-in-window-p openparen - nil t))) - ;; ...or partially visible, and the - ;; invisible part is less than 1/4th - ;; of the default font height - (and (>= (length part) 4) - (< (nth 2 part) dfh4) - (< (nth 3 part) dfh4)))))) - (let ((context (blink-paren-open-paren-line-string - openparen)) - (message-log-max nil)) + (catch 'sp-exit + (let* ((here-beg (nth 0 data)) + (here-end (nth 1 data)) + (there-beg (nth 2 data)) + (there-end (nth 3 data)) + (mismatch (nth 4 data)) + (highlight-expression + (or (eq show-paren-style 'expression) + (and there-beg + (eq show-paren-style 'mixed) + (let ((closest (if (< there-beg here-beg) + (1- there-end) (1+ there-beg)))) + (not (pos-visible-in-window-p closest)))))) + (face (cond - ((eq show-paren-context-when-offscreen 'child-frame) - (show-paren--show-context-in-child-frame context)) - ((eq show-paren-context-when-offscreen 'overlay) - (show-paren--show-context-in-overlay context)) - (show-paren-context-when-offscreen - (minibuffer-message "Matches %s" context)))))) - (setq show-paren--last-pos (point)) - ;; Always set the overlay face, since it varies. - (overlay-put show-paren--overlay 'priority show-paren-priority) - (overlay-put show-paren--overlay 'face face)))))) + (mismatch + (if (and (eq show-paren-not-in-comments-or-strings 'on-mismatch) + (save-excursion + (syntax-ppss-context (syntax-ppss here-beg)))) + (throw 'sp-exit nil)) + (if show-paren-ring-bell-on-mismatch + (beep)) + 'show-paren-mismatch) + (highlight-expression 'show-paren-match-expression) + (t 'show-paren-match)))) + (if (and (eq show-paren-not-in-comments-or-strings 'all) + (save-excursion + (syntax-ppss-context (syntax-ppss here-beg)))) + (throw 'sp-exit nil)) + ;; + ;; If matching backwards, highlight the closeparen + ;; before point as well as its matching open. + ;; If matching forward, and the openparen is unbalanced, + ;; highlight the paren at point to indicate misbalance. + ;; Otherwise, turn off any such highlighting. + (if (or (not here-beg) + (and (not show-paren-highlight-openparen) + (> here-end (point)) + (<= here-beg (point)) + (integerp there-beg))) + (delete-overlay show-paren--overlay-1) + (move-overlay show-paren--overlay-1 + here-beg here-end (current-buffer)) + ;; Always set the overlay face, since it varies. + (overlay-put show-paren--overlay-1 'priority show-paren-priority) + (overlay-put show-paren--overlay-1 'face face)) + ;; + ;; Turn on highlighting for the matching paren, if found. + ;; If it's an unmatched paren, turn off any such highlighting. + (if (not there-beg) + (delete-overlay show-paren--overlay) + (if highlight-expression + (move-overlay show-paren--overlay + (if (< there-beg here-beg) here-end here-beg) + (if (< there-beg here-beg) there-beg there-end) + (current-buffer)) + (move-overlay show-paren--overlay + there-beg there-end (current-buffer))) + ;; If `show-paren-context-when-offscreen' is non-nil and + ;; point is at a closing paren, show the context around the + ;; opening paren. + (let ((openparen (min here-beg there-beg))) + (when (and show-paren-context-when-offscreen + (not (eql show-paren--last-pos (point))) + (< there-beg here-beg) + ;; Either OPENPAREN position is fully visible... + (not (or (pos-visible-in-window-p openparen) + (let ((dfh4 (* 0.25 (default-font-height))) + (part + (pos-visible-in-window-p openparen + nil t))) + ;; ...or partially visible, and the + ;; invisible part is less than 1/4th + ;; of the default font height + (and (>= (length part) 4) + (< (nth 2 part) dfh4) + (< (nth 3 part) dfh4)))))) + (let ((context (blink-paren-open-paren-line-string + openparen)) + (message-log-max nil)) + (cond + ((eq show-paren-context-when-offscreen 'child-frame) + (show-paren--show-context-in-child-frame context)) + ((eq show-paren-context-when-offscreen 'overlay) + (show-paren--show-context-in-overlay context)) + (show-paren-context-when-offscreen + (minibuffer-message "Matches %s" context)))))) + (setq show-paren--last-pos (point)) + ;; Always set the overlay face, since it varies. + (overlay-put show-paren--overlay 'priority show-paren-priority) + (overlay-put show-paren--overlay 'face face))))))) (provide 'paren) -- 2.49.0 --=-=-= Content-Type: text/plain -- - E.G via GNU Emacs and Org. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 01 05:49:51 2025 Received: (at 78396) by debbugs.gnu.org; 1 Jun 2025 09:49:51 +0000 Received: from localhost ([127.0.0.1]:36683 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uLfKA-00005c-3c for submit@debbugs.gnu.org; Sun, 01 Jun 2025 05:49:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49532) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uLfK7-00004s-JJ for 78396@debbugs.gnu.org; Sun, 01 Jun 2025 05:49:48 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uLfK2-0005Y2-5d; Sun, 01 Jun 2025 05:49:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=d/PC50QWE+baVAC8928t/G+R7zZ2yhsfEFsAPHbWxE0=; b=f2WTaqkTSMTkqKFZkzRk kjmfLiQz8NQIxkCDteEcopzweZs38YOKb/VXJPN1Wj1KhahoLhSCaOHPbktihjc+V8KIagpAsJ/y+ yMi/5Rn46FtGf90le8xGkGlap9o1taDjKrLbJGILAxhR8BfSvSMrexDC5o3sg9/F0JlZZvVIxMcvD nicUiGkf7ebuIiMlRkZ8gV/Uek0IDE1xJEYW20tDdTedpQGYCOArjDie5zP2DZGB9ySrAXOsGcFTI 2G/Hvc8ZPeLES71l7lUlbS38hp18YjFt686PCrg/3REWuvMI6ynxsD3d2K8yE1M69031wjL7U9+nP fFWKBhzTGtzTtA==; Date: Sun, 01 Jun 2025 12:49:40 +0300 Message-Id: <861ps3rdu3.fsf@gnu.org> From: Eli Zaretskii To: Elijah Gabe =?utf-8?Q?P=C3=A9rez?= In-Reply-To: <87tt508wvv.fsf@gmail.com> (message from Elijah Gabe =?utf-8?Q?P=C3=A9rez?= on Sat, 31 May 2025 12:20:52 -0600) Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> <865xhhrogf.fsf@gnu.org> <87tt508wvv.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78396 Cc: monnier@iro.umontreal.ca, 78396@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Elijah Gabe PĂ©rez > Cc: Eli Zaretskii , 78396@debbugs.gnu.org > Date: Sat, 31 May 2025 12:20:52 -0600 > > Stefan Monnier writes: > > >> Thanks. > >> > >> Elijah, would you like to update your patch as suggested by Stefan > >> above? > > > > Actually, I now see that the two calls can never happen at the same > > time, so there's no change necessary. > > Anyways I'm sending here an updated version of the patch with Eli's > suggestions Thanks, a few minor comments below: > * lisp/paren.el (show-paren-not-in-comments-or-strings): > New user option. (bug#78396) ^^ Two spaces there, and "Bug" should be capitalized. > (show-paren-function): Enclose code in `catch` function. ^^^^^^^ Please quote 'like this' in log messages. > * doc/emacs/programs.texi: Document new option. Please mention the node where you made the changes (in parentheses, as if it were a function). > +@item > +@vindex show-paren-not-in-comments-or-strings > +If the value of @code{show-paren-not-in-comments-or-strings} is > +@code{all}, delimiters inside comments and strings will not be > +highlighted. Otherwise if the value is set to @code{on-mismatch}, the > +delimiters mismatched inside comments will not be highlighted. ^^^^^^^^^^^^^^^^^^^^^ "mismatched delimiters", i.e. reverse the order. > +** New user option 'show-paren-not-in-comments-or-strings' > +This option tells show-paren not to highlight the paren that are inside ^^^^^ "parens", plural. Also, this is not only about parentheses, right? > +a comment or string. If set to 'all', do not highlight the paren that ^^^^^ "parens" > +are inside comments or strings. If set to 'on-mismatch', the paren ^^^^^ And here. > +mismatched inside comments will not be highlighted. If set to nil (by > +default), highlight the paren wherever it is. ^^^ ^^^^^^^^ We say "(the default)". Also, "highlight the parens wherever they are", in plural again. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 06 01:07:03 2025 Received: (at 78396) by debbugs.gnu.org; 6 Jun 2025 05:07:03 +0000 Received: from localhost ([127.0.0.1]:40813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uNPIE-0005zG-DH for submit@debbugs.gnu.org; Fri, 06 Jun 2025 01:07:03 -0400 Received: from mail-oo1-xc43.google.com ([2607:f8b0:4864:20::c43]:49542) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uNPIC-0005y7-3V for 78396@debbugs.gnu.org; Fri, 06 Jun 2025 01:07:01 -0400 Received: by mail-oo1-xc43.google.com with SMTP id 006d021491bc7-6021e3daeabso787268eaf.3 for <78396@debbugs.gnu.org>; Thu, 05 Jun 2025 22:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749186414; x=1749791214; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6ceVvFYM8cJ2p4H5j7yMW4xAXQuHWmYL0ga5XdzCqNE=; b=ft9932BxgvOaU9DngPf79NtYSHUn057WuO79iCqa+oJsaPWIS+y6+fMY+byQ/SvAQ9 IlkX9veAB6fhtEkmUW9HcrUBxT+3HxwjO2K6uq3F2epaZ94mMFRblEhvAtdgZEddcBzU KHsIS6KpPO22qoeNdQ33yBdakPanxBWmIqGUdWRBrDa2XAkQuHudC9M4F8j1P6fAzvmu Ej2xUdceG5TCivzt3yxHsRj77D+23HVMZ2AaRkhqvxgl1VQGH2VsDPvBqffB8Ex8qTVl Naf9zFAuIjcGLMn28V2L9495yc+F7h6Sx7WSNrjyUTzsDh9nQDsOl3/8g+YpQ3vByXw7 jj4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749186414; x=1749791214; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6ceVvFYM8cJ2p4H5j7yMW4xAXQuHWmYL0ga5XdzCqNE=; b=atUvo+WsKa4y/B40AzaN63rMw/+7qTcg+rHrGOPt1CCSNCiGSmOz8OW08T05a0c8VP c3X+L++QYpW0vzVQvJHpcimo59Gfn6dbD/gvQqFHRAri7rD08JghQ5LgeBnzx7vOaN9F hOaO0kq/brIllRD+j7I0rh8dlbcY6un28vdl2Q9Icwvk7YPG0o4/7iMlvOqyAgV39H6x HQC7r/zqQVKT25rPEFyHkemEBZq1ckvoiNUMG7mfDL+FyITJ/bh4yEd16ay5s8Cb5IPZ bxDudEQk/zmY1IHiWvuXXRxrNJw07ec8TsNoD23HUW1kXDOfB2MO4UW+iQFgc4MI5Wre WH5A== X-Forwarded-Encrypted: i=1; AJvYcCWbUmuX5SgEdimLssBDM1zewBdvpakC8rnClCpWdFBWjloO9n9GEpkFUIOhWnpD49l1+cKA/Q==@debbugs.gnu.org X-Gm-Message-State: AOJu0YwJ6cfTuS1czlX1Cs2LaWmW/+PB94n/aDel/DQVw2B3xRiG0KEn h3gfZOrPpPt7VKBgmfNtf90fMFBVdQEq0D0MrRTcmVpQe0PXnxr4dHfu4svMRG/W X-Gm-Gg: ASbGncsQuWCCEIvsyr/2tioWiAXQL+ckfFfkRgWibkpYpxQt1/HOA/Br8t+5gyv0M3C hUytTSHLmz9sY/W6cWQxaO6xnYpVsUdXNoyMHEjrdVtiVw5/QzHpiXXqev1u1ptNKCNBxeb7I7W jjiAIo+jt9z11s0ClGZWF88gTC+BwzVVyFzlivmIIYk7zqeYsEwRUvn3du+KN124j8twlW/CRYI hibA99m91TCW0dOxDzKA9p/2bbYBU0nYblSD9qLdGoatsW0A8EjOIpOEmc3W+jgew8010PVEIvJ FGpJkB+ip2Y61kat9mI+AIkjG+mBzw== X-Google-Smtp-Source: AGHT+IHbEIB6MtuFAa+jTAQ38J7eNH+8ZlBGosWEenFNMPhz2u7aoRBQluDroPGdvQgCm85AUqUQIA== X-Received: by 2002:a05:6820:1992:b0:603:f981:5fe4 with SMTP id 006d021491bc7-60f3ce462d5mr1392897eaf.1.1749186413893; Thu, 05 Jun 2025 22:06:53 -0700 (PDT) Received: from fedora ([2806:10ae:e:8825::1]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-60f3e66fc6fsm120941eaf.17.2025.06.05.22.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jun 2025 22:06:53 -0700 (PDT) From: =?utf-8?Q?Elijah_Gabe_P=C3=A9rez?= To: Eli Zaretskii Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. In-Reply-To: <861ps3rdu3.fsf@gnu.org> References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> <865xhhrogf.fsf@gnu.org> <87tt508wvv.fsf@gmail.com> <861ps3rdu3.fsf@gnu.org> Date: Thu, 05 Jun 2025 23:06:51 -0600 Message-ID: <87zfelsbkk.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 78396 Cc: monnier@iro.umontreal.ca, 78396@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Anyways I'm sending here an updated version of the patch with Eli's >> suggestions > > Thanks, a few minor comments below: > [...] Thanks, sending fixed version: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-option-for-not-highlight-parens-inside-comments-.patch >From f39f0123c2cdd9c03931e077b3e17658f46d2df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= Date: Mon, 12 May 2025 12:04:46 -0600 Subject: [PATCH] Add option for not highlight parens inside comments or strings * lisp/paren.el (show-paren-not-in-comments-or-strings): New user option. (Bug#78396) (show-paren-function): Enclose code in 'catch' function. * etc/NEWS: Announce changes. * doc/emacs/programs.texi (Matching): Document new option. --- doc/emacs/programs.texi | 7 ++ etc/NEWS | 7 ++ lisp/paren.el | 184 ++++++++++++++++++++++------------------ 3 files changed, 117 insertions(+), 81 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index f3cdc1b8e6c..5363edfdc73 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -1056,6 +1056,13 @@ Matching that contains the opening delimiter, except if the opening delimiter is on its own line, in which case the context includes the previous nonblank line. + +@item +@vindex show-paren-not-in-comments-or-strings +If the value of @code{show-paren-not-in-comments-or-strings} is +@code{all}, delimiters inside comments and strings will not be +highlighted. Otherwise if the value is set to @code{on-mismatch}, the +mismatched delimiters inside comments will not be highlighted. @end itemize @cindex Electric Pair mode diff --git a/etc/NEWS b/etc/NEWS index d1b0189da0c..3e1dc6cc4b1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -471,6 +471,13 @@ setting is an alternative to 'help-at-pt-display-when-idle'. Customize this to nil to disable starting new asynchronous native compilations while AC power is not connected. +** New user option 'show-paren-not-in-comments-or-strings' +This option tells show-paren not to highlight the parens that are inside +a comment or string. If set to 'all', do not highlight the parens that +are inside comments or strings. If set to 'on-mismatch', the parens +mismatched inside comments will not be highlighted. If set to nil (the +default), highlight the parens wherever they are. + * Editing Changes in Emacs 31.1 diff --git a/lisp/paren.el b/lisp/paren.el index 9d7f131e043..986576a8e1d 100644 --- a/lisp/paren.el +++ b/lisp/paren.el @@ -110,6 +110,19 @@ show-paren-context-when-offscreen (const :tag "In child-frame" child-frame)) :version "29.1") +(defcustom show-paren-not-in-comments-or-strings nil + "Do not highlight the paren that are inside a comment or string. +If set to `all', do not highlight the paren that are inside comments +or strings. +If set to `on-mismatch', the paren mismatched inside comments will not be +highlighted. +If set to nil (by default), highlight the paren wherever it is." + :type '(choice + (const :tag "Never highlight" all) + (const :tag "Don't highlight when mismatched" on-mismatch) + (const :tag "Always highlight" nil)) + :version "31.1") + (defvar show-paren--idle-timer nil) (defvar show-paren--overlay (let ((ol (make-overlay (point) (point) nil t))) (delete-overlay ol) ol) @@ -450,88 +463,97 @@ show-paren-function (setq show-paren--last-pos (point))) ;; Found something to highlight. - (let* ((here-beg (nth 0 data)) - (here-end (nth 1 data)) - (there-beg (nth 2 data)) - (there-end (nth 3 data)) - (mismatch (nth 4 data)) - (highlight-expression - (or (eq show-paren-style 'expression) - (and there-beg - (eq show-paren-style 'mixed) - (let ((closest (if (< there-beg here-beg) - (1- there-end) (1+ there-beg)))) - (not (pos-visible-in-window-p closest)))))) - (face - (cond - (mismatch - (if show-paren-ring-bell-on-mismatch - (beep)) - 'show-paren-mismatch) - (highlight-expression 'show-paren-match-expression) - (t 'show-paren-match)))) - ;; - ;; If matching backwards, highlight the closeparen - ;; before point as well as its matching open. - ;; If matching forward, and the openparen is unbalanced, - ;; highlight the paren at point to indicate misbalance. - ;; Otherwise, turn off any such highlighting. - (if (or (not here-beg) - (and (not show-paren-highlight-openparen) - (> here-end (point)) - (<= here-beg (point)) - (integerp there-beg))) - (delete-overlay show-paren--overlay-1) - (move-overlay show-paren--overlay-1 - here-beg here-end (current-buffer)) - ;; Always set the overlay face, since it varies. - (overlay-put show-paren--overlay-1 'priority show-paren-priority) - (overlay-put show-paren--overlay-1 'face face)) - ;; - ;; Turn on highlighting for the matching paren, if found. - ;; If it's an unmatched paren, turn off any such highlighting. - (if (not there-beg) - (delete-overlay show-paren--overlay) - (if highlight-expression - (move-overlay show-paren--overlay - (if (< there-beg here-beg) here-end here-beg) - (if (< there-beg here-beg) there-beg there-end) - (current-buffer)) - (move-overlay show-paren--overlay - there-beg there-end (current-buffer))) - ;; If `show-paren-context-when-offscreen' is non-nil and - ;; point is at a closing paren, show the context around the - ;; opening paren. - (let ((openparen (min here-beg there-beg))) - (when (and show-paren-context-when-offscreen - (not (eql show-paren--last-pos (point))) - (< there-beg here-beg) - ;; Either OPENPAREN position is fully visible... - (not (or (pos-visible-in-window-p openparen) - (let ((dfh4 (* 0.25 (default-font-height))) - (part - (pos-visible-in-window-p openparen - nil t))) - ;; ...or partially visible, and the - ;; invisible part is less than 1/4th - ;; of the default font height - (and (>= (length part) 4) - (< (nth 2 part) dfh4) - (< (nth 3 part) dfh4)))))) - (let ((context (blink-paren-open-paren-line-string - openparen)) - (message-log-max nil)) + (catch 'sp-exit + (let* ((here-beg (nth 0 data)) + (here-end (nth 1 data)) + (there-beg (nth 2 data)) + (there-end (nth 3 data)) + (mismatch (nth 4 data)) + (highlight-expression + (or (eq show-paren-style 'expression) + (and there-beg + (eq show-paren-style 'mixed) + (let ((closest (if (< there-beg here-beg) + (1- there-end) (1+ there-beg)))) + (not (pos-visible-in-window-p closest)))))) + (face (cond - ((eq show-paren-context-when-offscreen 'child-frame) - (show-paren--show-context-in-child-frame context)) - ((eq show-paren-context-when-offscreen 'overlay) - (show-paren--show-context-in-overlay context)) - (show-paren-context-when-offscreen - (minibuffer-message "Matches %s" context)))))) - (setq show-paren--last-pos (point)) - ;; Always set the overlay face, since it varies. - (overlay-put show-paren--overlay 'priority show-paren-priority) - (overlay-put show-paren--overlay 'face face)))))) + (mismatch + (if (and (eq show-paren-not-in-comments-or-strings 'on-mismatch) + (save-excursion + (syntax-ppss-context (syntax-ppss here-beg)))) + (throw 'sp-exit nil)) + (if show-paren-ring-bell-on-mismatch + (beep)) + 'show-paren-mismatch) + (highlight-expression 'show-paren-match-expression) + (t 'show-paren-match)))) + (if (and (eq show-paren-not-in-comments-or-strings 'all) + (save-excursion + (syntax-ppss-context (syntax-ppss here-beg)))) + (throw 'sp-exit nil)) + ;; + ;; If matching backwards, highlight the closeparen + ;; before point as well as its matching open. + ;; If matching forward, and the openparen is unbalanced, + ;; highlight the paren at point to indicate misbalance. + ;; Otherwise, turn off any such highlighting. + (if (or (not here-beg) + (and (not show-paren-highlight-openparen) + (> here-end (point)) + (<= here-beg (point)) + (integerp there-beg))) + (delete-overlay show-paren--overlay-1) + (move-overlay show-paren--overlay-1 + here-beg here-end (current-buffer)) + ;; Always set the overlay face, since it varies. + (overlay-put show-paren--overlay-1 'priority show-paren-priority) + (overlay-put show-paren--overlay-1 'face face)) + ;; + ;; Turn on highlighting for the matching paren, if found. + ;; If it's an unmatched paren, turn off any such highlighting. + (if (not there-beg) + (delete-overlay show-paren--overlay) + (if highlight-expression + (move-overlay show-paren--overlay + (if (< there-beg here-beg) here-end here-beg) + (if (< there-beg here-beg) there-beg there-end) + (current-buffer)) + (move-overlay show-paren--overlay + there-beg there-end (current-buffer))) + ;; If `show-paren-context-when-offscreen' is non-nil and + ;; point is at a closing paren, show the context around the + ;; opening paren. + (let ((openparen (min here-beg there-beg))) + (when (and show-paren-context-when-offscreen + (not (eql show-paren--last-pos (point))) + (< there-beg here-beg) + ;; Either OPENPAREN position is fully visible... + (not (or (pos-visible-in-window-p openparen) + (let ((dfh4 (* 0.25 (default-font-height))) + (part + (pos-visible-in-window-p openparen + nil t))) + ;; ...or partially visible, and the + ;; invisible part is less than 1/4th + ;; of the default font height + (and (>= (length part) 4) + (< (nth 2 part) dfh4) + (< (nth 3 part) dfh4)))))) + (let ((context (blink-paren-open-paren-line-string + openparen)) + (message-log-max nil)) + (cond + ((eq show-paren-context-when-offscreen 'child-frame) + (show-paren--show-context-in-child-frame context)) + ((eq show-paren-context-when-offscreen 'overlay) + (show-paren--show-context-in-overlay context)) + (show-paren-context-when-offscreen + (minibuffer-message "Matches %s" context)))))) + (setq show-paren--last-pos (point)) + ;; Always set the overlay face, since it varies. + (overlay-put show-paren--overlay 'priority show-paren-priority) + (overlay-put show-paren--overlay 'face face))))))) (provide 'paren) -- 2.49.0 --=-=-= Content-Type: text/plain -- - E.G via GNU Emacs and Org. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 07 06:34:12 2025 Received: (at 78396-done) by debbugs.gnu.org; 7 Jun 2025 10:34:13 +0000 Received: from localhost ([127.0.0.1]:47064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uNqsO-0005xv-Il for submit@debbugs.gnu.org; Sat, 07 Jun 2025 06:34:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41446) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uNqsM-0005xh-EX for 78396-done@debbugs.gnu.org; Sat, 07 Jun 2025 06:34:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uNqsH-00088v-4c; Sat, 07 Jun 2025 06:34:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=V+TqLwRyDwoGG/QgO7nXpmKhEgQGqur81Y1Auj/FC1g=; b=iX2z+TcLHtqjA81fhpUr QiNQoIqq8W+CwN+ZSf1+Ohkv2DbzM+Bu1fBCJ7p3yg75iN0xCjYUQ3ro+T8CgEN8TR1GZvsS3CmNk o1HKXobuxFjGV7mqyqhdEU5YzwChweUQNVGioSDlbuxgHD5DPG9frSAf2oMstnQeWg5ho08qxJzrP qc5RgcpeUSkXuUxwSFlWiO284amraPhmML7PezEQE7ebpwyq+aO5ZdcdcKLCJXtI2gPFhc5uXRn2L gnDTDpNbwq9ACG8/CnfUMAckdMk3eUPWs4iV5QSrFG3rAL70F9cnb+YOiSnVamkeYEcgXFULHB+pU 6rgxxe8Yd66FgA==; Date: Sat, 07 Jun 2025 13:34:02 +0300 Message-Id: <86zfejhmcl.fsf@gnu.org> From: Eli Zaretskii To: Elijah Gabe =?utf-8?Q?P=C3=A9rez?= In-Reply-To: <87zfelsbkk.fsf@gmail.com> (message from Elijah Gabe =?utf-8?Q?P=C3=A9rez?= on Thu, 05 Jun 2025 23:06:51 -0600) Subject: Re: bug#78396: [PATCH] Add option for not highlight parens inside comments or strings. References: <87o6vxbr1u.fsf@gmail.com> <867c2fwpxg.fsf@gnu.org> <865xhhrogf.fsf@gnu.org> <87tt508wvv.fsf@gmail.com> <861ps3rdu3.fsf@gnu.org> <87zfelsbkk.fsf@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 78396-done Cc: monnier@iro.umontreal.ca, 78396-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Elijah Gabe PĂ©rez > Cc: monnier@iro.umontreal.ca, 78396@debbugs.gnu.org > Date: Thu, 05 Jun 2025 23:06:51 -0600 > > Eli Zaretskii writes: > > >> Anyways I'm sending here an updated version of the patch with Eli's > >> suggestions > > > > Thanks, a few minor comments below: > > > > [...] > > Thanks, sending fixed version: Thanks, installed on the master branch (with a couple of followup minor changes), and closing the bug.