Hi Basil,

"Basil L. Contovounesios" <ba...@contovou.net> writes:

> Arash Esbati [2024-03-28 13:09 +0100] wrote:
>
> Indeed, with the exception of important bugs which can be fixed at
> https://github.com/emacsmirror/auctex-latexmk (this is the fork/mirror
> that MELPA serves).

Thanks for your response and the pointer.

>> What do others think?  Is there a market for this addition?
>
> Personally I think it would be neat to have this built-in, but I'm not a
> market.

;-)  I hope you know that I didn't mean it like that.

>> Can you imagine helping us with this addition?
>
> I'd be more than happy to, but I'm not sure I'll be able to find the
> time in the next couple of weeks, so if anyone else is motivated to work
> on it in the meantime, feel free.

Great, thanks.  I was thinking about something like this:

--8<---------------cut here---------------start------------->8---
diff --git a/tex.el b/tex.el
index 053a0ade..abb5fcd7 100644
--- a/tex.el
+++ b/tex.el
@@ -250,6 +250,8 @@ 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")
+    ("LaTeXMK" "latexmk %(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 +674,41 @@ 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: Handling of Dvipdfmx in DVI mode is still open:
+    ("%(latexmk-out)"
+     (lambda ()
+       (cond ((eq TeX-engine 'default)
+              ;; 'default TeX-engine:
+              (if (if TeX-PDF-mode
+                      ;; We want to produce a pdf
+                      ;; Return t if default compiler produces PDF,
+                      ;; nil for "Dvips" or "Dvipdfmx"
+                      (not (TeX-PDF-from-DVI))
+                    ;; t if pdftex is used in dvi-mode
+                    TeX-DVI-via-PDFTeX)
+                  ;; We're using pdflatex in pdf-mode
+                  " -pdflatex"
+                ;; We're generating a .dvi to process with dvips or
+                ;; dvipdfmx.
+                ;; FIXME: I don't know how latexmk handles this for
+                ;; dvipdfmx!
+                " -pdflatex -dvi -ps"))
+             ;; Running luatex in pdf or dvi-mode:
+             ((eq TeX-engine 'luatex)
+              (if TeX-PDF-mode
+                  " -pdflua"
+                " -dvilua -ps"))
+             ;; Running xetex in any mode:
+             ((eq TeX-engine 'xetex)
+              " -xelatex")
+             ;; For anything else: This runs traditional latex, dvi, ps,
+             ;; pdf if needed.
+             ;; FIXME: "Dvipdfmx" might be missing.
+             (t
+              (if TeX-PDF-mode
+                  " -pdfps"
+                " -ps"))))))
   "List of built-in expansion strings for TeX command names.

 This should not be changed by the user who can use
@@ -2200,7 +2236,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.")
--8<---------------cut here---------------end--------------->8---

Again, I've never used LaTeXMK and maybe I misunderstood the options, so
I'm grateful for any comments.

Best, Arash

Reply via email to