[Top][All Lists]

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

[AUCTeX-devel] Automatic adding of label to optional argument

From: Arash Esbati
Subject: [AUCTeX-devel] Automatic adding of label to optional argument
Date: Thu, 12 Jan 2017 18:35:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91

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.  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

Here a small .tex file:

--8<---------------cut here---------------start------------->8---



Eval this first:
(add-to-list 'LaTeX-label-alist '("lstlisting" . "lst:") t)
Copy this: aboveskip=4pt, caption ={Some caption}

Enter `C-c C-e lstlisting RET' and yank
`aboveskip=4pt, caption ={Some caption}' when asked for key=vals.

\begin{lstlisting}[aboveskip=4pt, caption ={Some caption},label={lst:1}]
Result will be like this.
Try `C-c ) l' with RefTeX enabled.

--8<---------------cut here---------------end--------------->8---

Attachment: listings.el
Description: application/emacs-lisp

Best, Arash

reply via email to

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