# HG changeset patch # User Uwe Brauer # Date 1669793258 -3600 # Wed Nov 30 08:27:38 2022 +0100 # Node ID 65dcebb49bb529b0462a6026364c1216ed18bdfa # Parent b8c8bd65a9cce48e9f5998b3951cd6e9b9c71faf Add filename as a prefix to the counter for catchfilebetweentags * style/catchfilebetweentags.el (LaTeX-env-catchfilebetweentags): Add filename as a prefix to the counter, in a similar way RefTeX does this. diff --git a/style/catchfilebetweentags.el b/style/catchfilebetweentags.el --- a/style/catchfilebetweentags.el +++ b/style/catchfilebetweentags.el @@ -51,22 +51,28 @@ (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. + (let* ((myfile (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 myfile ":" + (TeX-read-string (if fn (format "Tag (default %s): " fn) "Tag: ") nil nil (when fn (number-to-string fn))))) + (number-to-string fn)) (unless (bolp) (newline) (delete-horizontal-space))