[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] [PATCH 1/3] Parse env's defined with `\lstnewenvironm
From: |
Tassilo Horn |
Subject: |
Re: [AUCTeX-devel] [PATCH 1/3] Parse env's defined with `\lstnewenvironment'. |
Date: |
Mon, 01 Jun 2015 17:12:04 +0200 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) |
Arash Esbati <address@hidden> writes:
> Tassilo Horn <address@hidden> writes:
>
> Hi Tassilo,
>
>> I've applied all three PATCHES.
>
> Thank you very much for applying them. Unfortunately, I made a
> mistake here and this particular patch lacks a feature: It doesn't
> care about the optional argument. And I can't see that AUCTeX cares
> about opt. argument for user defined environments as opposed to
> commands, e.g.:
>
> \documentclass[a4paper]{article}
>
> \usepackage{color}
>
> \newenvironment{colorenv}[2][red]{\color{#1}#2}{}
> \newcommand{\colorcmd}[2][red]{{\color{#1}#2}}
> \newcommand{\colorcmds}[3][red]{\color{#1}#2}#3}
This is the definition of how \newenvironments are parsed.
--8<---------------cut here---------------start------------->8---
(defvar LaTeX-auto-regexp-list
(append
(let ((token TeX-token-char))
`(...
(,(concat "\\\\newenvironment\\*?{?\\(" token
"+\\)}?\\[\\([0-9]+\\)\\]\\[")
1 LaTeX-auto-environment)
(,(concat "\\\\newenvironment\\*?{?\\(" token "+\\)}?\\[\\([0-9]+\\)\\]")
(1 2) LaTeX-auto-env-args)
(,(concat "\\\\newenvironment\\*?{?\\(" token "+\\)}?")
1 LaTeX-auto-environment)
...)))))
--8<---------------cut here---------------end--------------->8---
So indeed, if the \newenvironment has a second bracket-argument, and
thus the first argument is optional, no arguments are considered at all.
I've just fixed that in git. Now
\newenvironment{colorenv}[2][red]{\color{#1}#2}{}
results in ("colorenv" 1) being in (LaTeX-environment-list), i.e., it
now carries the number of arguments minus the optional one.
Bye,
Tassilo
- Re: [AUCTeX-devel] [PATCH 1/3] Parse env's defined with `\lstnewenvironment'.,
Tassilo Horn <=