Mosè Giordano <m...@gnu.org> writes: Hi Mosè,
> 2015-08-19 0:27 GMT+02:00 Arash Esbati <esb...@gmx.de>: [...] >> Of course, you're right. But do you a hint how I can achieve the >> desired result with AUCTeX functions? > > With the brand-new `TeX-arg-label' function! Many thanks for looking at this and `TeX-read-label' ;-) > I'd suggest you to use the same check done inside `LaTeX-label' (if > `LaTeX-label-function' is a valid function call it), but I suspect you > need to pass to `reftex-label' also the second argument, which is not > requested by `LaTeX-label-function'. Probably there aren't many other > functions bound to `LaTeX-label-function' apart from `reftex-label', > in which case we could update the docstring of `LaTeX-label-function' > requesting also a second argument, but we need some feedback from > users before doing this change. Following your suggestion, I changed my code to: --8<---------------cut here---------------start------------->8--- (defun LaTeX-arg-caption-captionbox (optional &optional prompt) "Query for the arguments of `\\captionbox' incl. a label and insert them." (let* ((caption (TeX-read-string (TeX-argument-prompt optional prompt "Caption"))) (label (if (and (boundp 'LaTeX-label-function) LaTeX-label-function (fboundp LaTeX-label-function) (eq LaTeX-label-function 'reftex-label)) (funcall LaTeX-label-function nil t) (TeX-read-label optional "Label" t))) (width (completing-read (TeX-argument-prompt t prompt "Width") (mapcar (lambda(elt) (concat TeX-esc (car elt))) (LaTeX-length-list)))) (inpos (completing-read (TeX-argument-prompt t prompt "Inner position") '("c" "l" "r" "s"))) (heading (format "%s\\label{%s}" caption label))) [rest snipped] --8<---------------cut here---------------end--------------->8--- It checks for (eq LaTeX-label-function 'reftex-label) and runs it with the required arguments. Otherwise, your new function. The only drawback of `TeX-read-label' is that it does not guess the current environment and puts a label prefix (fig: or tab:) in the minibuffer. Well, I would say "yet another reason to turn on RefTeX". Again, thanks a ton. Best, Arash _______________________________________________ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel