Matthew Leach <[email protected]> writes:

Hi Matthew,

> This patch adds a new style file for cleveref support.  I've included
> support for the most used cleveref macros, a new argument function
> that prompts the user for a series of labels and package options.

Nice, thanks.  In order to add this style to AUCTeX, you need to assign
copyright to the FSF.  If you are willing to do so, please fill out this
form

  
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=doc/Copyright/request-assign.future;hb=HEAD

and sent it to [email protected] with me in the Cc.  It's best if you name
Emacs as program you've contributed to since a copyright assignment for
Emacs also covers AUCTeX but not the other way round.

> I notice that \cref and friends aren't highlighted as keywords by
> font-lock.  Do I need to provide a hints to font-lock, such as is done
> in style/babel.el?

Yes, exactly.  You want to add \cref and friends to font-latex's
'reference class.  Have a look at style/hyperref.el which does the same
below the ;; Fontification comment.

> Any comments welcome.

See below.

> +(defun TeX-arg-multiple-labels (optional &optional prompt definition)

If this function is in the cleverref style, then it should start with
TeX-arg-cleverref-*.  If it was generally useful also for other styles,
then the name would be ok and we could add it to tex.el.  You could
check the other styles if multiple labels are queried and inserted, too.

> +  "Prompt for a series of labels completing with known labels.
> +If OPTIONAL is non-nil, insert the resulting value as an optional
> +argument, otherwise as a mandatory one.  Use PROMPT as the prompt
> +string.  If DEFINITION is non-nil, add each chosen label to the
> +list of defined labels."
> +  (let ((all-refs "")
> +        (first-ref t))
> +    (while
> +        (progn
> +          (let ((label (completing-read
> +                        (concat (TeX-argument-prompt optional prompt "Key" 
> (not first-ref))
> +                                (unless first-ref " (\"\" to finish): "))
> +                        (LaTeX-label-list))))
> +            (unless (string-equal "" label)
> +              (when definition
> +                (LaTeX-add-labels label))
> +              (setq all-refs
> +                    (concat all-refs (unless first-ref ",") label))
> +              (setq first-ref nil)
> +              t))))
> +    (TeX-argument-insert all-refs optional optional)))

This enter one label after the other in a loop approach is not very
convenient.  Use `TeX-completing-read-multiple' instead which reads
multiple elements as a comma-separated string.

> +(TeX-add-style-hook
> + "cleveref"
> + (lambda ()
> +   (TeX-add-symbols
> +    '("cref" TeX-arg-multiple-labels)
> +    '("Cref" TeX-arg-multiple-labels)
> +    '("crefrange" (TeX-arg-label "Key (first)") (TeX-arg-label "Key (last)"))
> +    '("Crefrange" (TeX-arg-label "key (first)") (TeX-arg-label "Key (last)"))
> +    '("cpageref" TeX-arg-multiple-labels)
> +    '("Cpageref" TeX-arg-multiple-labels)
> +    '("cpagerefrange" (TeX-arg-label "Key (first)") (TeX-arg-label "Key 
> (last)"))
> +    '("Cpagerefrange" (TeX-arg-label "Key (first)") (TeX-arg-label "Key 
> (last)"))
> +    '("cref*" TeX-arg-multiple-labels)
> +    '("Cref*" TeX-arg-multiple-labels)
> +    '("crefrange*" (TeX-arg-label "Key (first)") (TeX-arg-label "Key 
> (last)"))
> +    '("Crefrange*" (TeX-arg-label "Key (first)") (TeX-arg-label "Key 
> (last)"))))
> + LaTeX-dialect)

If some of these macros are rarely useful for the average LaTeX user,
you can declare them to be expert commands using
`TeX-declare-expert-macros'.  Have a look at style/metalogo.el for an
example.

Bye,
Tassilo


_______________________________________________
auctex-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to