auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for possible bug in TeX-find-macro-end-helper


From: Enrico Flor
Subject: Patch for possible bug in TeX-find-macro-end-helper
Date: Sun, 18 Dec 2022 21:13:38 +0000

Hi everyone,

I was meaning to use TeX-find-macro-end-helper from tex.el for a package
I am working on, but I found it has a behavior which strikes me as
undesirable.  It's of course very possible that I am missing something,
but here is the current behavior in 13.1 and in master.

Here are the positions where point lands after evaluating

   (goto-char (TeX-find-macro-end-helper))

with point at the beginning of the macro:

\macro{first}
{second}█

\macro{first}█
  {second}

\macro{first} % comment
  {second}█

What happens is that whitespace in the second line is skipped only if
the previous line ended with some comment.  Since "second" is parsed as
the second argument of the macro in all three cases, I think
TeX-find-macro-end-helper should return the position right after
`{second}` in all three cases.  If this is correct, this patch should
implement the behavior (it just modifies two regexps in that function).

Please forgive the noise if this is in fact an intentional behavior.

Attachment: signature.asc
Description: PGP signature

>From ce6f13201f1dd1bb711069fc85fcccbba8447ce8 Mon Sep 17 00:00:00 2001
From: Enrico Flor <nericoflor@gmail.com>
Date: Sun, 18 Dec 2022 15:59:40 -0500
Subject: [PATCH] Change two regexps in TeX-find-macro-end-helper

---
 tex.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tex.el b/tex.el
index 9671d5f3..72734a00 100644
--- a/tex.el
+++ b/tex.el
@@ -5631,7 +5631,7 @@ those will be considered part of it."
         (while (not (eobp))
           (cond
            ;; Skip over pairs of square brackets
-           ((or (looking-at "[ \t]*\n?\\(\\[\\)") ; Be conservative: Consider
+           ((or (looking-at "[ \t]*\n?[ \t]*\\(\\[\\)") ; Be conservative: 
Consider
                                         ; only consecutive lines.
                 (and (looking-at (concat "[ \t]*" TeX-comment-start-regexp))
                      (save-excursion
@@ -5642,7 +5642,7 @@ those will be considered part of it."
                 (forward-sexp)
               (scan-error (throw 'found (point)))))
            ;; Skip over pairs of curly braces
-           ((or (looking-at "[ \t]*\n?{") ; Be conservative: Consider
+           ((or (looking-at "[ \t]*\n?[ \t]*{") ; Be conservative: Consider
                                         ; only consecutive lines.
                 (and (looking-at (concat "[ \t]*" TeX-comment-start-regexp))
                      (save-excursion
--
2.38.1

Attachment: publickey - enrico@eflor.net - ffbd1445.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]