# HG changeset patch # User Uwe Brauer # Date 1671468375 -3600 # Mon Dec 19 17:46:15 2022 +0100 # Node ID 6f365fe769c2410c9ea83393a670e7cf3b1a00e2 # Parent 2d32ca8c73c5e64d0a6d2a9713e25ac78cc55fac Add filename as a prefix to the counter for catchfilebetweentags * style/catchfilebetweentags.el (LaTeX-env-catchfilebetweentags): Add filename as a prefix to the counter. diff --git a/style/catchfilebetweentags.el b/style/catchfilebetweentags.el --- a/style/catchfilebetweentags.el +++ b/style/catchfilebetweentags.el @@ -51,22 +51,30 @@ (setq LaTeX-catchfilebetweentags-counter 0) (save-excursion (goto-char (point-min)) - (while (re-search-forward (concat "^%<\\*\\([^>]+\\)>$") + (while (re-search-forward "^%<\\*[^:]*:\\([^>]+\\)>$" (point-max) t) (let ((fn (string-to-number (match-string 1)))) (when (> fn LaTeX-catchfilebetweentags-counter) (setq LaTeX-catchfilebetweentags-counter fn)))))) - (setq LaTeX-catchfilebetweentags-counter + (setq LaTeX-catchfilebetweentags-counter (1+ LaTeX-catchfilebetweentags-counter))) (defun LaTeX-env-catchfilebetweentags (_environment) "Insert a tag-skeleton defined by `LaTeX-catchfilebetweentags'. ENVIRONMENT is ignored." - (let* ((fn (when LaTeX-catchfilebetweentags-use-numeric-label + ;; The following code, adds the file name as a prefix to the tag, in + ;; a similar way reftex does this, which is useful for combining + ;; several external files to a singular one. + (let* ((file (file-name-sans-extension + (file-name-nondirectory + (buffer-file-name (current-buffer))))) + (fn (when LaTeX-catchfilebetweentags-use-numeric-label (LaTeX-catchfilebetweentags-counter-inc))) - (tag (TeX-read-string + (tag + (concat file ":" + (TeX-read-string (if fn (format "Tag (default %s): " fn) "Tag: ") - nil nil (when fn (number-to-string fn))))) + nil nil (when fn (number-to-string fn)))))) (unless (bolp) (newline) (delete-horizontal-space)) @@ -85,7 +93,6 @@ [TeX-arg-input-file "File" t] "Tag") '("ExecuteMetaData*" [TeX-arg-input-file "File" t] "Tag") - '("CatchFileBetweenTags" TeX-arg-define-macro (TeX-arg-input-file "File-name" t) "Tag") '("CatchFileBetweenTags*"