[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 8530cd0 45/80: Support cleveref labels
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 8530cd0 45/80: Support cleveref labels |
Date: |
Wed, 16 Oct 2019 11:07:15 -0400 (EDT) |
branch: externals/auctex
commit 8530cd0c25d07c182ccef54bee5645cc309cce62
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Support cleveref labels
* style/cleveref.el (TeX-arg-cleveref-crossref-type): New
function.
(LaTeX-cleveref-label-regexp): New variable for parsing \label
macros with an optional argument.
("cleveref"): Add missing package macros.
Update expert commands and fontification.
Update `reftex-label-regexps' enabling RefTeX to handle \label
with an optional argument as well.
Update description line and add Commentary section. (bug#36111)
---
style/cleveref.el | 141 ++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 115 insertions(+), 26 deletions(-)
diff --git a/style/cleveref.el b/style/cleveref.el
index 2774dcb..290bc2f 100644
--- a/style/cleveref.el
+++ b/style/cleveref.el
@@ -1,6 +1,6 @@
-;;; cleveref.el --- Style hook for the `cleveref.sty' package.
+;;; cleveref.el --- AUCTeX style for `cleveref.sty' (v0.21.4)
-;; Copyright (C) 2014--2016, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014--2019 Free Software Foundation, Inc.
;; Author: Matthew Leach <address@hidden>
;; Maintainer: address@hidden
@@ -23,6 +23,11 @@
;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
;; 02110-1301, USA.
+;;; Commentary:
+
+;; This file adds support for `cleveref.sty' (v0.21.4), dated
+;; 2018/03/27.
+
;;; Code
;; Silence the compiler:
@@ -47,22 +52,41 @@ string."
(labels-string (mapconcat #'identity labels ",")))
(TeX-argument-insert labels-string optional))))
+(defun TeX-arg-cleveref-crossref-type (optional &optional prompt)
+ "Insert the cross-reference type for macros of cleveref package.
+If OPTIONAL is non-nil, insert the resulting value in brackets.
+Use PROMPT as the prompt string."
+ (let* ((type (mapcar #'list
+ '("appendix" "subappendix" "subsubappendix"
+ "subsubsubappendix" "subfigure" "subtable"
+ "subequation")))
+ (types (append (LaTeX-counter-list) type)))
+ (TeX-argument-insert
+ (completing-read (TeX-argument-prompt optional prompt "Type") types)
+ optional)))
+
+(defvar LaTeX-cleveref-label-regexp
+ '("\\\\label\\[[^]]*\\]{\\([^\n\r%\\{}]+\\)}" 1 LaTeX-auto-label)
+ "Regexp matching a \\label incl. an optional argument.")
+
(TeX-add-style-hook
"cleveref"
(lambda ()
+
(TeX-add-symbols
+ ;; 4 Typesetting Cross-References
'("cref" TeX-arg-cleveref-multiple-labels)
'("Cref" TeX-arg-cleveref-multiple-labels)
'("crefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
'("Crefrange" (TeX-arg-ref "key (first)") (TeX-arg-ref "Key (last)"))
- '("cpageref" TeX-arg-cleveref-multiple-labels)
- '("Cpageref" TeX-arg-cleveref-multiple-labels)
- '("cpagerefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
- '("Cpagerefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
'("cref*" TeX-arg-cleveref-multiple-labels)
'("Cref*" TeX-arg-cleveref-multiple-labels)
'("crefrange*" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
'("Crefrange*" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
+ '("cpageref" TeX-arg-cleveref-multiple-labels)
+ '("Cpageref" TeX-arg-cleveref-multiple-labels)
+ '("cpagerefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
+ '("Cpagerefrange" (TeX-arg-ref "Key (first)") (TeX-arg-ref "Key (last)"))
'("namecref" TeX-arg-ref)
'("nameCref" TeX-arg-ref)
'("lcnamecref" TeX-arg-ref)
@@ -70,35 +94,100 @@ string."
'("nameCrefs" TeX-arg-ref)
'("lcnamecrefs" TeX-arg-ref)
'("labelcref" TeX-arg-cleveref-multiple-labels)
- '("labelcpageref" TeX-arg-cleveref-multiple-labels))
+ '("labelcpageref" TeX-arg-cleveref-multiple-labels)
+ ;; 6 Overriding the Cross-Reference Type
+ '("crefalias" TeX-arg-counter "Type")
+ '("label" [ TeX-arg-cleveref-crossref-type ] TeX-arg-define-label)
+
+ ;; 8.1.1 Global Customisation
+ '("crefdefaultlabelformat" t)
+
+ ;; 8.1.2 Customising Individual Cross-Reference Types
+ '("crefname" TeX-arg-cleveref-crossref-type
+ "Singular name" "Plural name")
+ '("Crefname" TeX-arg-cleveref-crossref-type
+ "Singular name" "Plural name")
+ '("creflabelformat" TeX-arg-cleveref-crossref-type t)
+ '("crefrangelabelformat" TeX-arg-cleveref-crossref-type t)
+
+ ;; 8.2.1 Single Cross-References
+ '("crefformat" TeX-arg-cleveref-crossref-type t)
+ '("Crefformat" TeX-arg-cleveref-crossref-type t)
+
+ ;; 8.2.2 Reference Ranges
+ '("crefrangeformat" TeX-arg-cleveref-crossref-type t)
+ '("Crefrangeformat" TeX-arg-cleveref-crossref-type t)
+
+ ;; 8.2.3 Multiple Cross-References
+ '("crefmultiformat" TeX-arg-cleveref-crossref-type 4)
+ '("Crefmultiformat" TeX-arg-cleveref-crossref-type 4)
+ '("crefrangemultiformat" TeX-arg-cleveref-crossref-type 4)
+ '("Crefrangemultiformat" TeX-arg-cleveref-crossref-type 4))
;; These macros aren't used particularly often during the course of
;; normal referencing.
(TeX-declare-expert-macros
"cleveref"
"namecref" "nameCref" "lcnamecref" "namecrefs" "nameCrefs"
- "lcnamecrefs" "labelcref" "labelcpageref")
+ "lcnamecrefs" "labelcref" "labelcpageref"
+ "crefdefaultlabelformat"
+ "crefname" "Crefname" "creflabelformat" "crefrangelabelformat"
+ "crefformat" "Crefformat"
+ "crefrangeformat" "Crefrangeformat"
+ "crefmultiformat" "Crefmultiformat"
+ "crefrangemultiformat" "Crefrangemultiformat")
+
+ ;; Add \label[type]{label} to AUCTeX parser
+ (TeX-auto-add-regexp LaTeX-cleveref-label-regexp)
+
+ ;; Tell RefTeX. Check if `reftex-label-regexps' is bound and use a
+ ;; local version of it. Check if the regexp is already added in
+ ;; order not to run `reftex-compile-variables' every time the style
+ ;; hook runs
+ (when (and (boundp 'reftex-label-regexps)
+ (fboundp 'reftex-compile-variables))
+ (let ((regexp "\\\\label\\[[^]]*\\]{\\(?1:[^\n\r%\\{}]+\\)}"))
+ (unless (member regexp reftex-label-regexps)
+ (add-to-list (make-local-variable 'reftex-label-regexps)
+ regexp t)
+ (reftex-compile-variables))))
;; Fontification
(when (and (fboundp 'font-latex-add-keywords)
(eq TeX-install-font-lock 'font-latex-setup))
- (font-latex-add-keywords '(("cref" "*{")
- ("Cref" "*{")
- ("crefrange" "*{{")
- ("Crefrange" "*{{")
- ("cpageref" "{")
- ("Cpageref" "{")
- ("cpagerefrange" "{{")
- ("Cpagerefrange" "{{")
- ("namecref" "{")
- ("nameCref" "{")
- ("lcnamecref" "{")
- ("namecrefs" "{")
- ("nameCrefs" "{")
- ("lcnamecrefs" "{")
- ("labelcref" "{")
- ("labelcpageref" "{"))
- 'reference))
+ (font-latex-add-keywords '(("cref" "*{")
+ ("Cref" "*{")
+ ("crefrange" "*{{")
+ ("Crefrange" "*{{")
+ ("cpageref" "{")
+ ("Cpageref" "{")
+ ("cpagerefrange" "{{")
+ ("Cpagerefrange" "{{")
+ ("namecref" "{")
+ ("nameCref" "{")
+ ("lcnamecref" "{")
+ ("namecrefs" "{")
+ ("nameCrefs" "{")
+ ("lcnamecrefs" "{")
+ ("labelcref" "{")
+ ("labelcpageref" "{")
+ ("label" "[{"))
+ 'reference)
+ (font-latex-add-keywords '(("crefalias" "{{")
+ ("crefname" "{{{")
+ ("Crefname" "{{{")
+ ("creflabelformat" "{{")
+ ("crefrangelabelformat" "{{")
+ ("crefdefaultlabelformat" "{")
+ ("crefformat" "{{")
+ ("Crefformat" "{{")
+ ("crefrangeformat" "{{")
+ ("Crefrangeformat" "{{")
+ ("crefmultiformat" "{{{{{")
+ ("Crefmultiformat" "{{{{{")
+ ("crefrangemultiformat" "{{{{{")
+ ("Crefrangemultiformat" "{{{{{"))
+ 'function))
;; Activate RefTeX reference style.
(and LaTeX-reftex-ref-style-auto-activate
@@ -108,6 +197,6 @@ string."
(defvar LaTeX-cleveref-package-options
'("capitalise" "nameinlink" "noabbrev" "poorman")
- "Package options for the cleveref package.")
+ "Package options for the cleveref package.")
;;; cleveref.el ends here.
- [elpa] externals/auctex ddd7894 20/80: ; Fix last commit, (continued)
- [elpa] externals/auctex ddd7894 20/80: ; Fix last commit, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex c92251c 36/80: Load hyperref.el in `LaTeX-beamer-class-options', Tassilo Horn, 2019/10/16
- [elpa] externals/auctex d4660dd 18/80: * style/xparse.el ("xparse"): Fix fontification of alternatives., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex b62181c 29/80: ; Remove unused code fragment, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 400b002 28/80: Remove obsolete codes, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 0cc2578 39/80: ; Use the correct variable `LaTeX-fontspec-font-features', Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 945ffaf 40/80: Update style/babel.el to package version 3.31, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 36d06e2 44/80: ; * tests/latex/preview-latex-test.el: Fix typo., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 686366e 48/80: ; Add Emacs 24 compatibility to the previous commit, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 0a9407c 47/80: Conform to `delete-selection-mode' (bug#36385), Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 8530cd0 45/80: Support cleveref labels,
Tassilo Horn <=
- [elpa] externals/auctex 4a56103 56/80: Reduce unnecessary local variable safety inquiry, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex b7083ee 51/80: Change color adjustment method (bug#35571, bug#35696, bug#36039), Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 43e98f1 55/80: Update style/titlesec.el to package version 2.11, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex f477383 54/80: Update style/thmtools.el to package version 67, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex ccfd3d9 57/80: Restore syntax fontify in Texinfo mode, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex f127145 60/80: * context.el (ConTeXt-environment): Fix docstring., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex d56a596 58/80: ; * tests/tex/path-expansion.el (): Fix typo., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 8610189 52/80: Update style/paracol.el to package version 1.35, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex c64d8c1 61/80: * doc/changes.texi: Mention fontification improvement for biblatex., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 2c23247 62/80: Support explicitly numbered group contructs, Tassilo Horn, 2019/10/16