Subject: 29.0.50; [PATCH] Improve finding of external documents

From: Arash Esbati <[email-masked]>
Date: Wed, 06 Oct 2021 09:26:39 +0200

Hi all,

attached is a small patch improving RefTeX finding external documents
for referencing.

Best, Arash
>From 84c5ef108e74ad1e377fcdb43823c4104630b09f Mon Sep 17 00:00:00 2001
From: Arash Esbati <[email-masked]>
Date: Tue, 5 Oct 2021 16:35:30 +0200
Subject: [PATCH] Improve finding external documents

* lisp/textmodes/reftex-parse.el (reftex-parse-from-file): Extend
regexp in order to support \externalcitedocument macro and a
second optional argument provided by LaTeX package xr-hyper.
---
 lisp/textmodes/reftex-parse.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index c521a07f19..b8c75cb21b 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -345,7 +345,17 @@ reftex-parse-from-file
 
              ;; Find external document specifications
              (goto-char 1)
-             (while (re-search-forward "[\n\r][ \t]*\\\\externaldocument\\(\\[\\([^]]*\\)\\]\\)?{\\([^}]+\\)}" nil t)
+             (while (re-search-forward
+                     (concat "[\n\r][ \t]*"
+                             ;; Support \externalcitedocument macro
+                             "\\\\external\\(?:cite\\)?document"
+                             ;; The optional prefix
+                             "\\(\\[\\([^]]*\\)\\]\\)?"
+                             ;; The 2nd opt. arg can only be nocite
+                             "\\(?:\\[nocite\\]\\)?"
+                             ;; Mandatory file argument
+                             "{\\([^}]+\\)}")
+                     nil t)
                (push (list 'xr-doc (reftex-match-string 2)
                            (reftex-match-string 3))
                      docstruct))
-- 
2.33.0