Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
96 views
in Technique[技术] by (71.8m points)

auctex - Emacs latexmk function throws me into an empty buffer

This is a follow up to How do I bind latexmk to one key in Emacs and have it show errors if there are any.

I'm using a function in Emacs to compile LaTeX documents with latexmk but it does not behave exactly as I want. The function I use is one Jouni K. Sepp?nen came up with:

(defun run-latexmk ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (TeX-master-file)))
    (TeX-save-document "")
    (TeX-run-TeX "latexmk" "latexmk" master-file)
    (if (plist-get TeX-error-report-switches (intern master-file))
        (TeX-next-error t)
      (minibuffer-message "latexmk done"))))

(add-hook 'LaTeX-mode-hook
          (lambda () (local-set-key (kbd "C-0") #'run-latexmk)))

The main problem is that when I use the function (by pressing C-0) it sometimes throws me into an empty buffer called TeX Live 2011.

One way of reproducing this problem is by trying to compile the following (it does not matter that vc.tex does not exist):

immediatewrite18{sh ./vc}
input{vc}
documentclass{article}
egin{document}
end{document}

Another way of reproducing it is to try to compile the following:

documentclass{article}

ewcommand{foo}{
egin{document}
end{document}

A minor (cosmetic) problem is that the height of the minibuffer sometimes expands from one line to two lines as run-latexmk and after it has run it pops back to one line height. I have had problems finding a simple example to reproduce this behavior (I've only reproduced it for very large documents).

I would like a solution for both problems. I'd also be interested in other ways for me to interact with latexmk in Emacs.


Here's the *... output* buffer from the last example (the one with missing closing curly bracket of ewcommand:

Running `latexmk' on `test' with ``latexmk''
Latexmk: This is Latexmk, John Collins, 10 October 2011, version: 4.27a.
**** Report bugs etc to John Collins <collins at phys.psu.edu>. ****
Rule 'pdflatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'test.tex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex -recorder -halt-on-error -interaction=nonstopmode -shell-escape -synctex=1  -recorder  "test.tex"'
------------
Latexmk: applying rule 'pdflatex'...
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
 write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman-x-2011-07-01, ngerman-x-2011-07-01, afrikaans, ancientgreek, ibycus, arabi
c, armenian, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danis
h, dutch, ukenglish, usenglishmax, esperanto, estonian, ethiopic, farsi, finnis
h, french, galician, german, ngerman, swissgerman, monogreek, greek, hungarian,
 icelandic, assamese, bengali, gujarati, hindi, kannada, malayalam, marathi, or
iya, panjabi, tamil, telugu, indonesian, interlingua, irish, italian, kurmanji,
 lao, latin, latvian, lithuanian, mongolian, mongolianlmc, bokmal, nynorsk, pol
ish, portuguese, romanian, russian, sanskrit, serbian, serbianc, slovak, sloven
ian, spanish, swedish, turkish, turkmen, ukrainian, uppersorbian, welsh, loaded
.
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/size10.clo)))
Runaway argument?
{ egin {document} end {document} 
! File ended while scanning use of @argdef.
<inserted text> 
                par 
<*> test.tex

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on test.log.
Collected error summary (may duplicate other messages):
  pdflatex: Command for 'pdflatex' gave return code 256
Latexmk: Use the -f option to force complete processing.
Latexmk: Errors, so I did not complete making targets

latexmk exited at Thu Oct 27 08:11:07

The following is output from the TeX file that makes *TeX Help* show Emergency stop.:

Running `latexmk' on `laskurs_logik.hemtenta' with ``latexmk''
Latexmk: This is Latexmk, John Collins, 10 October 2011, version: 4.27a.
**** Report bugs etc to John Collins <collins at phys.psu.edu>. ****
Rule 'pdflatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'laskurs_logik.hemtenta.tex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex -recorder -halt-on-error -interaction=nonstopmode -shell-escape -synctex=1  -recorder  "laskurs_logik.hemtenta.tex"'
------------
Latexmk: All targets (laskurs_logik.anteckningar.pdf) are up-to-date
Latexmk: applying rule 'pdflatex'...
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
 write18 enabled.
entering extended mode
(./laskurs_logik.hemtenta.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman-x-2011-07-01, ngerman-x-2011-07-01, afrikaans, ancientgreek, ibycus, arabi
c, armenian, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danis
h, dutch, ukenglish, usenglishmax, esperanto, estonian, ethiopic, farsi, finnis
h, french, galician, german, ngerman, swissgerman, monogreek, greek, hungarian,
 icelandic, assamese, bengali, gujarati, hindi, kannada, malayalam, marathi, or
iya, panjabi, tamil, telugu, indonesian, interlingua, irish, italian, kurmanji,
 lao, latin, latvian, lithuanian, mongolian, mongolianlmc, bokmal, nynorsk, pol
ish, portuguese, romanian, russian, sanskrit, serbian, serbianc, slovak, sloven
ian, spanish, swedish, turkish, turkmen, ukrainian, uppersorbian, welsh, loaded
.
(/usr/local/texlive/2011/texmf-dist/tex/latex/nag/nag.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/nag/nag-l2tabu.cfg)
(/usr/local/texlive/2011/texmf-dist/tex/latex/nag/nag-orthodox.cfg))fatal: Not a git repository (or any parent up to mount parent /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
 (./vc.tex)
 (/usr/local/texlive/2011/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/leqno.clo)
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/fleqn.clo)
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/inputenc.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/utf8.def
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/t1enc.dfu)
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/ot1enc.dfu)
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/omsenc.dfu)))
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/t1enc.def))
(/usr/local/texlive/2011/texmf-dist/tex/latex/lm/lmodern.sty)
(/usr/local/texlive/2011/texmf-dist/tex/latex/base/fixltx2e.sty) (./strict.sty)
(/usr/local/texlive/2011/texmf-dist/tex/latex/tools/verbatim.sty)
(/usr/local/texlive/2011/texmf-dist/tex/latex/enumitem/enumitem.sty)
(/usr/local/texlive/2011/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.te
x)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
(/usr/local/texlive/2011/texmf-dist/tex/latex/ms/everyshi.sty))
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex))
(/usr/local/texlive/2011/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2011/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2011/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/local/texlive/2011/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))))
(/usr/local/texlive/2011/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c
ode.tex))
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-pdftex.d
ef
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-p
df.def)))
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.
code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.
code.tex)) (/usr/local/texlive/2011/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/latexconfig/color.cfg))
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex
)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.
tex
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic
.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigo
nometric.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.rando
m.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.compa
rison.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.
code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round
.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.
code.tex)))
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex)
)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.co
de.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconst
ruct.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage
.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.co
de.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicst
ate.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransform
ations.code.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.cod
e.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.c
ode.tex)
(/usr/local/texlive/2011/texmf-dist/tex/generi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is a problem with how latexmk is being invoked. It is invoked with no arguments and so it tries to compile all tex files in the directory including the newly created vc.tex. This of course causes problems because vc.tex can't be compiled and so you get an error every time.

Starting from the function you have it is fairly easy to fix using TeX-command-expand like:

(defun run-latexmk ()
  (interactive)
  (let ((TeX-save-query nil)
        (TeX-process-asynchronous nil)
        (master-file (TeX-master-file)))
    (TeX-save-document "")
    (TeX-run-TeX "latexmk"
                 (TeX-command-expand "latexmk %t" 'TeX-master-file)
                 master-file)
    (if (plist-get TeX-error-report-switches (intern master-file))
        (TeX-next-error t)
      (minibuffer-message "latexmk done"))))

EDIT: In order to fix the problem with the "TeX Live 2011" buffer, you have to use the other answer as well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...