auctex
[Top][All Lists]
Advanced

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

Re: [AUCTeX] reftex-label-alist for ctable package


From: Tassilo Horn
Subject: Re: [AUCTeX] reftex-label-alist for ctable package
Date: Fri, 27 Jul 2012 12:32:23 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux)

Michael Bach <address@hidden> writes:

>> Ah, and one restriction: You have to write labels like so
>> 
>>   [..., label={tab:foo}, ...]
>> 
>> that is, no spaces around the =, and the {} are mandatory.  That
>> could probably be relaxed a bit, but maybe you'd get false positives
>> then...
>
> This is no big deal because of yasnippet (for new files) and keyboard
> macros (for old files)...

The committed change doesn't have that restriction.  And in the patch
you have there's another problem.  You cannot jump to the label location
from the *toc* buffer, cause the label-finding regex had to be adapted,
too.

Complete patch below.

>> I tried it with the attached tex file and it seems to work for ctable
>> and listings (which I added, but the context isn't that good).
>
> It also works for my ctables in my (org) files.  This has bothered me
> a long time, thanks for the quick patch!

Awesome.

Bye,
Tassilo

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog      2012-07-27 03:48:40 +0000
+++ lisp/ChangeLog      2012-07-27 07:59:50 +0000
@@ -1,3 +1,11 @@
+2012-07-27  Tassilo Horn  <address@hidden>
+
+       * textmodes/reftex-vars.el (reftex-label-alist-builtin): Add
+       support for the lstlisting and minted environments, and for the
+       ctable macro.
+       * textmodes/reftex.el (reftex-compile-variables): Also recognize
+       labels written in keyvals syntax.
+
 2012-07-27  Jay Belanger  <address@hidden>
 
        * calc/calccomp.el (math-compose-expr): Use parentheses when

=== modified file 'lisp/textmodes/reftex-vars.el'
--- lisp/textmodes/reftex-vars.el       2012-04-09 13:05:48 +0000
+++ lisp/textmodes/reftex-vars.el       2012-07-27 07:59:50 +0000
@@ -122,7 +122,14 @@
       ;;("\\label{*}" nil nil nil nil)
       ))
 
-    )
+    (ctable    "The ctable package"
+     (("\\ctable[]{}{}{}" ?t "tab:" "\\ref{%s}" 1 ("table" "Tabelle"))))
+
+    (listings  "The listings package"
+      (("lstlisting" ?l "lst:" "~\\ref{%s}" nil (regexp "[Ll]isting"))))
+
+    (minted    "The minted package"
+      (("minted" ?l "lst:" "~\\ref{%s}" nil (regexp "[Ll]isting")))))
   "The default label environment descriptions.
 Lower-case symbols correspond to a style file of the same name in the LaTeX
 distribution.  Mixed-case symbols are convenience aliases.")

=== modified file 'lisp/textmodes/reftex.el'
--- lisp/textmodes/reftex.el    2012-01-19 07:21:25 +0000
+++ lisp/textmodes/reftex.el    2012-07-27 07:59:50 +0000
@@ -1284,7 +1284,15 @@
 ;          (wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
            (wbol "\\(^\\)[ \t]*")  ; Need to keep the empty group because
                                   ;;; because match number are hard coded
-           (label-re "\\\\label{\\([^}]*\\)}")
+           (label-re (concat "\\(?:"
+                            ;; Normal \label{...}
+                            "\\\\label{\\([^}]*\\)}"
+                            "\\|"
+                            ;; keyvals [..., label = {foo}, ...]
+                            ;; forms used by ctable, listings,
+                            ;; minted, ...
+                            
"\\[[^]]*label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?[^[]*\\]"
+                            "\\)"))
            (include-re (concat wbol
                                "\\\\\\("
                                (mapconcat 'identity
@@ -1312,6 +1320,8 @@
                     "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]"))
            (find-label-re-format
             (concat "\\("
+                   
"\\[[^]]*label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?[^[]*\\]"
+                   "\\|"
                     (mapconcat 'regexp-quote (append '("\\label")
                                                      macros-with-labels) "\\|")
                     "\\)\\([[{][^]}]*[]}]\\)*[[{]\\(%s\\)[]}]"))


reply via email to

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