[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26010: Indenting in tabulars and \&
From: |
Arash Esbati |
Subject: |
bug#26010: Indenting in tabulars and \& |
Date: |
Tue, 07 Mar 2017 20:27:46 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 |
Ikumi Keita <address@hidden> writes:
>> Otherwise, I suggest the following change in `LaTeX-indent-tabular':
>> (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)))))))
>> Comments welcome.
Hi Keita,
many thanks for checking and your response.
> I think the form `(string= ...)' can be replaced with
> `(= ?& (char-before (match-end 0)))'.
Yes, this is even more elegant.
> And here is another solution keeping the regexp untouched:
> (cond (...
> (t
> (+ 2
> (let ((any-col (save-excursion
> (when (and
> (re-search-backward "\\\\\\\\\\|&"
> beg-pos t)
> (= ?& (char-after))
> (not (TeX-escaped-p)))
> (current-column)))))
> (or any-col
> beg-col))))))))
>
> Using `TeX-escaped-p' might be overkilling since we allow loose usages of
> (looking-at "\\\\\\\\") and (re-search-backward "\\\\\\\\... ) in this
> function.
I agree, this seems overkill. `[^\\]' is also used in
`LaTeX-hanging-ampersand-position' which is right above
`LaTeX-indent-tabular' in latex. el -- these functions would look more
in line with `[^\\]' in regexp. This is the current suggestion:
(cond (...
(t
(+ 2
(let ((any-col (save-excursion
(when (re-search-backward "\\\\\\\\\\|[^\\]&"
beg-pos t)
(current-column)))))
(if (and any-col (= ?& (char-before (match-end 0)))
(1+ any-col)
beg-col)))))))
Best, Arash