From unknown Thu Jun 19 14:05:28 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#65824 <65824@debbugs.gnu.org> To: bug#65824 <65824@debbugs.gnu.org> Subject: Status: Indent after open delimiters in verb constructs Reply-To: bug#65824 <65824@debbugs.gnu.org> Date: Thu, 19 Jun 2025 21:05:28 +0000 retitle 65824 Indent after open delimiters in verb constructs reassign 65824 auctex submitter 65824 Arash Esbati severity 65824 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 08 11:45:10 2023 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 11 12:38:56 2023 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 To: Arash Esbati Subject: Re: bug#65824: Indent after open delimiters in verb constructs 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-Debbugs-Envelope-To: 65824 Cc: 65824@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.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 debbugs-submit-bounces@debbugs.gnu.org Fri Sep 15 04:18:23 2023 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 From unknown Thu Jun 19 14:05:28 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 13 Oct 2023 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator