emacs-bug-tracker
[Top][All Lists]
Advanced

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

[debbugs-tracker] bug#26032: closed (Indenting in tabulars without &)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#26032: closed (Indenting in tabulars without &)
Date: Thu, 09 Mar 2017 14:50:02 +0000

Your message dated Thu, 09 Mar 2017 15:49:24 +0100
with message-id <address@hidden>
and subject line Re: bug#26032: Indenting in tabulars without &
has caused the debbugs.gnu.org bug report #26032,
regarding Indenting in tabulars without &
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
26032: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26032
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: Indenting in tabulars without & Date: Wed, 08 Mar 2017 20:43:15 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2
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



--- End Message ---
--- Begin Message --- Subject: Re: bug#26032: Indenting in tabulars without & Date: Thu, 09 Mar 2017 15:49:24 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2
Ikumi Keita <address@hidden> writes:

>> Alas, `wholenump' is not available in XEmacs.
>
> In XEmacs, `natnump' is available.  It is available in GNU Emacs, too,
> and already used in latex.el and tex-buf.el.

Hi Keita,

great, thanks a lot.  I've just pushed a change with `natnump' to git.
(I forgot to mention the bug number in changelog entry, but that's a
different story).

Best, Arash


--- End Message ---

reply via email to

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