branch: externals/auctex commit 991b582e7e27bc9e1b28415da32980e93eb0eca5 Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Detect \& in tabular cells when filling * latex.el (LaTeX-indent-tabular): Search backward for any ampersands not escaped with a backslash, i.e. control symbol \&, and return the adjusted value. Thanks to Ikumi Keita for his perceptive comments on the implementation. (bug#26010) * tests/latex/tabular-in.tex: * tests/latex/tabular-out.tex: Add test for table filling with \& in cells. --- latex.el | 6 +++--- tests/latex/latex-test.el | 2 ++ tests/latex/tabular-in.tex | 15 +++++++++++++++ tests/latex/tabular-out.tex | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/latex.el b/latex.el index 318362f..f034207 100644 --- a/latex.el +++ b/latex.el @@ -6664,10 +6664,10 @@ function would return non-nil and `(match-string 1)' would return (t (+ 2 (let ((any-col (save-excursion - (when (re-search-backward "\\\\\\\\\\|&" beg-pos t) + (when (re-search-backward "\\\\\\\\\\|[^\\]&" beg-pos t) (current-column))))) - (if (and any-col (string= "&" (match-string 0))) - any-col + (if (and any-col (= ?& (char-before (match-end 0)))) + (1+ any-col) beg-col)))))))) (provide 'latex) diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el index 205af00..e6e70eb 100644 --- a/tests/latex/latex-test.el +++ b/tests/latex/latex-test.el @@ -61,6 +61,8 @@ line and from another directory." 'tabular-count-ampersands/out "tabular-count-ampersands-out.tex") +;; Test for detecting \& in a table cell added; see +;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26010 (ert-deftest LaTeX-indent-tabular () (should (string= (with-temp-buffer diff --git a/tests/latex/tabular-in.tex b/tests/latex/tabular-in.tex index a8be333..61c0a92 100644 --- a/tests/latex/tabular-in.tex +++ b/tests/latex/tabular-in.tex @@ -38,4 +38,19 @@ detraxit & no. & Ne sea doming & deserunt. 8 & 9 \end{align} + +% Next table tests filling with a control symbol \& inside a cell; the +% function `LaTeX-indent-tabular' now (March 2017) detects \&, see: +% https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26010 +\begin{tabular}{llll} +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{document} diff --git a/tests/latex/tabular-out.tex b/tests/latex/tabular-out.tex index cd5b708..9310b0a 100644 --- a/tests/latex/tabular-out.tex +++ b/tests/latex/tabular-out.tex @@ -38,4 +38,19 @@ 8 & 9 \end{align} + +% Next table tests filling with a control symbol \& inside a cell; the +% function `LaTeX-indent-tabular' now (March 2017) detects \&, see: +% https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26010 +\begin{tabular}{llll} + 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{document}