On Sat, May 6, 2023 at 11:14 PM Hongyi Zhao <hongyi.z...@gmail.com> wrote:
>
> On Sat, May 6, 2023 at 10:31 PM Ikumi Keita <ik...@ikumi.que.jp> wrote:
> >
> > >>>>> Hongyi Zhao <hongyi.z...@gmail.com> writes:
> > >> (1) Does "latexmk -pv FILENAME" work as expected when you issue the
> > >> command on some shell, in the directory the file is located?
> >
> > > In fact, my latexmk configuration, aka, `/home/werner/.latexmkrc` was
> > > set by me very long ago.
> >
> > > See below:
> >
> > [...]
> >
> > > It's very strange that I don't have any acroread related config in
> > > `/home/werner/.latexmkrc`, why does it complain the following:
> >
> > > sh: 1: acroread: not found
> >
> > Then it isn't an AUCTeX issue. Unfortunately, I don't know latexmk. I
> > hope someone familiar with latexmk chimes in. :-)
> >
> > If no one does, I'd recommend to ask at latexmk support commnunity.
>
> Thanks for the tip!

Now, all works smoothly. The problem reported here is caused by my
mismatching configuration of latexmk and the Emacs smart-compile
package. Here is the current working configuration:

The latexmk configuration:

werner@X10DAi:~$ grep -v '^[ ]*#' ~/.latexmkrc | awk 'NF >0'
$show_time=1;
$pdf_mode = 1;
$pdflatex = "pdflatex -shell-escape -file-line-error -halt-on-error
-interaction=nonstopmode -synctex=1 %O %S";
$bibtex = "bibtex %O %S";
$bibtex_use = 2;
$makeindex = "makeindex %O -o %D %S";
$silence_logfile_warnings = 1;
   add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' );
   add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
   $clean_ext .= " acr acn alg glo gls glg";
   sub makeglossaries {
      my ($base_name, $path) = fileparse( $_[0] );
      pushd $path;
      my $return = system "makeglossaries", $base_name;
      popd;
      return $return;
   }
add_cus_dep( 'svg', 'pdf', 0, 'makesvg2pdf' );
sub makesvg2pdf {
    system( "inkscape \"$_[0].svg\" --export-pdf=\"$_[0].pdf\"" );
}
$pdf_previewer = 'evince %O %S';


The Emacs init.el configuration:

(defvar hz/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 hz/AUCTeX-process)
           (eq (process-status hz/AUCTeX-process) 'run))
    (let ((buf (get-buffer-create "*Background TeX proccess*")))
      (with-current-buffer buf (erase-buffer)) ;; flush previous log
      (setq hz/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))))


N.B.: In fact, we discussed the similar question a long time ago on
this list [1-2].

[1] https://lists.gnu.org/archive/html/auctex/2021-07/msg00013.html
[2] https://tam5917.hatenablog.com/entry/2021/04/10/134230

Regards,
Zhao

Reply via email to