Arash Esbati <[email protected]> writes:

> Can you apply this patch to your local listings.el, recompile the file,
> reset any customizations to `reftex-label-regexps' and
> `reftex-label-alist', restart Emacs and try it again?

The patch failed to apply, so I pulled again (using straight.el, which pulls
from this mirror: https://github.com/emacs-straight/auctex). After the pull,
the patch still doesn't apply. listings.el at the moment looks like this:

   (when (fboundp 'reftex-add-label-environments)
     (reftex-add-label-environments
      '(("lstlisting" ?l "lst:" "~\\ref{%s}"
         LaTeX-keyval-caption-reftex-context-function
         (regexp "[Ll]isting"))
        ("\\lstinputlisting[]{}" ?l "lst:" "~\\ref{%s}"
         LaTeX-keyval-caption-reftex-context-function
         (regexp "[Ll]isting")))))

   ;; Tell RefTeX about \lstinputlisting:
   (when (and (boundp 'reftex-label-regexps)
              (fboundp 'reftex-compile-variables))
     (let ((regexp (concat "\\\\lstinputlisting"
                           (LaTeX-extract-key-value-label "label" 1))))
       (unless (member regexp reftex-label-regexps)
         (add-to-list (make-local-variable 'reftex-label-regexps) regexp t)
         (reftex-compile-variables))))


If I remove the (when) block and replace it with

> +   (when (and (boundp 'reftex-label-regexps)
> +              (fboundp 'reftex-compile-variables))
> +     (let ((regexp (concat "\\\\lstinputlisting"
> +                           ;; Match the opening [ and the following chars
> +                           "\\[[^][]*"
> +                           ;; Allow nested levels of chars enclosed in braces
> +                           "\\(?:{[^}{]*"
> +                           "\\(?:{[^}{]*"
> +                           "\\(?:{[^}{]*}[^}{]*\\)*"
> +                           "}[^}{]*\\)*"
> +                           "}[^][]*\\)*"
> +                           ;; Match the label key
> +                           "\\<label[[:space:]]*=[[:space:]]*"
> +                           ;; Match the label value; braces around the
> +                           ;; value are optional from LaTeX POV, but
> +                           ;; necessary for RefTeX for follow-mode:
> +                           "{?\\(?1:[^] ,}\r\n\t%]+\\)")))
> +       (unless (member regexp reftex-label-regexps)
> +         (add-to-list 'reftex-label-regexps regexp t)
> +         (reftex-compile-variables))))

and re-build it, the problem still persists. However, since I'm using
straight.el I'm not 100% sure that I am doing this correctly.

A quick question before I commit a lot more time into this (I was in the
process of migrating away from straight.el but haven't fully picked that up
yet): is the code I sent above what should be on the main branch (so is it to
be expected that the patch doesn't apply on the latest code)?

Thanks for the reply after all this time!

-- 
Best,
Rens

Reply via email to