Hi Keita, Ikumi Keita <ik...@ikumi.que.jp> writes:
> I expect the attached patch basically works. Thanks for picking this up as well. > It still has shortcomings: > 1. It uses single quote to prevent variable expansion of '$dvipdf' in > the shell command line. However, it doesn't work for windows. Yes, that wouldn't work on Windows, so we should use something else or an alternative approach. > 2. After C-c C-c LaTeXMK, in dvi+dvips case, C-c C-c View offers xdvi, > not postscript viewer, as default candidate. Similarly, in > dvi+dvipdfmx case, C-c C-c offers Dvipdfmx, not View, as default > candidate. Yes, I can confirm this. I also tried it with my approach with the same result: C-c C-c View doesn't work. I didn't try to find out why, though. I have a question: Is putting the "progname='%`%l%(mode)%''" in each entry necessary? I slightly changed my initial proposal and it seems to work as well. The code looks less complicated to me. I admit I didn't test every combination in the code. Best, Arash
diff --git a/tex.el b/tex.el index 053a0ade..f1f4d343 100644 --- a/tex.el +++ b/tex.el @@ -250,6 +250,11 @@ If nil, none is specified." ("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Convert PostScript file to PDF") + ;; Suppress "-recorder" option because %l expantion can include + ;; "\input", after which latexmk inserts "-recorder". + ("LaTeXMK" "latexmk -recorder %(latexmk-out) %(file-line-error) \ +%`%(extraopts) %S%(mode)%' %t" + TeX-run-format nil (LaTeX-mode docTeX-mode) :help "Run LaTeXMK") ("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil (plain-TeX-mode LaTeX-mode docTeX-mode AmSTeX-mode Texinfo-mode) :help "Run makeglossaries to create glossary file") @@ -672,7 +677,40 @@ string." ;; Okular forward PDF search requires absolute path. ("%a" (lambda nil (prin1-to-string (expand-file-name (buffer-file-name))))) ;; the following is for preview-latex. - ("%m" preview-create-subdirectory)) + ("%m" preview-create-subdirectory) + ;; LaTeXMK support + ("%(latexmk-out)" + (lambda () + (cond ((eq TeX-engine 'xetex) + " -pdfxe") + ((eq TeX-engine 'luatex) + (cond ((and TeX-PDF-mode + (TeX-PDF-from-DVI)) + " -dvilua -pdfdvi") + ((and (not TeX-PDF-mode) + TeX-DVI-via-PDFTeX) + " -dvilua -ps") + (t ; (and TeX-PDF-mode (not (TeX-PDF-from-DVI))) + " -pdflua"))) + (t ; (eq TeX-engine 'default) + (cond ((and TeX-PDF-mode + (not (TeX-PDF-from-DVI))) + " -pdf") + ((and TeX-PDF-mode + (TeX-PDF-from-DVI)) + " -pdfdvi") + ;; TBD: Not sure how to do this with LaTeXMK: + ;; ((and TeX-PDF-mode + ;; (string= (TeX-PDF-from-DVI) "Dvipdfmx")) + ;; " ") + ((and TeX-PDF-mode + (string= (TeX-PDF-from-DVI) "Dvips")) + " -pdfps") + ((and (not TeX-PDF-mode) + TeX-DVI-via-PDFTeX) + " -pdflatex -dvi -ps") + (t + " -dvi -ps"))))))) "List of built-in expansion strings for TeX command names. This should not be changed by the user who can use @@ -2200,7 +2238,8 @@ Must be the car of an entry in `TeX-command-list'." "\\.glo" "\\.gls" "\\.idx" "\\.ilg" "\\.ind" "\\.lof" "\\.log" "\\.lot" "\\.nav" "\\.out" "\\.snm" "\\.toc" "\\.url" "\\.synctex\\.gz" - "\\.bcf" "\\.run\\.xml" "\\.fls" "-blx\\.bib") + "\\.bcf" "\\.run\\.xml" "\\.fls" "-blx\\.bib" + "\\.fdb_latexmk") "List of regexps matching suffixes of files to be cleaned. Used as a default in TeX, LaTeX and docTeX mode.")