# HG changeset patch # User Uwe Brauer # Date 1671209191 -3600 # Fri Dec 16 17:46:31 2022 +0100 # Node ID 3e71eb49c8465c6ba3c1b83d7fa61d781e670f42 # Parent 8950c20945ef7aca42ad63a2ff3aea83f1788423 Add filename as a prefix to the counter for catchfilebetweentags * style/catchfilebetweentags.el: Add filename as a prefix to the counter for catchfilebetweentags 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 "^%<\\*\\([^>]+\\)>$") - (point-max) t) + (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*"