From unknown Sat Jun 14 18:52:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78587: [PATCH] TeX-find-macro-end Resent-From: "Paul D. Nelson" Original-Sender: "Debbugs-submit" Resent-CC: bug-auctex@gnu.org Resent-Date: Sun, 25 May 2025 15:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 78587 X-GNU-PR-Package: auctex X-GNU-PR-Keywords: patch To: 78587@debbugs.gnu.org X-Debbugs-Original-To: bug-auctex@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.174818610015559 (code B ref -1); Sun, 25 May 2025 15:15:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 May 2025 15:15:00 +0000 Received: from localhost ([127.0.0.1]:46744 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uJD3z-00042t-Ss for submit@debbugs.gnu.org; Sun, 25 May 2025 11:15:00 -0400 Received: from lists.gnu.org ([2001:470:142::17]:51836) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uJD3w-00042M-L4 for submit@debbugs.gnu.org; Sun, 25 May 2025 11:14:57 -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 1uJD3q-0003Wb-IR for bug-auctex@gnu.org; Sun, 25 May 2025 11:14:50 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uJD3o-0006Pe-R6 for bug-auctex@gnu.org; Sun, 25 May 2025 11:14:50 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-60410a9c6dcso2295585a12.1 for ; Sun, 25 May 2025 08:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748186087; x=1748790887; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=kgzou8plurF1P/cd7eHTHvAMPx4iUjdsrIMdhFV25Us=; b=bVThj0Uwvrei6m5Flsj67JHVcCGEKQHO9AsmvQepI6ni31GNX0gxVfGJ0XPijYUNSC 7sKl4o6tU4Xl050sTEcAS6tT5SRVQ4ykCqHPSJb1okk+zwL9wmhLDOZ8d1sxUlXxxIvO c7wvddxe2njjEw2JhInk7xkRGCgwE5tGJUm9osGkIMGoENqwfShvZvdf+UAK947uW5G1 UMmkTHnpN1BqzkFg9nb6D3dkE0WmNVdt/hWCpQNJM04zWic421/AfXmwlGLwCluS4Pw8 oyhkKobzzRWdktotKsoy7Frnb6P1uhWLyQ+N/L2VBM88Tk1KSNYkphZX0kDZvxijVUlf OkKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748186087; x=1748790887; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kgzou8plurF1P/cd7eHTHvAMPx4iUjdsrIMdhFV25Us=; b=nb6t5ihPfS7Sivlqh089iTEziIYDg3Unr1Gej8EWYpBnFejrX7JpWjFeNfwHUjGfaT gnnIg+BLB2IQz9bxicKEfVPZb89HE93WHpSopg9/RBjQbNGK9kowg1zQkH5PrUPslnsV ngUbRhrRR9dpYT/E73kOqYfAkVu/uRBsmDkFkysoy9pkFloIJ4UwSwdrI+tHSqIkg3rl 3KVv7EJQjHxZKsmZo1njiCQ2tclZmINV0Doptdc7EYX7ztr7YMW51dE6Sh1w3J2ur6wf j8ksHno6Eh1DT8XuHe3zOhEVvIrIe0r9HzQuqqK0AkLPPi5eOEP3SIxyXyjoQyovSBDy 2i/g== X-Gm-Message-State: AOJu0YzNcxfmXy1ifPtetMsM2Hc8yv311Ebgu2ZFrtEr0f3DIFpAZaej mw+t0ukPy0Q7Azac9cByUTmvjky/DXohvgR68EGh1iHGuiT/+nnoyW/0Sy6P5ZEe X-Gm-Gg: ASbGncudHGp7PY8MYKxZzjaR9QSd7RVn8fawUHNknPv7uMUv1IPIxivm456zQg7gliX rbLdDlUvnfbNmiNBcBSCsIxYISpZcBKIjrF9W3H1GU3YDt5fbsGbLtSr7V/Aj/lvpSjMoWrY+kO GOZJ82H8Mit7UJKSl4EQ1uixPCTFZHpRhdyKp+opmmRoGHFP8bYhMIpSxLGkLtWKYk8UzSyAJCq MWZUv90YCAWpHeH+wUbT11Tn9UyqYGKNb+NCg05CtTZy0ipFCbhwFIsBhycO5lmWffUAsusTTuy kAYX2IiQ/koBMn89wr6GsMj+1n2xTIe/8snvI/UnAOrLq/gUxesHfRCR+w== X-Google-Smtp-Source: AGHT+IFMNCUASRLGrHRwPdMteS6BfufWuL4pu1tw6U4dPKM+IWY1RxcN+hch2bEw1w9CsVdH+Wf5Pw== X-Received: by 2002:a17:907:3faa:b0:ad5:2b4e:bb7b with SMTP id a640c23a62f3a-ad85b0be7a8mr547963366b.15.1748186086407; Sun, 25 May 2025 08:14:46 -0700 (PDT) Received: from localhost ([185.229.154.237]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ad52d06b497sm1526104466b.42.2025.05.25.08.14.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 May 2025 08:14:45 -0700 (PDT) From: "Paul D. Nelson" Date: Sun, 25 May 2025 17:14:44 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=ultrono@gmail.com; helo=mail-ed1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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.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: -0.0 (/) --=-=-= Content-Type: text/plain Hi all, I noticed that TeX-find-macro-end doesn't work as expected way on, e.g., \begin{enumerate}[a)] The issue arose organically when folding such macros. To see the basic issue, evaluate the following in scratch: --8<---------------cut here---------------start------------->8--- (mapcar (lambda (str) (with-temp-buffer (LaTeX-mode) (insert str) (char-to-string (char-before (TeX-find-macro-end-helper (point-min)))))) '("\begin{enumerate}[a]" "\begin{enumerate}[(a)]" "\begin{enumerate}[a)]")) --8<---------------cut here---------------end--------------->8--- This returns ("]" "]" ")") but should return ("]" "]" "]"). The attached patch seems to address the issue by using a stripped syntax table, which seems like a standard approach in tex.el. Any feedback would be welcome. Paul --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-TeX-macro-end-detection-in-some-edge-cases.patch >From c523eeedf567499d98d46c3dd6f04629f96799aa Mon Sep 17 00:00:00 2001 From: Paul Nelson Date: Sun, 25 May 2025 17:11:49 +0200 Subject: [PATCH] Fix TeX macro end detection in some edge cases * tex.el (TeX-find-macro-end-helper): Use TeX-search-syntax-table with square brackets when calling forward-sexp. This fixes parsing of optional arguments containing other unmatched delimiters, such as \begin{enumerate}[a)], where the search would stop at ')' instead of ']'. --- tex.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tex.el b/tex.el index e90252d8..d65599be 100644 --- a/tex.el +++ b/tex.el @@ -5867,7 +5867,8 @@ those will be considered part of it." (looking-at "[ \t]*\\(\\[\\)")))) (goto-char (match-beginning 1)) (condition-case nil - (forward-sexp) + (with-syntax-table (TeX-search-syntax-table ?\[ ?\]) + (forward-sexp)) (scan-error (throw 'found (point))))) ;; Skip over pairs of curly braces ((or (looking-at "[ \t]*\n?[ \t]*{") ; Be conservative: Consider -- 2.39.3 (Apple Git-145) --=-=-=-- From unknown Sat Jun 14 18:52:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78587: [PATCH] TeX-find-macro-end Resent-From: Arash Esbati Original-Sender: "Debbugs-submit" Resent-CC: bug-auctex@gnu.org Resent-Date: Mon, 26 May 2025 13:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78587 X-GNU-PR-Package: auctex X-GNU-PR-Keywords: patch To: "Paul D. Nelson" Cc: 78587@debbugs.gnu.org Received: via spool by 78587-submit@debbugs.gnu.org id=B78587.174826564525765 (code B ref 78587); Mon, 26 May 2025 13:21:02 +0000 Received: (at 78587) by debbugs.gnu.org; 26 May 2025 13:20:45 +0000 Received: from localhost ([127.0.0.1]:56117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uJXkz-0006hV-18 for submit@debbugs.gnu.org; Mon, 26 May 2025 09:20:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34996) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uJXks-0006gs-TW for 78587@debbugs.gnu.org; Mon, 26 May 2025 09:20:39 -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 1uJXkm-00005D-Fv; Mon, 26 May 2025 09:20:32 -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=6XlM8vHxvlDfp8dx/hvxl7NXe738D/eRdAs58X+SIH8=; b=gU1Xub3uQ7vcUu9SZF3R qet99mFlYvSBhR5hI+Z7aRcelczeAwEzdm+2/n/Vpjc4xOBI1TjyKZJn5dCtWZKCqeq7tEjCO0Fvy ov7GR6RIZH5u95GuYCAq+jIHn1r/Pu4V9tvXgh839KPOI7/NeKhX+DC0+i/SfyfoLorTr9IEqUuIw Ik15eER6+bW8Hq+jI40HXQwv98UljSbS6ib9wPnind8E0cDLfGWzZ1eeqS8c9o7CSIkpJ8zF1bQrX FMmjQbFxrptTmntLSCyqVocqwlvbQNqMv9RYmkwvz4D72Abss+BSginaTa8TDJJluTKcKrn48fjkw mvO3VK9iFNL/4A==; From: Arash Esbati In-Reply-To: References: Date: Mon, 26 May 2025 15:20:28 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) 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 Paul, "Paul D. Nelson" writes: > I noticed that TeX-find-macro-end doesn't work as expected way on, e.g., > > \begin{enumerate}[a)] > > The issue arose organically when folding such macros. > > To see the basic issue, evaluate the following in scratch: > > (mapcar > (lambda (str) > (with-temp-buffer > (LaTeX-mode) > (insert str) > (char-to-string (char-before (TeX-find-macro-end-helper (point-min)))))) > '("\begin{enumerate}[a]" > "\begin{enumerate}[(a)]" > "\begin{enumerate}[a)]")) > > This returns ("]" "]" ")") but should return ("]" "]" "]"). > > The attached patch seems to address the issue by using a stripped syntax > table, which seems like a standard approach in tex.el. Any feedback > would be welcome. What do get with your patch when you eval this form: --8<---------------cut here---------------start------------->8--- (mapcar (lambda (str) (with-temp-buffer (LaTeX-mode) (insert str) (char-to-string (char-before (TeX-find-macro-end-helper (point-min)))))) '("\begin{enumerate}[a]" "\begin{enumerate}[(a)]" "\begin{enumerate}[a)]" "\begin{enumerate}[a{]}]")) --8<---------------cut here---------------end--------------->8--- Best, Arash From unknown Sat Jun 14 18:52:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78587: [PATCH] TeX-find-macro-end References: Resent-From: "Paul D. Nelson" Original-Sender: "Debbugs-submit" Resent-CC: bug-auctex@gnu.org Resent-Date: Mon, 26 May 2025 16:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78587 X-GNU-PR-Package: auctex X-GNU-PR-Keywords: patch To: Arash Esbati Cc: 78587@debbugs.gnu.org Received: via spool by 78587-submit@debbugs.gnu.org id=B78587.174827624215250 (code B ref 78587); Mon, 26 May 2025 16:18:02 +0000 Received: (at 78587) by debbugs.gnu.org; 26 May 2025 16:17:22 +0000 Received: from localhost ([127.0.0.1]:58582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uJaVu-0003xt-2X for submit@debbugs.gnu.org; Mon, 26 May 2025 12:17:22 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:54348) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uJaVr-0003xQ-5d for 78587@debbugs.gnu.org; Mon, 26 May 2025 12:17:19 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-ad55d6aeb07so466297466b.0 for <78587@debbugs.gnu.org>; Mon, 26 May 2025 09:17:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748276233; x=1748881033; darn=debbugs.gnu.org; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=rzEtP9RCZxt+4sWJaSDhJCM6llhaGGUStNqOOo/QEaQ=; b=fYS/XfU+WcrqJLV98DmKJq543Hhj99numrJvrIJ3Mer5Mmy4QIQp7StVCcHiYO+u/g 2APN1vzA0sQSWfK1UgHxUm3/YV0SXyl9rB7Ixpq8POkEAFw67LueJV+zEKy3xV1wDuuM ic40gaz/8iscwBracrXlKuuMCXZBKcdHVLNLvzga5RC0R4DAkHY9brLspb3/dh+0Zn1r PMN7fVnICYlf/o74Kv2G1RzwmH94BBi5AtgDi4CD9Arcv8REnpmS/s1hWjC1fqNqwD6u LgMdYDZqJUu+IfJUHlxNwZ4fi/4buNULLhEZ9d1AdyrHM7KY9jGLPRRtHyM5udjaqm48 AS+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748276233; x=1748881033; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rzEtP9RCZxt+4sWJaSDhJCM6llhaGGUStNqOOo/QEaQ=; b=ICG3913utuZihDmqJxSS22hUzKYDvFKsbsllF6CWWhK7ELRmG1m3vSO81kbGYIjrJ1 wJnw9FEagcz9liL9lfqrW9/IMWau/AUlFOK1aQucoBArXc3qah+iDRVuoicx4C3wPdMh yarEVuPmwdGN4k7T1TSy4jnmV2E4PEy58JVIje12Lr3td1gmPh77lzibLi+Z7cFKUGKg qeesaN6I0kRKj0hWxsB7oUh/fYqMV4BAsmfRuxMiP46F0m6FYtpUNGIBsFg0sjkar60a fue7S9VaIF29MaMjK93ZUyX738r+MW8bOl1IZFRFD44y1G2nFVV0nvygNhHyinNeoZDO Mldw== X-Gm-Message-State: AOJu0YwjI7sgTKkC1ABgIAQ0eCoF6qYcdpiixc9fUEzeN5C6a1/nh6A7 LBzwLHq7eY/hC6CjyjV3744COmxkfrzc+Q6qAID9uea96JWTBuGr6EYFKD3axasr X-Gm-Gg: ASbGnctfmRTqsglan3dE4cUzlS4o2CP/hJ0VfPiogf3ozbwrpyUdG/DWtKlxPt8SytY 9Y+u58AhGCAMThMwLBS0oZObvMhutIYuxa2ggGVT8RktMcIMmgvGGhexgAgdn58brH0pfBYIi72 WjgYpCsRMSbOJTUy6G1V8HKsX+j/JHRIzceR/RGqZ0EeWz4D2a67T2AMVNViXwNS//30hxlogjN GuGyDB36Ve1SffQp39sqiXFYZuavN91h8EyOQHcxH3f+OCIEo41zs81rmGYdYxNu4FpqIRkG8nB r2CcB64u1C0Eq7Rn8U97CdBHN7UcrcfYV8OgX5UkHD7UFEu0P5CCn6n5CaCBCoVI1XIaM5cQG/r 9eoaMCDyyk3oR X-Google-Smtp-Source: AGHT+IEQqYI45F18SFGq7qufftlnaFEmXQiN43scS5czC8l77jJj22+fQsF5OcDXKbqe1CuIF3O+Kg== X-Received: by 2002:a17:907:868b:b0:ad2:3d34:e2ad with SMTP id a640c23a62f3a-ad85b0753femr876708466b.26.1748276232480; Mon, 26 May 2025 09:17:12 -0700 (PDT) Received: from localhost (users-1190.st.net.au.dk. [130.225.0.251]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ad5505131f7sm1505912166b.67.2025.05.26.09.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 May 2025 09:17:12 -0700 (PDT) From: "Paul D. Nelson" In-Reply-To: (message from Arash Esbati on Mon, 26 May 2025 15:20:28 +0200) Date: Mon, 26 May 2025 18:17:11 +0200 Message-ID: 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 Arash, > What do get with your patch when you eval this form: > > --8<---------------cut here---------------start------------->8--- > (mapcar > (lambda (str) > (with-temp-buffer > (LaTeX-mode) > (insert str) > (char-to-string (char-before (TeX-find-macro-end-helper (point-min)))))) > '("\begin{enumerate}[a]" > "\begin{enumerate}[(a)]" > "\begin{enumerate}[a)]" > "\begin{enumerate}[a{]}]")) > --8<---------------cut here---------------end--------------->8--- I get the right answer ("]" "]" "]" "]"), but for the wrong reason: evaluating --8<---------------cut here---------------start------------->8--- (mapcar (lambda (str) (with-temp-buffer (LaTeX-mode) (insert str) (char-to-string (char-before (1- (TeX-find-macro-end-helper (point-min))))))) '("\begin{enumerate}[a{]}]")) --8<---------------cut here---------------end--------------->8--- yields ("{"), which shows that it's picking up the wrong "]". I guess this case could be covered by adding "{" and "}" to the syntax table. Can you imagine any further issues with that approach? Thanks, best, Paul From unknown Sat Jun 14 18:52:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78587: [PATCH] TeX-find-macro-end Resent-From: Arash Esbati Original-Sender: "Debbugs-submit" Resent-CC: bug-auctex@gnu.org Resent-Date: Tue, 27 May 2025 12:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78587 X-GNU-PR-Package: auctex X-GNU-PR-Keywords: patch To: "Paul D. Nelson" Cc: 78587@debbugs.gnu.org Received: via spool by 78587-submit@debbugs.gnu.org id=B78587.174834915112923 (code B ref 78587); Tue, 27 May 2025 12:33:01 +0000 Received: (at 78587) by debbugs.gnu.org; 27 May 2025 12:32:31 +0000 Received: from localhost ([127.0.0.1]:39861 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uJtTr-0003MN-A7 for submit@debbugs.gnu.org; Tue, 27 May 2025 08:32:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44292) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uJtTm-0003Lz-8M for 78587@debbugs.gnu.org; Tue, 27 May 2025 08:32:27 -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 1uJtTf-000160-4y; Tue, 27 May 2025 08:32:20 -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=/CrjLcEsDcd19/4WaAnuCd4CyrhYiGzX4IaLsFCTnOA=; b=JcnVzyW4bcmhh3jRjssH xB3m8ZXiRQ9J9Q0XQkOAM4OaTBtsbJ8DzDO+mB7Y/SPOO857QgAe+2GIqTrCaRzfoeUvHhj8/bdQi aiuAxjDGzclhAusLBOeJIxgtpUrHUuv815y0bVxSLKCgLEd7KpLJqWVB7s63V3NJm3vonLh9tunDa +2AT/NRkWyoR/qWqMd7/WGUrWnWmA1nLq1PnmnlzWBxw/o0sgAnahIpH6sy9BJgJ+Bq/t9ZdNIglp ngmX8llPSBPCe3jc8FKtFaV6VOGBoXG4YR/5U+UMnnXP5ippRwpeaiedCvk3VUUZmcm6ly3/1Dx2g G+yVBuoDHJQtQA==; From: Arash Esbati In-Reply-To: References: Date: Tue, 27 May 2025 14:32:11 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) 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 Paul, "Paul D. Nelson" writes: > I get the right answer ("]" "]" "]" "]"), but for the wrong reason: > evaluating > > (mapcar > (lambda (str) > (with-temp-buffer > (LaTeX-mode) > (insert str) > (char-to-string (char-before (1- (TeX-find-macro-end-helper (point-min))))))) > '("\begin{enumerate}[a{]}]")) > > yields ("{"), which shows that it's picking up the wrong "]". This is also what I thought, sorry for not being explicit about it in my last message, was a bit in hurry. > I guess this case could be covered by adding "{" and "}" to the syntax > table. Can you imagine any further issues with that approach? My answer to that exercise is basically this: https://cgit.git.savannah.gnu.org/cgit/auctex.git/commit/font-latex.el?id=7de5f1bbdd186bc84a8bd764e843a308f798210f This was the best I could come up with as I tried to fix this fontification bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57516 I'm not sure if that solution is applicable to the issue at hand. Best, Arash From unknown Sat Jun 14 18:52:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78587: [PATCH] TeX-find-macro-end References: Resent-From: "Paul D. Nelson" Original-Sender: "Debbugs-submit" Resent-CC: bug-auctex@gnu.org Resent-Date: Tue, 27 May 2025 14:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78587 X-GNU-PR-Package: auctex X-GNU-PR-Keywords: patch To: Arash Esbati Cc: 78587@debbugs.gnu.org Received: via spool by 78587-submit@debbugs.gnu.org id=B78587.174835782522723 (code B ref 78587); Tue, 27 May 2025 14:58:02 +0000 Received: (at 78587) by debbugs.gnu.org; 27 May 2025 14:57:05 +0000 Received: from localhost ([127.0.0.1]:42360 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uJvjk-0005uQ-Sx for submit@debbugs.gnu.org; Tue, 27 May 2025 10:57:05 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:55798) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uJvjh-0005th-MT for 78587@debbugs.gnu.org; Tue, 27 May 2025 10:57:02 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-60497d07279so4567050a12.3 for <78587@debbugs.gnu.org>; Tue, 27 May 2025 07:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748357815; x=1748962615; darn=debbugs.gnu.org; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=ok7vP5Q95sV++6KQJEEaFc88XA3HX8GUdN0RQeGXosI=; b=TLqyZjgjl5irlhMBraRoy80pM0LEZXk+D0Pvo8O85xDKduNcbiDJ3pQmAZdRu+XmEl NwgNILzTWjbDORCMLpUKBcxGHpJpwJD88I3hxml3bHdG6ea6veBiwLzq+ytmRo+PQ5vu 3DvapMEe6Lh6ugjdniIrtC6UM3znsKtcrbanya2ygepNgdkwV7OkWsAYcCO2r7JRBRku HOy3cwzjL0qVZlrIyg9SceUjCWJErSSsl9Zm9UhvEyh+gC1pqPdQAtN+oZDxpz7hCZMG cYAy35OltAqusAAB7yfHxVIcJxrrmUNRX3OWFjNUkCIGYcHX2jjaWnPBPymORQsTCAfX 0xpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748357815; x=1748962615; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ok7vP5Q95sV++6KQJEEaFc88XA3HX8GUdN0RQeGXosI=; b=eumdxAQovt7M2CYZthXr0l1C6qK7rq/brYuKJFcwD9EBKHsRW2C4blpdOKugWwhTJJ fAKj1r1odewROhiRRfEqs0sHhPEt7oWYHJDJNMo5gAG/hOPdG0RFQ87Q9AuLpIiUz+2l mxUM0z88HDKp+zaGEEqVaqJH0OGMz8VeNnoGYQcWwS5aHsMpcSp3Mx6rXqrVciDCQ2CQ 9CrBZgAxb7cIc4GbDJhmuNbX3MYq1i5/5PV4cXq7udt3GXifsClQx75SwwnrgBI6TDy9 6lTTPejodaBSu9WC6k2I+enWAQUVrTo+ZbR0O3LZoS+tvKxlnWtvxPkow6rTJixlG+CN PihQ== X-Gm-Message-State: AOJu0YzHAO4XJJHpY7XshO7H5bMHYOoRMQ4D3m/xCUH7WO/Z6sBrhKa4 U8vgWu81qpZ9oIs0CZdMgMxbsD6HtdtMEffy05HvRpd9jPrpllguTrzQ X-Gm-Gg: ASbGnctGztPYIRHK5CmLofjWKBvsVZSSdk1hutZtm3s7LyCs+pmz7/8//7ryz33+21L GIHTdjzHEgnpT7ZNFEkaPHkwnZHvufkrCkwyjHTw0bm+HmaXO9s8pUHn0h2QdIr32A3lCzKwQuh pXAieXRm9m2uW9uBJ68nkX9xLE3bRmSfI89CkQvNyaq0g1VoP2j1vz1C75K7q5vh9ULkYMC16fl TNJTF6VD4YOhaErUj1LBQ0ZYMcWa2GQMAKreMzx4+QLiSS5RNdOlBQdPEVdW/xWnecwAJ35MRzf x1Gg/QzzmtUnT3HgZ8tcZQHb7u1GyGs95c+oS8pP8NBDUH7eLv700oJntLzb/ujnte8znEEQFEy FGw== X-Google-Smtp-Source: AGHT+IGeSkWrqIrqZ1K95kpXaS7zAIP7Jzhq4DM+HQaTRaFvT9aOPVDnBuc5FC71n7xiFmucp0cfPA== X-Received: by 2002:a05:6402:26cc:b0:602:1832:c16c with SMTP id 4fb4d7f45d1cf-602d9af6928mr9101226a12.9.1748357815135; Tue, 27 May 2025 07:56:55 -0700 (PDT) Received: from localhost (users-1190.st.net.au.dk. [130.225.0.251]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-604a556c6f4sm3302432a12.30.2025.05.27.07.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 May 2025 07:56:54 -0700 (PDT) From: "Paul D. Nelson" In-Reply-To: (message from Arash Esbati on Tue, 27 May 2025 14:32:11 +0200) Date: Tue, 27 May 2025 16:56:53 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 (-) --=-=-= Content-Type: text/plain Hi Arash, Thanks, that suggestion is helpful, and seems to take care of the issue you noted. Please find attached an updated patch, to which I also added a test. thanks, best, Paul --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-TeX-macro-end-detection-in-some-edge-cases.patch >From 65906577241bda8d7321d0ef33f0808944d06bed Mon Sep 17 00:00:00 2001 From: Paul Nelson Date: Sun, 25 May 2025 17:11:49 +0200 Subject: [PATCH] Fix TeX macro end detection in some edge cases * tex.el (TeX-find-macro-end-helper): Use TeX-search-syntax-table with square brackets when calling forward-sexp. This fixes parsing of optional arguments containing other unmatched delimiters, such as \begin{enumerate}[a)], where the search would stop at ')' instead of ']'. We take further care to treat examples like \begin{enumerate}[a{]}]. * tests/latex/latex-test.el (TeX-find-macro-end-with-complicated-optional-args): New test concerning the above issue. --- tests/latex/latex-test.el | 13 +++++++++++++ tex.el | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el index b68ea3b8..92b7c530 100644 --- a/tests/latex/latex-test.el +++ b/tests/latex/latex-test.el @@ -761,4 +761,17 @@ check the indentation for optional argument of \\usepackage." (buffer-string) "sab\n"))))) +(ert-deftest TeX-find-macro-end-with-complicated-optional-args () + "Check that end of macro is determined correctly." + ;; (bug#78587) + (dolist (str '("\begin{enumerate}[a]" + "\begin{enumerate}[(a)]" + "\begin{enumerate}[a)]" + "\begin{enumerate}[a{]}]")) + (with-temp-buffer + (insert str) + (LaTeX-mode) + (should (equal (point-max) + (TeX-find-macro-end-helper (point-min))))))) + ;;; latex-test.el ends here diff --git a/tex.el b/tex.el index e90252d8..62fc217b 100644 --- a/tex.el +++ b/tex.el @@ -5866,9 +5866,19 @@ those will be considered part of it." (forward-line 1) (looking-at "[ \t]*\\(\\[\\)")))) (goto-char (match-beginning 1)) - (condition-case nil - (forward-sexp) - (scan-error (throw 'found (point))))) + (goto-char (match-beginning 1)) + ;; Imitate `font-latex-find-matching-close', motivated by + ;; examples like \begin{enumerate}[a{]}]. + (let* ((syntax (TeX-search-syntax-table ?\[ ?\])) + (parse-sexp-ignore-comments + (not (eq major-mode 'docTeX-mode)))) + (modify-syntax-entry ?\{ "|" syntax) + (modify-syntax-entry ?\} "|" syntax) + (modify-syntax-entry ?\\ "/" syntax) + (condition-case nil + (with-syntax-table syntax + (forward-sexp)) + (scan-error (throw 'found (point)))))) ;; Skip over pairs of curly braces ((or (looking-at "[ \t]*\n?[ \t]*{") ; Be conservative: Consider ; only consecutive lines. -- 2.39.3 (Apple Git-145) --=-=-=-- From unknown Sat Jun 14 18:52:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78587: [PATCH] TeX-find-macro-end Resent-From: Arash Esbati Original-Sender: "Debbugs-submit" Resent-CC: bug-auctex@gnu.org Resent-Date: Wed, 28 May 2025 21:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78587 X-GNU-PR-Package: auctex X-GNU-PR-Keywords: patch To: "Paul D. Nelson" Cc: 78587@debbugs.gnu.org Received: via spool by 78587-submit@debbugs.gnu.org id=B78587.17484692195340 (code B ref 78587); Wed, 28 May 2025 21:54:02 +0000 Received: (at 78587) by debbugs.gnu.org; 28 May 2025 21:53:39 +0000 Received: from localhost ([127.0.0.1]:57774 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uKOiR-0001O4-8D for submit@debbugs.gnu.org; Wed, 28 May 2025 17:53:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51542) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uKOiO-0001NZ-0t for 78587@debbugs.gnu.org; Wed, 28 May 2025 17:53:36 -0400 Received: from fencepost.gnu.org ([209.51.188.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKOiH-0005Ox-2k; Wed, 28 May 2025 17:53:30 -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=sMTqeV1WlpY2hKLNZL9RaYpa0olzgGJgr0vQjMM/+nA=; b=ewI3OGU+ny8w4aPzkLm0 retM1IOr8cZr210tvp502BqTuTJ2tvbdkrhx5mmnbNpet/F2lXgY/ZifjG/dCuaXeunDsKwhM0aim eEr1/Z46Z5d1maACP5G8dOR9hmM1WQ4/9JvYblTZU3dGxKW9ifg84jHRFSoI6W8pLyY7pFFtysHdm S+jRZUTAiyRHkQ606DJ1IvfStaN33fanbSmWDMNN6HbAnZgsCDitFi4NGhwKIyDOc2vPJh1uuq1aX iIV/UoiRe5htqL/AIJE0Sq+tKIUShgTGNI339ApzKeA7D9QmDV7vjIHEEWjCzvbh5lGEBBy2KYcjv 7O/LdoP+CIoz4A==; From: Arash Esbati In-Reply-To: References: Date: Wed, 28 May 2025 23:53:00 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) 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 Paul, "Paul D. Nelson" writes: > Thanks, that suggestion is helpful, and seems to take care of the issue > you noted. Great, glad it helped. > Please find attached an updated patch, to which I also added a test. Thanks, I have 2 minor question below. > From 65906577241bda8d7321d0ef33f0808944d06bed Mon Sep 17 00:00:00 2001 > From: Paul Nelson > Date: Sun, 25 May 2025 17:11:49 +0200 > Subject: [PATCH] Fix TeX macro end detection in some edge cases > > * tex.el (TeX-find-macro-end-helper): Use > TeX-search-syntax-table with square brackets when calling > forward-sexp. This fixes parsing of optional arguments > containing other unmatched delimiters, such as > \begin{enumerate}[a)], where the search would stop at ')' > instead of ']'. We take further care to treat examples like > \begin{enumerate}[a{]}]. > > * tests/latex/latex-test.el > (TeX-find-macro-end-with-complicated-optional-args): New test > concerning the above issue. > --- > tests/latex/latex-test.el | 13 +++++++++++++ > tex.el | 16 +++++++++++++--- > 2 files changed, 26 insertions(+), 3 deletions(-) > > diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el > index b68ea3b8..92b7c530 100644 > --- a/tests/latex/latex-test.el > +++ b/tests/latex/latex-test.el > @@ -761,4 +761,17 @@ check the indentation for optional argument of \\usepackage." > (buffer-string) > "sab\n"))))) > > +(ert-deftest TeX-find-macro-end-with-complicated-optional-args () > + "Check that end of macro is determined correctly." > + ;; (bug#78587) > + (dolist (str '("\begin{enumerate}[a]" > + "\begin{enumerate}[(a)]" > + "\begin{enumerate}[a)]" > + "\begin{enumerate}[a{]}]")) > + (with-temp-buffer > + (insert str) > + (LaTeX-mode) > + (should (equal (point-max) > + (TeX-find-macro-end-helper (point-min))))))) > + > ;;; latex-test.el ends here > diff --git a/tex.el b/tex.el > index e90252d8..62fc217b 100644 > --- a/tex.el > +++ b/tex.el > @@ -5866,9 +5866,19 @@ those will be considered part of it." > (forward-line 1) > (looking-at "[ \t]*\\(\\[\\)")))) > (goto-char (match-beginning 1)) > - (condition-case nil > - (forward-sexp) > - (scan-error (throw 'found (point))))) > + (goto-char (match-beginning 1)) > + ;; Imitate `font-latex-find-matching-close', motivated by > + ;; examples like \begin{enumerate}[a{]}]. > + (let* ((syntax (TeX-search-syntax-table ?\[ ?\])) Why do you need `let*' here? `let' seems to do the job, or am I missing something? > + (parse-sexp-ignore-comments > + (not (eq major-mode 'docTeX-mode)))) Can we do (not (derived-mode-p 'docTeX-mode))? Let me know what you think about the above, I can add them when I install the patch. Best, Arash From unknown Sat Jun 14 18:52:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#78587: [PATCH] TeX-find-macro-end References: Resent-From: "Paul D. Nelson" Original-Sender: "Debbugs-submit" Resent-CC: bug-auctex@gnu.org Resent-Date: Thu, 29 May 2025 07:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78587 X-GNU-PR-Package: auctex X-GNU-PR-Keywords: patch To: Arash Esbati Cc: 78587@debbugs.gnu.org Received: via spool by 78587-submit@debbugs.gnu.org id=B78587.174850488823490 (code B ref 78587); Thu, 29 May 2025 07:49:01 +0000 Received: (at 78587) by debbugs.gnu.org; 29 May 2025 07:48:08 +0000 Received: from localhost ([127.0.0.1]:33415 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uKXzk-00066l-1L for submit@debbugs.gnu.org; Thu, 29 May 2025 03:48:08 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:44331) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1uKXzh-00065u-CK for 78587@debbugs.gnu.org; Thu, 29 May 2025 03:48:06 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-acb39c45b4eso84351566b.1 for <78587@debbugs.gnu.org>; Thu, 29 May 2025 00:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748504879; x=1749109679; darn=debbugs.gnu.org; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=6jQcVAMBQaaxD0lTtbYGRQ1D8x/AuB3Xsdy6tFPEm2M=; b=SjIkJqLeMSfbHaCXyxHVhJ1ePSnVPLcSAWN26oNzQPTJVsR80wP0fF7yL9BpqQa4a4 J16mlTfCJk8KxCOQdksY5qm+6v7wu9TmCufOInRayzl2zDnCdBTDcvYScABrZQvsxizB iQJYAxPQQVa6ceRXyz8/Sgr5T67b0NlTIjWVv+6hB+uQcmIZTxfTGYH4imgV6tLG4nM0 q/FVRhD+Vi8dkQUNnQCcsQLgr2FYGJ62EsLNBb/1/NrgRboFQKTIO44+MiBp+buGNPnp xBf0A/wQA7f5G3AInA4leoXPSsL2ViSQm28Vd18MaUiD3256zldrTd9pdYUg8w3TinGS cMNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748504879; x=1749109679; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6jQcVAMBQaaxD0lTtbYGRQ1D8x/AuB3Xsdy6tFPEm2M=; b=jIE3LeySfl0zDzXS2SUZFfWEC5qPHJm5NcraggJMT9jLB6RkEsbjZhX3xA1j7xLQIz xhzoi7JDGnN7IgcPs9XdCPiIgVEcfiYPMvvuk/euzPzTJpZlAN0+S4cFLeAPsTZk0mH5 9icjj6gSjWeM/NKakuAh2IRCXdZAwF1fijUV0N9L55di5ItZhxJyfprprIEvsnIOhEMJ oIGruU4T0rVqiU4/flyI1qpkgexhL4VWzIiZYwiq1wn9YdStP4Gh+FSx07wnjFTD+iAe FqAMdPTXUgmTKO2jABGqLWWcV+J4usdKH0g+I56KJDWUZb40E9QBhcghsZH+CWpY7Z2q 3YCQ== X-Gm-Message-State: AOJu0YzJ7VAAC/9dHNQnp/OlOXsXyEYiZgpiWOBZajtJj+XWcphNvuHQ 24P9l8xSkZXhBSGB9WbTfMW+1fGULPvFIAi1OMuH3tYVdMuIip/8q846W+IwbM05 X-Gm-Gg: ASbGncsvB4E/crUN71suzrbPDEAfxp/L9OVfx54+418LALkJKo62I81uV5+SS3gtItm yv0qr7MKb8pwegPPAUluA1Jn0lzXFRbyYBJAWLpm7Ap1YuR0KpbMRKBgXWkBgf31TLA02Znlin6 HfvBRYrb7EC2TzFg2Ho8sLK6xsgs/w5u+4BFIiAqZ5+HQ3+LTXsLZ0Ez0GYOM26VC0A7jpfqJkC q76biSIqQyZ4VY0t9vwtuXMnt3cvAunn9QCHuwPHzsjdcnk2EFJBdZn9c5Gv0RDSFMRCHZFCecd CROccvbauy77xNwaK/1nVlMzGunmknxb5TAIdOEL4TATFXy70+hSanvh X-Google-Smtp-Source: AGHT+IEbyfQSeLldmUJf19m0RDPURn6KmPm1D0NspTEZ/x5i1GHPD2SVdG0kr4a23LCgpHRjRAZrxw== X-Received: by 2002:a17:906:4fd5:b0:ad5:7234:e4a9 with SMTP id a640c23a62f3a-ad8a1f30fc2mr469896866b.28.1748504878806; Thu, 29 May 2025 00:47:58 -0700 (PDT) Received: from localhost ([185.229.154.43]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ada5d82ddfcsm94155066b.55.2025.05.29.00.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 May 2025 00:47:58 -0700 (PDT) From: "Paul D. Nelson" In-Reply-To: (message from Arash Esbati on Wed, 28 May 2025 23:53:00 +0200) Date: Thu, 29 May 2025 09:47:57 +0200 Message-ID: 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 Arash, I think the answer to both of your questions is "yes". Thanks for your feedback and best, Paul From unknown Sat Jun 14 18:52:42 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: "Paul D. Nelson" Subject: bug#78587: closed (Re: bug#78587: [PATCH] TeX-find-macro-end) Message-ID: References: X-Gnu-PR-Message: they-closed 78587 X-Gnu-PR-Package: auctex X-Gnu-PR-Keywords: patch Reply-To: 78587@debbugs.gnu.org Date: Fri, 30 May 2025 15:07:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1748617622-15090-1" This is a multi-part message in MIME format... ------------=_1748617622-15090-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #78587: [PATCH] TeX-find-macro-end 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 78587@debbugs.gnu.org. --=20 78587: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D78587 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1748617622-15090-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 78587-done) by debbugs.gnu.org; 30 May 2025 15:06:42 +0000 Received: from localhost ([127.0.0.1]:49354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uL1Ji-0003tj-GC for submit@debbugs.gnu.org; Fri, 30 May 2025 11:06:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55032) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uL1Jf-0003tP-Mt for 78587-done@debbugs.gnu.org; Fri, 30 May 2025 11:06:40 -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 1uL1Ja-0001eD-9P; Fri, 30 May 2025 11:06:34 -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=X9KvL1WpmSe+oAEGFCxTAmYRMHGJQ6AfADnAh9cup3I=; b=iD4QKjXzIbYr8ICcnqGE IJyEv8EgLbQB5+bN3LkvcIvazryfXO7pyE9SEt8kh76ZgDmneGxsHr5qv9TC/qx8k7ds/JNkMh8rr WhVIoINk37Qp6Pen5kkbLJw66nAH+MZr8NbdO5u36/zRMU1ExJzxdazcxXnnt+lL7ahp2ALkjDZsg fgUlT878qGS3p+JbKR1X+oy+Fw2ab1L6RzyfddhKu7Fl2idU/a7O1E1mY/aOqQMId18FRwyGL6yae 1dtY9ske85x2w0gmYzdVVASQqOESXlingUDFXX88SuouiWsRf3YBSo3w402WcdKc+qfo64r2NxzX8 aQFIH2a3PPa7Sg==; From: Arash Esbati To: "Paul D. Nelson" Subject: Re: bug#78587: [PATCH] TeX-find-macro-end In-Reply-To: References: Date: Fri, 30 May 2025 17:06:30 +0200 Message-ID: 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: 78587-done Cc: 78587-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 Paul, "Paul D. Nelson" writes: > I think the answer to both of your questions is "yes". Thanks for your > feedback and best, I massaged that change a little and installed it. Many thanks for the change set, closing. Best, Arash ------------=_1748617622-15090-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 25 May 2025 15:15:00 +0000 Received: from localhost ([127.0.0.1]:46744 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uJD3z-00042t-Ss for submit@debbugs.gnu.org; Sun, 25 May 2025 11:15:00 -0400 Received: from lists.gnu.org ([2001:470:142::17]:51836) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uJD3w-00042M-L4 for submit@debbugs.gnu.org; Sun, 25 May 2025 11:14:57 -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 1uJD3q-0003Wb-IR for bug-auctex@gnu.org; Sun, 25 May 2025 11:14:50 -0400 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uJD3o-0006Pe-R6 for bug-auctex@gnu.org; Sun, 25 May 2025 11:14:50 -0400 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-60410a9c6dcso2295585a12.1 for ; Sun, 25 May 2025 08:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748186087; x=1748790887; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=kgzou8plurF1P/cd7eHTHvAMPx4iUjdsrIMdhFV25Us=; b=bVThj0Uwvrei6m5Flsj67JHVcCGEKQHO9AsmvQepI6ni31GNX0gxVfGJ0XPijYUNSC 7sKl4o6tU4Xl050sTEcAS6tT5SRVQ4ykCqHPSJb1okk+zwL9wmhLDOZ8d1sxUlXxxIvO c7wvddxe2njjEw2JhInk7xkRGCgwE5tGJUm9osGkIMGoENqwfShvZvdf+UAK947uW5G1 UMmkTHnpN1BqzkFg9nb6D3dkE0WmNVdt/hWCpQNJM04zWic421/AfXmwlGLwCluS4Pw8 oyhkKobzzRWdktotKsoy7Frnb6P1uhWLyQ+N/L2VBM88Tk1KSNYkphZX0kDZvxijVUlf OkKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748186087; x=1748790887; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=kgzou8plurF1P/cd7eHTHvAMPx4iUjdsrIMdhFV25Us=; b=nb6t5ihPfS7Sivlqh089iTEziIYDg3Unr1Gej8EWYpBnFejrX7JpWjFeNfwHUjGfaT gnnIg+BLB2IQz9bxicKEfVPZb89HE93WHpSopg9/RBjQbNGK9kowg1zQkH5PrUPslnsV ngUbRhrRR9dpYT/E73kOqYfAkVu/uRBsmDkFkysoy9pkFloIJ4UwSwdrI+tHSqIkg3rl 3KVv7EJQjHxZKsmZo1njiCQ2tclZmINV0Doptdc7EYX7ztr7YMW51dE6Sh1w3J2ur6wf j8ksHno6Eh1DT8XuHe3zOhEVvIrIe0r9HzQuqqK0AkLPPi5eOEP3SIxyXyjoQyovSBDy 2i/g== X-Gm-Message-State: AOJu0YzNcxfmXy1ifPtetMsM2Hc8yv311Ebgu2ZFrtEr0f3DIFpAZaej mw+t0ukPy0Q7Azac9cByUTmvjky/DXohvgR68EGh1iHGuiT/+nnoyW/0Sy6P5ZEe X-Gm-Gg: ASbGncudHGp7PY8MYKxZzjaR9QSd7RVn8fawUHNknPv7uMUv1IPIxivm456zQg7gliX rbLdDlUvnfbNmiNBcBSCsIxYISpZcBKIjrF9W3H1GU3YDt5fbsGbLtSr7V/Aj/lvpSjMoWrY+kO GOZJ82H8Mit7UJKSl4EQ1uixPCTFZHpRhdyKp+opmmRoGHFP8bYhMIpSxLGkLtWKYk8UzSyAJCq MWZUv90YCAWpHeH+wUbT11Tn9UyqYGKNb+NCg05CtTZy0ipFCbhwFIsBhycO5lmWffUAsusTTuy kAYX2IiQ/koBMn89wr6GsMj+1n2xTIe/8snvI/UnAOrLq/gUxesHfRCR+w== X-Google-Smtp-Source: AGHT+IFMNCUASRLGrHRwPdMteS6BfufWuL4pu1tw6U4dPKM+IWY1RxcN+hch2bEw1w9CsVdH+Wf5Pw== X-Received: by 2002:a17:907:3faa:b0:ad5:2b4e:bb7b with SMTP id a640c23a62f3a-ad85b0be7a8mr547963366b.15.1748186086407; Sun, 25 May 2025 08:14:46 -0700 (PDT) Received: from localhost ([185.229.154.237]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ad52d06b497sm1526104466b.42.2025.05.25.08.14.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 May 2025 08:14:45 -0700 (PDT) From: "Paul D. Nelson" To: bug-auctex@gnu.org Subject: [PATCH] TeX-find-macro-end Date: Sun, 25 May 2025 17:14:44 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::533; envelope-from=ultrono@gmail.com; helo=mail-ed1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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.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: -0.0 (/) --=-=-= Content-Type: text/plain Hi all, I noticed that TeX-find-macro-end doesn't work as expected way on, e.g., \begin{enumerate}[a)] The issue arose organically when folding such macros. To see the basic issue, evaluate the following in scratch: --8<---------------cut here---------------start------------->8--- (mapcar (lambda (str) (with-temp-buffer (LaTeX-mode) (insert str) (char-to-string (char-before (TeX-find-macro-end-helper (point-min)))))) '("\begin{enumerate}[a]" "\begin{enumerate}[(a)]" "\begin{enumerate}[a)]")) --8<---------------cut here---------------end--------------->8--- This returns ("]" "]" ")") but should return ("]" "]" "]"). The attached patch seems to address the issue by using a stripped syntax table, which seems like a standard approach in tex.el. Any feedback would be welcome. Paul --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-TeX-macro-end-detection-in-some-edge-cases.patch >From c523eeedf567499d98d46c3dd6f04629f96799aa Mon Sep 17 00:00:00 2001 From: Paul Nelson Date: Sun, 25 May 2025 17:11:49 +0200 Subject: [PATCH] Fix TeX macro end detection in some edge cases * tex.el (TeX-find-macro-end-helper): Use TeX-search-syntax-table with square brackets when calling forward-sexp. This fixes parsing of optional arguments containing other unmatched delimiters, such as \begin{enumerate}[a)], where the search would stop at ')' instead of ']'. --- tex.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tex.el b/tex.el index e90252d8..d65599be 100644 --- a/tex.el +++ b/tex.el @@ -5867,7 +5867,8 @@ those will be considered part of it." (looking-at "[ \t]*\\(\\[\\)")))) (goto-char (match-beginning 1)) (condition-case nil - (forward-sexp) + (with-syntax-table (TeX-search-syntax-table ?\[ ?\]) + (forward-sexp)) (scan-error (throw 'found (point))))) ;; Skip over pairs of curly braces ((or (looking-at "[ \t]*\n?[ \t]*{") ; Be conservative: Consider -- 2.39.3 (Apple Git-145) --=-=-=-- ------------=_1748617622-15090-1--