auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] [PATCH] Add indentation for tabular environment


From: Tassilo Horn
Subject: Re: [AUCTeX] [PATCH] Add indentation for tabular environment
Date: Fri, 11 Oct 2013 11:16:03 +0200
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 (gnu/linux)

Oleh <address@hidden> writes:

>> `cl-count' is only available in Emacs 24, but we'd like to stay
>> compatible with at least Emacs 22 and also XEmacs 21.  (Using `count'
>> from `cl' also won't work, because we don't want to require that at
>> runtime.)
>
> This one I'm not really sure how to fix. Maybe you know hot to do it?
> Would dash.el work?

No.  I'm not sure if it works with XEmacs (probably not), and adding a
dependency just for one single function isn't justified.  So I'd just
define a compat function `TeX-count' (in tex.el), which can just be an
alias to `cl-count' if that's bound.  E.g., something like this:

--8<---------------cut here---------------start------------->8---
(if (fboundp 'cl-count)
    (defalias 'TeX-count 'cl-count
      "Return the number of occurences of the ITEM in LIST.
The tests are done with `eql'.")
  (defun TeX-count (item list)
    "Return the number of occurences of the ITEM in LIST.
The tests are done with `eql'."
    (let ((c 0))
      (setq list (memql item list))
      (while list
        (setq c (1+ c))
        (setq list (memql item (cdr list))))
      c)))
--8<---------------cut here---------------end--------------->8---

> +(defvar LaTeX-tabularlike-alist '("tabular" "tabular*" "align" "align*"))
> +
> +(defvar LaTeX-tabularlike-end (format "\\\\end{%s}" (regexp-opt 
> LaTeX-tabularlike-alist)))

That doesn't work if style files add their environment names to
`LaTeX-tabularlike-alist' later on, because then they'd also need to
recompute the end-regexp.  I'd omit the global regexp variable and just
compute the regular expression every time in `LaTeX-indent-tabular'.

And I'd name the list `LaTeX-tabular-like-env-list'.  It's not an alist,
so list instead of alist, and the env makes it clear that there are
environment names in it.

Please also add a docstring, e.g.,

  "A list of tabular-like environments.
Those are indented specially using `LaTeX-indent-tabular'
so that columns line up nicely."

Bye,
Tassilo



reply via email to

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