[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] Automatic adding of label to optional argument
From: |
Mosè Giordano |
Subject: |
Re: [AUCTeX-devel] Automatic adding of label to optional argument |
Date: |
Fri, 13 Jan 2017 01:45:19 +0100 |
Hi Arash,
2017-01-12 18:35 GMT+01:00 Arash Esbati <address@hidden>:
> Hi all,
>
> some packages like listings.sty have a label key since one cannot put
> \label in the body of the environment. I wrote a function which uses
> the standard interface of AUCTeX and/or RefTeX for inserting a \label
> and then moves the result into the optional argument.
I like the problem you want to solve, am not sure your way is the most
effective one to do it, though, see below.
> Please find
> attached a modified version of listings.el. The respective function is
> `LaTeX-listings-env'. Any comments are welcome. One thing I'm not sure
> is do I have to (set-marker let-bound-marker nil) at the end of the
> function? I could see if I can make a more generalized function out of
> this.
Some comments on the code:
* I think that
--8<---------------cut here---------------start------------->8---
(and keyvals
(not (string= keyvals ""))
(save-excursion
(re-search-backward "caption[ \t\n\r%]*="
(save-excursion
(re-search-backward
(concat "\\\\begin{" env "}[ \t\n\r%]*\\[") nil t))
t))
(assoc env LaTeX-label-alist)
(save-excursion (LaTeX-label env 'environment)))
--8<---------------cut here---------------end--------------->8---
can be simplified to
--8<---------------cut here---------------start------------->8---
(and (string-match "caption[ \t\n\r%]*=" keyvals)
(assoc env LaTeX-label-alist)
(save-excursion (LaTeX-label env 'environment)))
--8<---------------cut here---------------end--------------->8---
or did you see corner cases where this wouldn't work?
* I don't really like inserting the label and then deleting it. How
about adding an optional no-insert argument to `LaTeX-label', just
like `reftex-label'? `LaTeX-label' already returns the label, we only
need not to insert it.
* Why don't you use (save-excursion (LaTeX-find-matching-begin)
(point)) to get the position of the beginning of current environment?
* I'm not sure whether the markers should be erased before exiting
(they're defined in a `let', they should automatically go away), but
making them point nowhere doesn't harm.
Bye,
Mosè
- [AUCTeX-devel] Automatic adding of label to optional argument, Arash Esbati, 2017/01/12
- Re: [AUCTeX-devel] Automatic adding of label to optional argument,
Mosè Giordano <=
- Re: [AUCTeX-devel] Automatic adding of label to optional argument, Arash Esbati, 2017/01/13
- Re: [AUCTeX-devel] Automatic adding of label to optional argument, Mosè Giordano, 2017/01/15
- Re: [AUCTeX-devel] Automatic adding of label to optional argument, Arash Esbati, 2017/01/16
- Re: [AUCTeX-devel] Automatic adding of label to optional argument, Arash Esbati, 2017/01/17
- Re: [AUCTeX-devel] Automatic adding of label to optional argument, Mosè Giordano, 2017/01/18
- Re: [AUCTeX-devel] Automatic adding of label to optional argument, Arash Esbati, 2017/01/18
- Re: [AUCTeX-devel] Automatic adding of label to optional argument, Mosè Giordano, 2017/01/16