auctex-devel
[Top][All Lists]
Advanced

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

Re: fill breaks verbatim macros not followed with spaces


From: Arash Esbati
Subject: Re: fill breaks verbatim macros not followed with spaces
Date: Thu, 07 Jul 2022 12:12:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50

Arash Esbati <arash@gnu.org> writes:

> The only thing remaining is how to suppress the actual indenting in this
> part of the `LaTeX-indent-line':
>
>     (save-excursion
>       (cond ((and fill-prefix
>                   (TeX-in-line-comment)
>                   (eq major-mode 'doctex-mode))
>              ;; If point is in a line comment in `doctex-mode' we only
>              ;; consider the inner indentation.
>              (let ((inner-indent (LaTeX-indent-calculate 'inner)))
>                (when (/= (LaTeX-current-indentation 'inner) inner-indent)
>                  (LaTeX-indent-inner-do inner-indent))))

Having another look, I think it is much easier to suppress the
inner-indent calculation for verbatim environments like this and don't
touch the fill-prefix calculation:

--8<---------------cut here---------------start------------->8---
diff --git a/latex.el b/latex.el
index e8b81409..7d75e9c6 100644
--- a/latex.el
+++ b/latex.el
@@ -3910,7 +3910,10 @@ value."
      4 t)
     (,(concat (regexp-quote TeX-esc)
               "\\(begin\\|end\\)[ \t]*{\\(macro\\|environment\\)\\*?}")
-     0 nil))
+     0 nil)
+    (,(concat (regexp-quote TeX-esc)
+              "\\(begin\\|end\\)[ \t]*{verbatim\\*?}")
+     0 t))
   "List of items which should have a fixed inner indentation.
 The items consist of three parts.  The first is a regular
 expression which should match the respective string.  The second
@@ -4042,10 +4045,15 @@ Lines starting with an item is given an extra 
indentation of
                  (concat (match-string 0) (TeX-comment-padding-string))))))
     (save-excursion
       (cond ((and fill-prefix
+                  (eq major-mode 'doctex-mode)
                   (TeX-in-line-comment)
-                  (eq major-mode 'doctex-mode))
+                  (not (member (LaTeX-current-environment)
+                               (LaTeX-verbatim-environments))))
              ;; If point is in a line comment in `doctex-mode' we only
-             ;; consider the inner indentation.
+             ;; consider the inner indentation.  An exception is when
+             ;; we're inside a verbatim environment where we don't
+             ;; want to touch the indentation, notably with a
+             ;; fill-prefix "% " (see above)
              (let ((inner-indent (LaTeX-indent-calculate 'inner)))
                (when (/= (LaTeX-current-indentation 'inner) inner-indent)
                  (LaTeX-indent-inner-do inner-indent))))
@@ -4057,16 +4065,16 @@ Lines starting with an item is given an extra 
indentation of
              (let ((inner-indent (LaTeX-indent-calculate 'inner))
                    (outer-indent (LaTeX-indent-calculate 'outer)))
                (when (/= (LaTeX-current-indentation 'inner) inner-indent)
-                   (LaTeX-indent-inner-do inner-indent))
+                 (LaTeX-indent-inner-do inner-indent))
                (when (/= (LaTeX-current-indentation 'outer) outer-indent)
-                   (LaTeX-indent-outer-do outer-indent))))
+                 (LaTeX-indent-outer-do outer-indent))))
             (t
              ;; The default is to adapt whitespace before any
              ;; non-whitespace character, i.e. to do outer
              ;; indentation.
              (let ((outer-indent (LaTeX-indent-calculate 'outer)))
                (when (/= (LaTeX-current-indentation 'outer) outer-indent)
-                   (LaTeX-indent-outer-do outer-indent))))))
+                 (LaTeX-indent-outer-do outer-indent))))))
     (when (< (current-column) (save-excursion
                                 (LaTeX-back-to-indentation) (current-column)))
       (LaTeX-back-to-indentation))))
--8<---------------cut here---------------end--------------->8---

Best, Arash



reply via email to

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