[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 72a6943 54/95: Add fallback for indentation when
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 72a6943 54/95: Add fallback for indentation when & is omitted |
Date: |
Sun, 16 Apr 2017 01:26:54 -0400 (EDT) |
branch: externals/auctex
commit 72a694360771d15393939b904d39a2054c34788c
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Add fallback for indentation when & is omitted
* latex.el (LaTeX-hanging-ampersand-position): Add fallback for
indentation if the row searched does not contain a column
separator &.
* tests/latex/tabular-in.tex:
* tests/latex/tabular-out.tex: Add filling test for missing & in
row.
---
latex.el | 27 +++++++++++++++++----------
tests/latex/latex-test.el | 2 ++
tests/latex/tabular-in.tex | 14 ++++++++++++++
tests/latex/tabular-out.tex | 14 ++++++++++++++
4 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/latex.el b/latex.el
index f034207..d91d9c9 100644
--- a/latex.el
+++ b/latex.el
@@ -6627,16 +6627,23 @@ function would return non-nil and `(match-string 1)'
would return
(defun LaTeX-hanging-ampersand-position ()
"Return indent column for a hanging ampersand (i.e. ^\\s-*&)."
- (destructuring-bind (beg-pos . beg-col)
- (LaTeX-env-beginning-pos-col)
- (let* ((cur-pos (point)))
- (save-excursion
- (if (re-search-backward "\\\\\\\\" beg-pos t)
- (let ((cur-idx (TeX-how-many "[^\\]&" (point) cur-pos)))
- (goto-char beg-pos)
- (re-search-forward "[^\\]&" cur-pos t (+ 1 cur-idx))
- (- (current-column) 1))
- (+ 2 beg-col))))))
+ (destructuring-bind
+ (beg-pos . beg-col)
+ (LaTeX-env-beginning-pos-col)
+ (let* ((cur-pos (point)))
+ (save-excursion
+ (if (re-search-backward "\\\\\\\\" beg-pos t)
+ (let ((cur-idx (TeX-how-many "[^\\]&" (point) cur-pos)))
+ (goto-char beg-pos)
+ (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)))
+ (+ 2 beg-col))))))
(defun LaTeX-indent-tabular ()
"Return indent column for the current tabular-like line."
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index e6e70eb..69939cf 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -63,6 +63,8 @@ line and from another directory."
;; Test for detecting \& in a table cell added; see
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26010
+;; Test for missing & in row added; see
+;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
(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 61c0a92..a0b9bf0 100644
--- a/tests/latex/tabular-in.tex
+++ b/tests/latex/tabular-in.tex
@@ -53,4 +53,18 @@ 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:
+% https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
+\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{document}
diff --git a/tests/latex/tabular-out.tex b/tests/latex/tabular-out.tex
index 9310b0a..316ee99 100644
--- a/tests/latex/tabular-out.tex
+++ b/tests/latex/tabular-out.tex
@@ -53,4 +53,18 @@
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:
+% https://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
+\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{document}
- [elpa] externals/auctex 43b07d9 70/95: Use `TeX-line-number-at-pos' further for older emacsen, (continued)
- [elpa] externals/auctex 43b07d9 70/95: Use `TeX-line-number-at-pos' further for older emacsen, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 9e7f21e 69/95: Use compatibility function `TeX-line-number-at-pos' for older emacsen, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex c360b9a 76/95: Adapt fontification for \lstinline, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 2182b6f 30/95: Append "lstlisting" to `LaTeX-label-alist', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 337ce76 33/95: Add new keys for package version 4.00, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 6bb49cc 39/95: * style/subfiles.el (LaTeX-subfiles-class-options): New function., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 4992f5a 46/95: Make customization to face specification to appear in, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex c97a654 48/95: * tex-ispell.el (TeX-ispell-skip-setcdr): Add entry for filecontents package., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 0dc770d 42/95: Prevent infinite loop in TeX-command-expand, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 841d4cb 45/95: Unify treatment of face argument over the relevant functions., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 72a6943 54/95: Add fallback for indentation when & is omitted,
Tassilo Horn <=
- [elpa] externals/auctex 8fdc494 63/95: ; Provide fallback when no locale information is available, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 9d12a06 66/95: Use `TeX-replace-regexp-in-string' in style files, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a71a72d 74/95: Add support for Japanese font command, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 88a7563 81/95: Fix last improvement for skipping of inline verbatim macros, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 16f24dd 90/95: ; * style/minted.el (LaTeX-minted-add-syntactic-keywords-extra): Fix doc string., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a46c307 77/95: Improve fontification of verbatim macros in style/minted.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 83890d6 86/95: Update package options in style/amsmath.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 94b227d 89/95: * doc/auctex.texi (Selecting a Command): Document `TeX-ispell-verb-delimiters'., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 4225941 59/95: Modify `TeX-expand-list-builtin' instead of `TeX-expand-list', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 79361b5 58/95: Add new style/fvextra.el, Tassilo Horn, 2017/04/16