emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/auctex 6b5a7e0 56/95: Improve fallback for indentation


From: Tassilo Horn
Subject: [elpa] externals/auctex 6b5a7e0 56/95: Improve fallback for indentation when & is omitted
Date: Sun, 16 Apr 2017 01:26:54 -0400 (EDT)

branch: externals/auctex
commit 6b5a7e0d058c41763a09c8c292b33cc6b18616ce
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>

    Improve fallback for indentation when & is omitted
    
    * latex.el (LaTeX-hanging-ampersand-position): Improve handling of
    fallback which now respects also intended tabular environments.
    Thanks to Ikumi Keita for testing and providing code.  (bug#26032)
    
    * tests/latex/tabular-in.tex:
    * tests/latex/tabular-out.tex: Add additional test for indented
    tabular.
---
 latex.el                    |  8 +++-----
 tests/latex/tabular-in.tex  | 20 ++++++++++++++++----
 tests/latex/tabular-out.tex | 20 ++++++++++++++++----
 3 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/latex.el b/latex.el
index d91d9c9..443396f 100644
--- a/latex.el
+++ b/latex.el
@@ -6638,11 +6638,9 @@ function would return non-nil and `(match-string 1)' 
would return
             (re-search-forward "[^\\]&" cur-pos t (+ 1 cur-idx))
             ;; If the above searchs fails, i.e. no "&" found,
             ;; (- (current-column) 1) returns -1, which is wrong.  So
-            ;; we check the result first with `natnump' and return
-            ;; (+ 2 beg-col) as fallback.
-            (if (natnump (- (current-column) 1))
-                (- (current-column) 1)
-              (+ 2 beg-col)))
+            ;; we use a fallback (+ 2 beg-col) whenever this happens:
+            (max (- (current-column) 1)
+                 (+ 2 beg-col)))
         (+ 2 beg-col))))))
 
 (defun LaTeX-indent-tabular ()
diff --git a/tests/latex/tabular-in.tex b/tests/latex/tabular-in.tex
index a0b9bf0..8f75ab7 100644
--- a/tests/latex/tabular-in.tex
+++ b/tests/latex/tabular-in.tex
@@ -53,12 +53,12 @@ prompta           & disputando & ne mel, ne
 vel.            & No petentium
 \end{tabular}
 
-% Next table tests filling when & (column separator) character is
-% missing in a row; the function `LaTeX-hanging-ampersand-position' now
-% (March 2017) detects this and has a fallback, see:
+% Next tables test filling when & (column separator) character is
+% missing in a row; the function `LaTeX-hanging-ampersand-position'
+% now (March 2017) detects this and has a fallback, see:
 % https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
 \begin{tabular}{llll}
-\multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei}\\
+\multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei} \\
 & paulo tation honestatis,
 intellegam accommodare ne vim, ut \\
 & mel solum putant atomorum. Posse & dolores has ut, \\
@@ -67,4 +67,16 @@ prompta & disputando & ne mel, ne
 & No petentium
 \end{tabular}
 
+\begin{table}[tbp]
+  \begin{tabular}{llll}
+\multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei} \\
+& paulo tation honestatis,
+intellegam accommodare ne vim, ut \\
+& mel solum putant atomorum. Posse & dolores has ut, \\
+prompta & disputando & ne mel, ne
+\& viderer ceteros vel. \\
+& No petentium
+  \end{tabular}
+\end{table}
+
 \end{document}
diff --git a/tests/latex/tabular-out.tex b/tests/latex/tabular-out.tex
index 316ee99..73521d2 100644
--- a/tests/latex/tabular-out.tex
+++ b/tests/latex/tabular-out.tex
@@ -53,12 +53,12 @@
                                    vel.            & No petentium
 \end{tabular}
 
-% Next table tests filling when & (column separator) character is
-% missing in a row; the function `LaTeX-hanging-ampersand-position' now
-% (March 2017) detects this and has a fallback, see:
+% Next tables test filling when & (column separator) character is
+% missing in a row; the function `LaTeX-hanging-ampersand-position'
+% now (March 2017) detects this and has a fallback, see:
 % https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
 \begin{tabular}{llll}
-  \multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei}\\
+  \multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei} \\
   & paulo tation honestatis,
     intellegam accommodare ne vim, ut \\
   & mel solum putant atomorum. Posse & dolores has ut, \\
@@ -67,4 +67,16 @@
   & No petentium
 \end{tabular}
 
+\begin{table}[tbp]
+  \begin{tabular}{llll}
+    \multicolumn{4}{c}{Lorem ipsum dolor sit amet, ei mei} \\
+    & paulo tation honestatis,
+      intellegam accommodare ne vim, ut \\
+    & mel solum putant atomorum. Posse & dolores has ut, \\
+    prompta & disputando & ne mel, ne
+                           \& viderer ceteros vel. \\
+    & No petentium
+  \end{tabular}
+\end{table}
+
 \end{document}



reply via email to

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