GNU bug report logs -
#26032
Indenting in tabulars without &
Previous Next
Reported by: Arash Esbati <arash <at> gnu.org>
Date: Wed, 8 Mar 2017 19:45:02 UTC
Severity: normal
Done: Arash Esbati <arash <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#26032: Indenting in tabulars without &
which was filed against the auctex package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 26032 <at> debbugs.gnu.org.
--
26032: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
Ikumi Keita <ikumi <at> ikumi.que.jp> writes:
> I think that the sign test can be omitted altogether if we use `max'.
> That is, just
>
> (max (+ 2 beg-col)
> (- (current-column) 1)))
>
> is enough. This code does the expected job on my machine.
Hi Keita,
yes, of course. Thank you very much. I've push a new change set to
git. Next try to close this bug.
Best, Arash
[Message part 3 (message/rfc822, inline)]
Hi all,
please consider the following 2 examples and how the column separator is
filled, both do not work as expected:
--8<---------------cut here---------------start------------->8---
\documentclass{article}
\begin{document}
\begin{tabular}{ll}
\multicolumn{2}{c}{These lines will} `M-RET here'
\end{tabular}
results in:
\begin{tabular}{ll}
\multicolumn{2}{c}{These lines will} `M-RET here' \\
&
\end{tabular}
And
\begin{tabular}{ll}
\multicolumn{2}{c}{These lines will} \\
& `C-c C-q C-e here'
\end{tabular}
results in:
\begin{tabular}{ll}
\multicolumn{2}{c}{These lines will} \\
& `C-c C-q C-e here'
\end{tabular}
\end{document}
--8<---------------cut here---------------end--------------->8---
The issue is in `LaTeX-hanging-ampersand-position' where
(- (current-column) 1) returns a negative value if no "[^\\]&" is found:
--8<---------------cut here---------------start------------->8---
(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))))))
--8<---------------cut here---------------end--------------->8---
My suggest to guard (- (current-column) 1) with a (wholenump ...) and
return (+ 2 beg-col) as fallback if the test is not true:
--8<---------------cut here---------------start------------->8---
(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))
(if (wholenump (- (current-column) 1))
(- (current-column) 1)
(+ 2 beg-col)))
(+ 2 beg-col))))))
--8<---------------cut here---------------end--------------->8---
Any comments welcome.
Best, Arash
This bug report was last modified 8 years and 72 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.