[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Detect latexmk is running on currently buffer.
From: |
Hongyi Zhao |
Subject: |
Re: Detect latexmk is running on currently buffer. |
Date: |
Wed, 13 Oct 2021 20:34:28 +0800 |
On Wed, Oct 13, 2021 at 8:11 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> On Wed, Oct 13, 2021 at 5:19 PM Ikumi Keita <ikumi@ikumi.que.jp> wrote:
> >
> > Hi Hongyi,
> >
> > >>>>> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> >
> > > Though the above method works, I meet a problem when the project LaTeX
> > > files are large to some extent. To be more specific, when the project
> > > is large to a certain extent, the compilation time of latexmk will be
> > > relatively long, which may lead to the following race condition: When
> > > the previous latexmk process has not ended, the subsequent latexmk
> > > process is launched again.
> >
> > > Any hints for fixing this problem?
> >
> > Maybe the following stuff works, though I haven't test it.
> >
> > (defvar my-AUCTeX-process nil)
> > (use-package smart-compile
> > :init
> > (declare-function smart-compile-string "smart-compile")
> > (defun run-latexmk ()
> > (when (string-match ".tex$" (buffer-file-name))
> > (let ((buf (get-buffer "*Background TeX proccess*")))
> > (if (bufferp buf) (kill-buffer buf))) ;; flush previous log
> > (unless (and (processp my-AUCTeX-process)
> > (eq (process-status my-AUCTeX-process) 'run))
> > (setq my-AUCTeX-process
> > (start-process-shell-command
> > "Background TeX" "*Background TeX proccess*"
> > ;; use an external application as the previewer
> > ;;(smart-compile-string "latexmk -pv %f")
> >
> > ;; use pdf-tools
> > (smart-compile-string "latexmk %f"))))))
> > (define-minor-mode AutoTeX-mode
> > "Mode for compiling latex sources and creating PDFs after saving."
> > :global nil
> > :lighter " Auto"
> > (if AutoTeX-mode
> > (add-hook 'after-save-hook 'run-latexmk t t)
> > (remove-hook 'after-save-hook 'run-latexmk t)))
> >
> > :hook (LaTeX-mode . (lambda () (AutoTeX-mode 1))))
>
> Thank you very much for your improvement, I'll test and feedback.
I've tested with this project [1]. It seems that the background
latexmk process failed to compile the master latex file after I made
some changes and saved it.
[1] https://gitlab.kwant-project.org/jbweston/thesis
But I can't sure this is caused by the above code revision,
considering that the above LaTeX project is very complicated in
itself.
HZ
- Detect latexmk is running on currently buffer., Hongyi Zhao, 2021/10/11
- Re: Detect latexmk is running on currently buffer., Ikumi Keita, 2021/10/13
- Re: Detect latexmk is running on currently buffer., Hongyi Zhao, 2021/10/13
- Re: Detect latexmk is running on currently buffer.,
Hongyi Zhao <=
- Re: Detect latexmk is running on currently buffer., Ikumi Keita, 2021/10/13
- Re: Detect latexmk is running on currently buffer., Hongyi Zhao, 2021/10/14
- Re: Detect latexmk is running on currently buffer., Hongyi Zhao, 2021/10/14
- Re: Detect latexmk is running on currently buffer., Ikumi Keita, 2021/10/14
- Re: Detect latexmk is running on currently buffer., Hongyi Zhao, 2021/10/14