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

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

[debbugs-tracker] bug#26010: closed (Indenting in tabulars and \&)


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#26010: closed (Indenting in tabulars and \&)
Date: Wed, 08 Mar 2017 10:47:02 +0000

Your message dated Wed, 08 Mar 2017 11:45:24 +0100
with message-id <address@hidden>
and subject line Re: bug#26010: Indenting in tabulars and \&
has caused the debbugs.gnu.org bug report #26010,
regarding Indenting in tabulars and \&
to be marked as done.

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


-- 
26010: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=26010
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: Indenting in tabulars and \& Date: Tue, 07 Mar 2017 14:24:15 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2
Hi all,

please consider the following 2 examples and how they are filled: First
example works as expected, second one not because of \&:

--8<---------------cut here---------------start------------->8---
\documentclass{article}

\usepackage{longtable}

\begin{document}

Hit `C-c C-q C-e' inside env:
\begin{tabular}{ll}
  These lines will & appear \\
  at the end
  & of the table     
\end{tabular}
results in:
\begin{tabular}{ll}
  These lines will & appear \\
  at the end
                   & of the table
\end{tabular}

Hit `C-c C-q C-e' inside env:
\begin{tabular}{ll}
  These lines will appear \& 
  at the end \\
  of the &
  table
\end{tabular}
results in:
\begin{tabular}{ll}
  These lines will appear \& 
                             at the end \\
  of the &
           table
\end{tabular}

\end{document}
--8<---------------cut here---------------end--------------->8---

AUCTeX doesn't see the control symbol \&, it just takes the ampersand as
a column separator.  This issue is caused in the last part of the
function `LaTeX-indent-tabular':

--8<---------------cut here---------------start------------->8---
    (cond (...
          (t
           (+ 2
              (let ((any-col (save-excursion
                               (when (re-search-backward "\\\\\\\\\\|&" beg-pos 
t)
                                 (current-column)))))
                (if (and any-col (string= "&" (match-string 0)))
                    any-col
                  beg-col)))))))
--8<---------------cut here---------------end--------------->8---

I'm not aware of any way to fix this *only* by tweaking the regexp here:

    (re-search-backward "\\\\\\\\\\|&" beg-pos t)

Any idea?

Otherwise, I suggest the following change in `LaTeX-indent-tabular':

--8<---------------cut here---------------start------------->8---
    (cond (...
          (t
           (+ 2
              (let ((any-col (save-excursion
                               (when (re-search-backward "\\\\\\\\\\|[^\\]&" 
beg-pos t)
                                 (current-column)))))
                (if (and any-col (string= "&" (substring 
(match-string-no-properties 0) -1)))
                    (1+ any-col)
                  beg-col)))))))
--8<---------------cut here---------------end--------------->8---

Comments welcome.

Best, Arash



--- End Message ---
--- Begin Message --- Subject: Re: bug#26010: Indenting in tabulars and \& Date: Wed, 08 Mar 2017 11:45:24 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2
Mosè Giordano <address@hidden> writes:

> 2017-03-07 14:24 GMT+01:00 Arash Esbati <address@hidden>:
>> AUCTeX doesn't see the control symbol \&, it just takes the ampersand as
>> a column separator.  This issue is caused in the last part of the
>> function `LaTeX-indent-tabular':
>
> Good catch.  I like the solution proposed by Keita, with or without
> `TeX-escaped-p' (but I slightly prefer using these generic functions).
> If you're going to install the fix, please add a test as well.

Hi Mosè,

thanks for your response.  I've installed a patch incl. a test; I went
for Keita's suggestion without `TeX-escaped-p', commit 991b582.  I close
this one then.

Best, Arash


--- End Message ---

reply via email to

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