>> I found that replace-match on line 568 replaces something that differs >> from matched string on line 553. > > That would mean that in between `match-string' in 553 and > `replace-match' in 568, something else changed the match data. But we > use `save-match-data' when calling the expansion function, so in theory > that must not happen.
I got a recipe as described below. emacs -Q ;; (add-to-list 'load-path "~/.emacs.d/elpa/auctex-12.3.1/") (add-to-list 'load-path "~/.emacs.d/elpa/auctex-13.0.3/") (load "auctex.el" nil t t) (setq TeX-parse-self t) (setq TeX-auto-save t) (setq-default TeX-master t) (find-file-other-frame "report.tex") (add-to-list 'TeX-expand-list '("%(jobname)" sesame-TeX-jobname)) (add-to-list 'TeX-expand-list '("%(outdir)" sesame-TeX-outdir)) (add-to-list 'TeX-command-list '("make" "latexmk%S%(mode)%(jobname)%(outdir)%(file-line-error) %t" TeX-run-TeX nil (latex-mode) :help "Run latexmk")) (defun sesame-TeX-jobname () "Return option `-jobname' or empty string." (TeX-active-master-with-quotes nil t) ;; " -jobname=LaTexMkJob" "") (defun sesame-TeX-outdir (&optional looptex-p) "Return option `-outdir' or empty string." (TeX-active-master-with-quotes nil t) " -outdir=~/deleteme.d") (call-interactively 'TeX-command-master) ; type `make' (call-interactively 'TeX-recenter-output-buffer) Messages I expect and I got then are shown below. expect: Running `make' on `report' with ``latexmk -interaction=nonstopmode -file-line-error report.tex'' I got: Running `make' on `report' with ``latexmk -interaction=nonstopmode%(outdir) -file-line-error report.tex'' It seems that when TeX-active-master-with-quotes is called from TeX-command-expand, something happens.