From unknown Sun Jun 22 07:54:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65824: Indent after open delimiters in verb constructs Resent-From: Arash Esbati Original-Sender: "Debbugs-submit" Resent-CC: bug-auctex@gnu.org Resent-Date: Fri, 08 Sep 2023 15:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65824 X-GNU-PR-Package: auctex X-GNU-PR-Keywords: To: 65824@debbugs.gnu.org X-Debbugs-Original-To: auctex-bugs Received: via spool by submit@debbugs.gnu.org id=B.169418791023114 (code B ref -1); Fri, 08 Sep 2023 15:46:02 +0000 Received: (at submit) by debbugs.gnu.org; 8 Sep 2023 15:45:10 +0000 Received: from localhost ([127.0.0.1]:45254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qedfS-00060j-6V for submit@debbugs.gnu.org; Fri, 08 Sep 2023 11:45:10 -0400 Received: from lists.gnu.org ([2001:470:142::17]:41460) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qedfP-000609-Ru for submit@debbugs.gnu.org; Fri, 08 Sep 2023 11:45:08 -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 1qedfG-0006uN-U9 for bug-auctex@gnu.org; Fri, 08 Sep 2023 11:44:59 -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 1qedfF-0004WC-L3 for bug-auctex@gnu.org; Fri, 08 Sep 2023 11:44:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=shhMfQcdRGhZAwdxG+j4QHJ4dxJwPlsGlj0sRQqYMIg=; b=miEcsXTnTGoTyV J5gbwAn8cMHAE+dqGIJXWrE5VsZvuln9qbFrBfgNcb0pC/4CJPlQtpGgm+WPmvBUFaR33o7OojTWg pNIjZHbPYvPoQn3bSvJd/F9h1LHstaW0jFqK+foEjXEITcSrPHVav2PEM6vEJkf6BuRS31ajy0f28 BaiCvjP6kk5Q0nNIQghDaAXfCDIgWAd84DiqlT8a9nJA1rQ/MnKU5+UWuG3aiHBJgihHQ8EC6z9rN 4n6fUEfRtzaOZRtZi4ehlS15uw5TM6yQOPcGDwxk/OAVLKcurNHtFQWkGPJoELPkDqCRQ9RWJMOqQ E2Qc5JbA/z5BafsxiBOA==; From: Arash Esbati Date: Fri, 08 Sep 2023 17:44:26 +0200 Message-ID: <8634zofz51.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) 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.0 (-) Hi all, please consider this small file: --8<---------------cut here---------------start------------->8--- \documentclass{article} \begin{document} \verb|foo{bar| foo bar baz \end{document} --8<---------------cut here---------------end--------------->8--- Now do 'M-x mark-whole-buffer RET M-x indent-region RET' and you get: --8<---------------cut here---------------start------------->8--- \documentclass{article} \begin{document} \verb|foo{bar| foo bar baz \end{document} --8<---------------cut here---------------end--------------->8--- I think the issue is within `TeX-brace-count-line' which doesn't look for opening/closing delimiters in verbatim text. My simple minded solution looks like this: --8<---------------cut here---------------start------------->8--- diff --git a/tex.el b/tex.el index a85b8ef9..30118384 100644 --- a/tex.el +++ b/tex.el @@ -5485,21 +5485,22 @@ additional characters." '(?\{ ?\} ?\\)) (TeX-in-comment)))) (forward-char) - (cond ((memq char (append - TeX-indent-open-delimiters - '(?\{))) - (setq count (+ count TeX-brace-indent-level))) - ((memq char (append - TeX-indent-close-delimiters - '(?\}))) - (setq count (- count TeX-brace-indent-level))) - ((eq char ?\\) - (when (< (point) limit) - ;; ?\\ in verbatim constructs doesn't escape - ;; the next char - (unless (TeX-verbatim-p) - (forward-char)) - t)))))) + ;; If inside a verbatim construct, just return t and + ;; proceed, otherwise start counting: + (if (TeX-verbatim-p) + t + (cond ((memq char (append + TeX-indent-open-delimiters + '(?\{))) + (setq count (+ count TeX-brace-indent-level))) + ((memq char (append + TeX-indent-close-delimiters + '(?\}))) + (setq count (- count TeX-brace-indent-level))) + ((eq char ?\\) + (when (< (point) limit) + (forward-char) + t))))))) count))) ;;; Navigation --8<---------------cut here---------------end--------------->8--- Any better ideas how to do this? My only concern is that `LaTeX-verbatim-p' (which is used by `TeX-verbatim-p') uses `save-match-data' which is known to be expensive. I don't have any benchmarks, but there might be performance hit when indenting/filling large portions of text. Best, Arash From unknown Sun Jun 22 07:54:41 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65824: Indent after open delimiters in verb constructs Resent-From: Ikumi Keita Original-Sender: "Debbugs-submit" Resent-CC: bug-auctex@gnu.org Resent-Date: Mon, 11 Sep 2023 16:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65824 X-GNU-PR-Package: auctex X-GNU-PR-Keywords: To: Arash Esbati Cc: 65824@debbugs.gnu.org Received: via spool by 65824-submit@debbugs.gnu.org id=B65824.16944503365624 (code B ref 65824); Mon, 11 Sep 2023 16:39:01 +0000 Received: (at 65824) by debbugs.gnu.org; 11 Sep 2023 16:38:56 +0000 Received: from localhost ([127.0.0.1]:54652 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfjw7-0001Se-OF for submit@debbugs.gnu.org; Mon, 11 Sep 2023 12:38:55 -0400 Received: from smtp1a.inetd.co.jp ([210.129.88.11]:42648) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qfjw5-0001SR-9T for 65824@debbugs.gnu.org; Mon, 11 Sep 2023 12:38:54 -0400 Received: from localhost (42-144-34-11.rev.home.ne.jp [42.144.34.11]) by smtp1a.inetd.co.jp (Postfix) with ESMTPA id B3AC05C; Tue, 12 Sep 2023 01:38:46 +0900 (JST) From: Ikumi Keita In-reply-to: <8634zofz51.fsf@gnu.org> References: <8634zofz51.fsf@gnu.org> Comments: In-reply-to Arash Esbati message dated "Fri, 08 Sep 2023 17:44:26 +0200." X-Mailer: MH-E 8.6+git; nmh 1.7.1; Emacs 29.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <43567.1694450322.1@localhost> Date: Tue, 12 Sep 2023 01:38:42 +0900 Message-ID: <43568.1694450322@localhost> X-Spam-Score: 0.0 (/) 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.0 (-) Hi Arash, >>>>> Arash Esbati writes: > Any better ideas how to do this? That seems a sensible solution to me. > My only concern is that `LaTeX-verbatim-p' (which is used by > `TeX-verbatim-p') uses `save-match-data' which is known to be > expensive. I don't have any benchmarks, but there might be performance > hit when indenting/filling large portions of text. Hmm, it really matters, I think there are two actions that we can take: 1. Remove `save-match-data' from `LaTeX-verbatim-p' and announce the removal in changes.texi. Grepping over the current source briefly, the only usage of (La)TeX-verbatim-p that needs to preserve the match data is `LaTeX-search-forward-comment-start'. So wrapping it with `save-match-data' in that function is easy. (In addition, `LaTeX-search-forward-comment-start' is only used as a value of `TeX-search-forward-comment-start-function', which is only used in `TeX-search-forward-comment-start', which isn't used at all now.) 2. Implement LaTeX mode function for `indent-region'. Now AUCTeX has "line-by-line" indent function only, but there are apparent overheads when AUCTeX indents a region. We could implement region-oriented indent function which works with less overheads. Regards, Ikumi Keita #StandWithUkraine #StopWarInUkraine From unknown Sun Jun 22 07:54:41 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Arash Esbati Subject: bug#65824: closed (Re: bug#65824: Indent after open delimiters in verb constructs) Message-ID: References: <86led7j1eg.fsf@gnu.org> <8634zofz51.fsf@gnu.org> X-Gnu-PR-Message: they-closed 65824 X-Gnu-PR-Package: auctex Reply-To: 65824@debbugs.gnu.org Date: Fri, 15 Sep 2023 08:19:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1694765942-32058-1" This is a multi-part message in MIME format... ------------=_1694765942-32058-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #65824: Indent after open delimiters in verb constructs which was filed against the auctex package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 65824@debbugs.gnu.org. --=20 65824: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D65824 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1694765942-32058-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 65824-done) by debbugs.gnu.org; 15 Sep 2023 08:18:23 +0000 Received: from localhost ([127.0.0.1]:42004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qh41u-0008K5-N4 for submit@debbugs.gnu.org; Fri, 15 Sep 2023 04:18:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qh41t-0008Js-0E for 65824-done@debbugs.gnu.org; Fri, 15 Sep 2023 04:18:22 -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 1qh41f-0008SJ-90; Fri, 15 Sep 2023 04:18:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=YKP5JFOSCJITiO6axYfXdPW90K2nzCjXle24HNc5kjs=; b=UNBBI4ny1MR6sZ1w7XeQ rs20tGxLAvxU6BAl8Ob64BdTbXDJqdn6IjkuTWCe5uy0YDJloAr6ma/RpZdR57T+7nrYjheW4LrEA +6vGIlWK8FceXpWe7T4saIv0UaFi4eCIhTmEqLzDM2+q67EdOtXAheDk5Zv/nZDYJ8vn/CPXp1bnk 7bL5reMpaXtZ7DqNBLQu3/KwBKQuQsPVLXbbcVR2bvgFTQib5pHrgEc4wLkRCb4lmK/n88SLiSahI i0deSViid7SVHUi42Q9qT2yTdSb+G4JEnBTfdVZdGKYDU9slYWfZrThrTLG54tWPviYkw5lcQYQq2 T1j9anXROCwm4A==; From: Arash Esbati To: Ikumi Keita Subject: Re: bug#65824: Indent after open delimiters in verb constructs In-Reply-To: <43568.1694450322@localhost> (Ikumi Keita's message of "Tue, 12 Sep 2023 01:38:42 +0900") References: <8634zofz51.fsf@gnu.org> <43568.1694450322@localhost> Date: Fri, 15 Sep 2023 10:17:43 +0200 Message-ID: <86led7j1eg.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65824-done Cc: 65824-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 (---) Hi Keita, Ikumi Keita writes: > Hmm, it really matters, I think there are two actions that we can take: > 1. Remove `save-match-data' from `LaTeX-verbatim-p' and announce the > removal in changes.texi. Grepping over the current source briefly, > the only usage of (La)TeX-verbatim-p that needs to preserve the match > data is `LaTeX-search-forward-comment-start'. So wrapping it with > `save-match-data' in that function is easy. (In addition, > `LaTeX-search-forward-comment-start' is only used as a value of > `TeX-search-forward-comment-start-function', which is only used in > `TeX-search-forward-comment-start', which isn't used at all now.) > 2. Implement LaTeX mode function for `indent-region'. Now AUCTeX has > "line-by-line" indent function only, but there are apparent overheads > when AUCTeX indents a region. We could implement region-oriented > indent function which works with less overheads. Thanks for your response. I pushed that change (a228137f66). I'd say let's wait and see if users complain about any performance regressions, we can then implement one of your suggestions above. For now, I'm closing this report. Best, Arash ------------=_1694765942-32058-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 8 Sep 2023 15:45:10 +0000 Received: from localhost ([127.0.0.1]:45254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qedfS-00060j-6V for submit@debbugs.gnu.org; Fri, 08 Sep 2023 11:45:10 -0400 Received: from lists.gnu.org ([2001:470:142::17]:41460) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qedfP-000609-Ru for submit@debbugs.gnu.org; Fri, 08 Sep 2023 11:45:08 -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 1qedfG-0006uN-U9 for bug-auctex@gnu.org; Fri, 08 Sep 2023 11:44:59 -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 1qedfF-0004WC-L3 for bug-auctex@gnu.org; Fri, 08 Sep 2023 11:44:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=shhMfQcdRGhZAwdxG+j4QHJ4dxJwPlsGlj0sRQqYMIg=; b=miEcsXTnTGoTyV J5gbwAn8cMHAE+dqGIJXWrE5VsZvuln9qbFrBfgNcb0pC/4CJPlQtpGgm+WPmvBUFaR33o7OojTWg pNIjZHbPYvPoQn3bSvJd/F9h1LHstaW0jFqK+foEjXEITcSrPHVav2PEM6vEJkf6BuRS31ajy0f28 BaiCvjP6kk5Q0nNIQghDaAXfCDIgWAd84DiqlT8a9nJA1rQ/MnKU5+UWuG3aiHBJgihHQ8EC6z9rN 4n6fUEfRtzaOZRtZi4ehlS15uw5TM6yQOPcGDwxk/OAVLKcurNHtFQWkGPJoELPkDqCRQ9RWJMOqQ E2Qc5JbA/z5BafsxiBOA==; From: Arash Esbati To: auctex-bugs Subject: Indent after open delimiters in verb constructs Date: Fri, 08 Sep 2023 17:44:26 +0200 Message-ID: <8634zofz51.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) 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: -1.0 (-) Hi all, please consider this small file: --8<---------------cut here---------------start------------->8--- \documentclass{article} \begin{document} \verb|foo{bar| foo bar baz \end{document} --8<---------------cut here---------------end--------------->8--- Now do 'M-x mark-whole-buffer RET M-x indent-region RET' and you get: --8<---------------cut here---------------start------------->8--- \documentclass{article} \begin{document} \verb|foo{bar| foo bar baz \end{document} --8<---------------cut here---------------end--------------->8--- I think the issue is within `TeX-brace-count-line' which doesn't look for opening/closing delimiters in verbatim text. My simple minded solution looks like this: --8<---------------cut here---------------start------------->8--- diff --git a/tex.el b/tex.el index a85b8ef9..30118384 100644 --- a/tex.el +++ b/tex.el @@ -5485,21 +5485,22 @@ additional characters." '(?\{ ?\} ?\\)) (TeX-in-comment)))) (forward-char) - (cond ((memq char (append - TeX-indent-open-delimiters - '(?\{))) - (setq count (+ count TeX-brace-indent-level))) - ((memq char (append - TeX-indent-close-delimiters - '(?\}))) - (setq count (- count TeX-brace-indent-level))) - ((eq char ?\\) - (when (< (point) limit) - ;; ?\\ in verbatim constructs doesn't escape - ;; the next char - (unless (TeX-verbatim-p) - (forward-char)) - t)))))) + ;; If inside a verbatim construct, just return t and + ;; proceed, otherwise start counting: + (if (TeX-verbatim-p) + t + (cond ((memq char (append + TeX-indent-open-delimiters + '(?\{))) + (setq count (+ count TeX-brace-indent-level))) + ((memq char (append + TeX-indent-close-delimiters + '(?\}))) + (setq count (- count TeX-brace-indent-level))) + ((eq char ?\\) + (when (< (point) limit) + (forward-char) + t))))))) count))) ;;; Navigation --8<---------------cut here---------------end--------------->8--- Any better ideas how to do this? My only concern is that `LaTeX-verbatim-p' (which is used by `TeX-verbatim-p') uses `save-match-data' which is known to be expensive. I don't have any benchmarks, but there might be performance hit when indenting/filling large portions of text. Best, Arash ------------=_1694765942-32058-1--