[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] [problems with TeX-arg-ref]
From: |
Arash Esbati |
Subject: |
Re: [AUCTeX-devel] [problems with TeX-arg-ref] |
Date: |
Wed, 16 Nov 2016 16:17:51 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 |
Hi Uwe,
Uwe Brauer <address@hidden> writes:
> > You're comparing apples with oranges: `reftex-label' defines a new
> > label, `TeX-arg-ref' prompts for an already existing label. What do
> > you want to accomplish? Determine what action you want to take
> > (define a new label? reference an existing one?), use the appropriate
> > AUCTeX function, and you're done. If you use RefTeX, it'll be
> > actually used.
>
> The first version of my code was
> '("titledquestion" "Title" ["Points"] reftex-label)
>
> Arash told me to change it because it was too reftex specific. So I
> changed it to
> '("titledquestion" "Title" ["Points"] TeX-arg-ref)
> which most likely is fine if reftex-plug-into-AUCTeX is nil.
>
> But the problem is, with setq reftex-plug-into-AUCTeX t, TeX-arg-ref
> behaves differently from reftex-label, because it now asks you
> interactively to insert a label. That is a behaviour which I don't want,
> I want reftex to do this automatically.
I'm not sure if I understand this correctly, but I see a point here:
`TeX-arg-ref' inserts an empty pair of braces when the argument is
empty.
> So it boils down to this what is the corresponding AUCTeX function which
> behaves *exactly* as reftex-label?
It is `LaTeX-label' (ah! ;-) which behaves almost exactly as
`reftex-label'. You could write a function like this:
(defun LaTeX-exam-label (_optional &optional name type)
"Indent the line and query/insert a label incl. the \"\\label\" macro.
Arguments NAME and TYPE are the same as for the function
`LaTeX-label'. OPTIONAL is ignored."
(indent-according-to-mode)
(let ((currenv (LaTeX-current-environment)))
(LaTeX-label (or name currenv) type)))
And then:
(TeX-add-symbols
'("titledquestion" "Title" ["Points"] LaTeX-exam-label (TeX-arg-literal "
"))
Note that with RefTeX enabled, the job is transferred to `reftex-label',
otherwise `LaTeX-label' itself does it.
Here a small file I tested with:
--8<---------------cut here---------------start------------->8---
\documentclass{exam}
\qformat{Question \thequestion: \thequestiontitle\dotfill\thepoints}
\begin{document}
\begin{questions}
\titledquestion{RefTeX is not plugged into AUCTeX}[0] When asked for a
\verb|(Optional:) What label|, just hit \verb|RET| and nothing is
inserted
\titledquestion{RefTeX is not plugged into AUCTeX}[0]\label{one} When
asked for a \verb|(Optional:) What label|, enter \verb|<key>| and
\verb|\label{<key>}| is inserted
%
\titledquestion{RefTeX is plugged into AUCTeX}[100] When asked for a
\verb|Label: sec:|, just hit \verb|RET| and nothing is inserted
\titledquestion{RefTeX is plugged into AUCTeX}[100]\label{sec:reftex}
When asked for a \verb|Label: sec:|, enter \verb|<label>| and
\verb|\label{<sec:label>}| is inserted
\end{questions}
\end{document}
--8<---------------cut here---------------end--------------->8---
Best, Arash
- Re: [AUCTeX-devel] patch for exam class, (continued)
- Re: [AUCTeX-devel] patch for exam class, Arash Esbati, 2016/11/13
- [AUCTeX-devel] [problems with TeX-arg-ref] (was: patch for exam class), Uwe Brauer, 2016/11/14
- Re: [AUCTeX-devel] [problems with TeX-arg-ref] (was: patch for exam class), Mosè Giordano, 2016/11/14
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Uwe Brauer, 2016/11/14
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Mosè Giordano, 2016/11/15
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Uwe Brauer, 2016/11/15
- Re: [AUCTeX-devel] [problems with TeX-arg-ref],
Arash Esbati <=
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Uwe Brauer, 2016/11/16
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Mosè Giordano, 2016/11/16
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Uwe Brauer, 2016/11/16
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Arash Esbati, 2016/11/17
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Uwe Brauer, 2016/11/17
- Re: [AUCTeX-devel] [problems with TeX-arg-ref], Arash Esbati, 2016/11/17