auctex-devel
[Top][All Lists]
Advanced

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

Re: [SOLVED by Arash]


From: Arash Esbati
Subject: Re: [SOLVED by Arash]
Date: Mon, 10 Jan 2022 12:45:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50

Hi Uwe,

Uwe Brauer <oub@mat.ucm.es> writes:

> I just found 
> https://tex.stackexchange.com/questions/557959/emacs-auctex-tabular-vertical-alignment-of-cells
>
> That is very nice. Thanks Arash.

Sure, welcome.

> Why not including this function in AucTeX?

FTR, this is a more polished version of the function:

--8<---------------cut here---------------start------------->8---
(defun LaTeX-align-tabular ()
  (interactive)
  (let ((env (LaTeX-current-environment)))
    ;; Extra usage check that we don't mess the entire document:
    (unless (string= env "document")
      (let ((s (make-marker))
            (e (make-marker)))
        (set-marker s (save-excursion
                        (LaTeX-find-matching-begin)
                        (line-beginning-position 2)))
        (set-marker e (save-excursion
                        (LaTeX-find-matching-end)
                        (line-end-position 0)))
        ;; Check if the environment has an entry in
        ;; `LaTeX-indent-environment-list' otherwise
        ;; `LaTeX-fill-environment' will play hovoc
        (when (assoc env LaTeX-indent-environment-list)
          (LaTeX-fill-environment nil))
        (whitespace-cleanup-region s e)
        (align-regexp s e "\\(\\s-*\\)&" 1 1 t)
        (align-regexp s e "\\(\\s-*\\)\\\\\\\\")
        (set-marker s nil)
        (set-marker e nil)))))
--8<---------------cut here---------------end--------------->8---

AUCTeX has a policy not to rely on external package at run-time.  The
function above relies on align.el; with the `whitespace-cleanup-region'
part whitespace.el is also involved (That call can be removed, IMO).

The function above might be handy, but it breaks the current policy.  If
we don't include it, we could start documenting this sort of things in
the manual.

What do others think?

Best, Arash



reply via email to

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