Oleh <[email protected]> writes:

Hi Oleh,

> I wrote some indentation for the tabular environment.
> Let me know if it's alright.
> I attach a patch and a test.

I like that table formatting.  Nice!

As you might know, as official GNU project AUCTeX only incorporates code
from people that have assigned copyright to the FSF.  Are you Oleh
Krehel from Ukraine?  If so, then you have already done that.  If not,
are you willing to sign a CA?  Then I'll send you the request off-list.

> +(defun re-search-backward->column (str)
> +  (save-excursion
> +    (if (re-search-backward str nil t)
> +        (current-column)
> +      0)))

New functions/variable should always be namespace-prefixed.  But I don't
see why you need that function anyhow.  If the re-search-backward
doesn't find a match, then we're not in a table and calling
`LaTeX-indent-tabular' shouldn't have been called in the first place.

> +(defun LaTeX-indent-tabular ()
> +  (let ((beg-col (re-search-backward->column "\\\\begin{tabular}")))

It would be good if it would work with other tabular-like environments,
too.  Say tabular*, tabularx, tabulary, longtable, and the math
tabular-alikes array, align, eqnarray, cases, ...

You should be able to figure out the nearest surrounding tabular-like
environment with `LaTeX-current-environment'.

> +    (if (looking-at "\\\\end{tabular}")
> +        beg-col
> +      (+ 2
> +         (if (looking-at "\\\\\\\\")
> +             beg-col
> +           (let ((any-col (re-search-backward->column
> +                           "\\\\begin{tabular}\\|\\\\\\\\\\|&")))
> +             (if (equal "&" (match-string-no-properties 0))

Better use `string-equal' here.

> +                 any-col
> +               beg-col)))))))
> +
>  (provide 'latex)
>  
>  ;;; latex.el ends here

Bye,
Tassilo


_______________________________________________
auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex

Reply via email to