On Thu, Oct 14, 2021 at 12:18 AM Ikumi Keita <ik...@ikumi.que.jp> wrote:
>
> >>>>> Hongyi Zhao <hongyi.z...@gmail.com> writes:
> >> 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.
>
> After reconsideration, I came to think that it's better to clear process
> buffer only when emacs is going to restart latexmf process.  Here is my
> second proposal:
>
> (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))
>       (unless (and (processp my-AUCTeX-process)
>                    (eq (process-status my-AUCTeX-process) 'run))
>         (let ((buf (get-buffer-create "*Background TeX proccess*")))
>           (erase-buffer buf) ;; flush previous log
>           (setq my-AUCTeX-process
>                 (start-process-shell-command
>                  "Background TeX" buf
>                  ;; 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))))

When the buffer is saved, the following error will be triggered:

let: Wrong number of arguments: erase-buffer, 1

> I hope this works.
>
> Bye,
> Ikumi Keita

Reply via email to