0

I try to write a function based on the code from: Latex, Emacs: automatically open *TeX Help* buffer on error and close it after correction of the error?

I would like to replace latexmk by texi2dvi, but TeX-master-file does not contain the file ending .tex (which seems to be required for texi2dvi). I found out that one can add .tex by using TeX-master-file t. However, I can't make it work (I'm not an elisp programmer). Here is what I tried:

;; texi2dvi 
(defun run-texi2dvi ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (expand-file-name (TeX-master-file t)))); append `.tex`
    (TeX-save-document "")
    (TeX-run-TeX "texi2dvi"
         (TeX-command-expand "PDFLATEX='pdflatex -synctex=1' texi2dvi -p %s" 'TeX-master-file)
                 master-file)
    (if (plist-get TeX-error-report-switches (intern master-file))
        (TeX-next-error t)
      (progn
    (demolish-tex-help)
    (minibuffer-message "texi2dvi: done.")))))
Community
  • 1
  • 1
Marius Hofert
  • 6,546
  • 10
  • 48
  • 102

2 Answers2

1

No clue if there's a better way to do it, but this version should work. Basically, TeX-command-expand was given the function TeX-master-file as a symbol which was called internally, and there it was called without the I-want-the-extension argument. The replacing lambda forces that.

(defun run-texi2dvi ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (expand-file-name (TeX-master-file t)))); append `.tex`
    (TeX-save-document "")
    (TeX-run-TeX "texi2dvi"
         (TeX-command-expand
          "PDFLATEX='pdflatex -synctex=1' texi2dvi -p %s"
          (lambda (ext-ignored nondir)
            (TeX-master-file t nondir)))
                 master-file)
    (if (plist-get TeX-error-report-switches (intern master-file))
        (TeX-next-error t)
      (progn
    (demolish-tex-help)
    (minibuffer-message "texi2dvi: done.")))))
Tassilo Horn
  • 791
  • 8
  • 14
  • Unfortunately, this is not working as expected. If there is no error in the .tex file, then fine. But if there is an error, it is not detected (no buffer displaying the error message is opened). Also, C-c C-l typically shows the process, but I only obtain "No process for this document.". – Marius Hofert Aug 14 '12 at 17:53
0

See here for a more detailed description of the issue and a simple workaround: https://tex.stackexchange.com/questions/67244/how-to-set-up-texi2dvi-with-synctex-and-error-handling/67384#67384

Community
  • 1
  • 1
Marius Hofert
  • 6,546
  • 10
  • 48
  • 102