bug-auctex
[Top][All Lists]
Advanced

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

bug#61400: Different filling for verbatim macros


From: Arash Esbati
Subject: bug#61400: Different filling for verbatim macros
Date: Wed, 15 Feb 2023 18:36:44 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Keita,

Ikumi Keita <ikumi@ikumi.que.jp> writes:

> Thanks, now I'd like to push the attached commit. Any comments welcome.

Thanks, I think I have one minor comment.  Take this example:

--8<---------------cut here---------------start------------->8---
\documentclass{article}

\usepackage{fvextra}

\begin{document}
\Verb{pre\cmd{test}p*st}
\end{document}
--8<---------------cut here---------------end--------------->8---

Put point on * and try

  M-: (LaTeX-verbatim-macro-boundaries) RET

which returns nil.  This is due to this part of the function:

  (when (string= delimiter TeX-grop)
    (setq delimiter (concat delimiter TeX-grcl)))
  (goto-char (1+ end))
  (skip-chars-forward (concat "^" delimiter))

What I don't understand it why the code does:

  (when (string= delimiter TeX-grop)
    (setq delimiter (concat delimiter TeX-grcl)))

which is "^{}"; I would have expected "^}" only because using \verb{foo{
is just asking for trouble and not officially supported IIRC.  Even with
delimiter being "^}", this form:

  (skip-chars-forward (concat "^" delimiter))

means stop before the first "}" which is not far enough in case we have
balanced braces in the argument (and only such are allowed).  So I
suggest we change this part of the code like this:

--8<---------------cut here---------------start------------->8---
diff --git a/latex.el b/latex.el
index 03795cf4..bbb8cd29 100644
--- a/latex.el
+++ b/latex.el
@@ -3830,10 +3830,14 @@ of the macro argument as cons."
           ;; both the opening and the closing brace as an end marker.
           ;; Like that the function should work for \verb|...| as well
           ;; as for \url{...}.
-          (when (string= delimiter TeX-grop)
-            (setq delimiter (concat delimiter TeX-grcl)))
-          (goto-char (1+ end))
-          (skip-chars-forward (concat "^" delimiter))
+          (if (string= delimiter TeX-grop)
+              (progn
+                (goto-char end)
+                (re-search-forward "{[^}{]*\\(?:{[^}{]*}[^}{]*\\)*}"
+                                   (line-end-position) t)
+                (backward-char))
+            (goto-char (1+ end))
+            (skip-chars-forward (concat "^" delimiter)))
           (when (<= orig (point))
             (if arg-only
                 (cons (1+ end) (point))
--8<---------------cut here---------------end--------------->8---

Then we only need to solve the fontification issue ;-)  WDYT?

Best, Arash





reply via email to

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