* Detect latexmk is running on currently buffer.
@ 2021-10-12 7:54 Hongyi Zhao
2021-10-12 9:32 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 9+ messages in thread
From: Hongyi Zhao @ 2021-10-12 7:54 UTC (permalink / raw)
To: help-gnu-emacs
Currently, I'm using the following configuration to automate the LaTeX
workflow in Emacs with AUCTeX:
```emacs-lisp
;; Automatically revert a buffer when the corresponding file on disk is updated.
(global-auto-revert-mode 1)
(setq auto-revert-use-notify nil)
;; Automatically save the buffer to disk periodically.
(use-package real-auto-save
:hook ((TeX-mode python-mode) . real-auto-save-mode)
:config
(setq real-auto-save-interval 5) ;; in seconds
)
;; After the buffer is changed and saved to disk, run latexmk on the
;; corresponding file immediately.
;;See ~/.latexmkrc for correspoding configuration
(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
(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)))
)
```
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?
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Detect latexmk is running on currently buffer.
2021-10-12 7:54 Detect latexmk is running on currently buffer Hongyi Zhao
@ 2021-10-12 9:32 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-12 12:08 ` Hongyi Zhao
2021-10-12 12:15 ` Hongyi Zhao
0 siblings, 2 replies; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-12 9:32 UTC (permalink / raw)
To: help-gnu-emacs
Hongyi Zhao wrote:
> 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?
I use the "LaTeX mode defined in ‘tex-mode.el’" and there is
an important difference compared to yours, which is in line
with our respective styles, ha.
Anyway with LaTeX have a Makefile and just hammer it ... to
avoid getting institutionalized, don't ONLY do that, do
something else, light work (shell programming, even reading)
on the side, literally, and if/when you forget about LaTeX, do
force yourself to be reminded :)
I've seen calm guys punch into fences and stuff because that
constant recompilation can become a form of
self-torture, almost, soo frustrating. ha
Makefile example:
https://dataswamp.org/~incal/borta/Makefile
Some helpers:
https://dataswamp.org/~incal/emacs-init/latex.el
Bibtex:
https://dataswamp.org/~incal/emacs-init/bibtex-incal.el
https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-next-volume.el
Very creative TeX, some would say :)
https://dataswamp.org/~incal/borta/borta.pdf
https://dataswamp.org/~incal/borta/
https://dataswamp.org/~incal/hs-linux/docs/report/report.pdf
https://dataswamp.org/~incal/hs-linux/docs/report/
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Detect latexmk is running on currently buffer.
2021-10-12 9:32 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-12 12:08 ` Hongyi Zhao
2021-10-12 12:58 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-12 12:15 ` Hongyi Zhao
1 sibling, 1 reply; 9+ messages in thread
From: Hongyi Zhao @ 2021-10-12 12:08 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
On Tue, Oct 12, 2021 at 5:53 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > 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?
>
> I use the "LaTeX mode defined in ‘tex-mode.el’" and there is
> an important difference compared to yours, which is in line
> with our respective styles, ha.
>
> Anyway with LaTeX have a Makefile and just hammer it ... to
> avoid getting institutionalized, don't ONLY do that, do
> something else, light work (shell programming, even reading)
> on the side, literally, and if/when you forget about LaTeX, do
> force yourself to be reminded :)
>
> I've seen calm guys punch into fences and stuff because that
> constant recompilation can become a form of
> self-torture, almost, soo frustrating. ha
>
> Makefile example:
> https://dataswamp.org/~incal/borta/Makefile
>
> Some helpers:
> https://dataswamp.org/~incal/emacs-init/latex.el
>
> Bibtex:
> https://dataswamp.org/~incal/emacs-init/bibtex-incal.el
> https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-next-volume.el
>
> Very creative TeX, some would say :)
> https://dataswamp.org/~incal/borta/borta.pdf
> https://dataswamp.org/~incal/borta/
> https://dataswamp.org/~incal/hs-linux/docs/report/report.pdf
> https://dataswamp.org/~incal/hs-linux/docs/report/
OMG, wonderful man with wonderful ideas and ELISP treasures!
HZ
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Detect latexmk is running on currently buffer.
2021-10-12 9:32 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-12 12:08 ` Hongyi Zhao
@ 2021-10-12 12:15 ` Hongyi Zhao
2021-10-12 12:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 9+ messages in thread
From: Hongyi Zhao @ 2021-10-12 12:15 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
On Tue, Oct 12, 2021 at 5:53 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> > 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?
>
> I use the "LaTeX mode defined in ‘tex-mode.el’" and there is
> an important difference compared to yours, which is in line
> with our respective styles, ha.
It's called `latex-mode', as shown by `C-h o latex-mode RET':
latex-mode is an interactive native compiled Lisp function in
‘tex-mode.el’.
(latex-mode)
>
> Anyway with LaTeX have a Makefile and just hammer it ... to
> avoid getting institutionalized, don't ONLY do that, do
> something else, light work (shell programming, even reading)
> on the side, literally, and if/when you forget about LaTeX, do
> force yourself to be reminded :)
>
> I've seen calm guys punch into fences and stuff because that
> constant recompilation can become a form of
> self-torture, almost, soo frustrating. ha
>
> Makefile example:
> https://dataswamp.org/~incal/borta/Makefile
>
> Some helpers:
> https://dataswamp.org/~incal/emacs-init/latex.el
>
> Bibtex:
> https://dataswamp.org/~incal/emacs-init/bibtex-incal.el
> https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-next-volume.el
>
> Very creative TeX, some would say :)
> https://dataswamp.org/~incal/borta/borta.pdf
> https://dataswamp.org/~incal/borta/
> https://dataswamp.org/~incal/hs-linux/docs/report/report.pdf
> https://dataswamp.org/~incal/hs-linux/docs/report/
>
> --
> underground experts united
> https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Detect latexmk is running on currently buffer.
2021-10-12 12:08 ` Hongyi Zhao
@ 2021-10-12 12:58 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-12 12:58 UTC (permalink / raw)
To: help-gnu-emacs
Hongyi Zhao wrote:
> OMG, wonderful man with wonderful ideas and ELISP treasures!
Well, let's not get carried away here ... but OK, thanks, I'll
take it to prevent the deadlock LOL :)
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Detect latexmk is running on currently buffer.
2021-10-12 12:15 ` Hongyi Zhao
@ 2021-10-12 12:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-12 13:10 ` Hongyi Zhao
0 siblings, 1 reply; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-12 12:59 UTC (permalink / raw)
To: help-gnu-emacs
Hongyi Zhao wrote:
>> I use the "LaTeX mode defined in ‘tex-mode.el’" and there
>> is an important difference compared to yours, which is in
>> line with our respective styles, ha.
>
> It's called `latex-mode', as shown by `C-h o latex-mode
> RET':
>
> latex-mode is an interactive native compiled Lisp function
> in ‘tex-mode.el’.
>
> (latex-mode)
OK, so what is the difference between the other mode then?
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Detect latexmk is running on currently buffer.
2021-10-12 12:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-12 13:10 ` Hongyi Zhao
2021-10-12 13:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 9+ messages in thread
From: Hongyi Zhao @ 2021-10-12 13:10 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
On Tue, Oct 12, 2021 at 9:00 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> Hongyi Zhao wrote:
>
> >> I use the "LaTeX mode defined in ‘tex-mode.el’" and there
> >> is an important difference compared to yours, which is in
> >> line with our respective styles, ha.
> >
> > It's called `latex-mode', as shown by `C-h o latex-mode
> > RET':
> >
> > latex-mode is an interactive native compiled Lisp function
> > in ‘tex-mode.el’.
> >
> > (latex-mode)
>
> OK, so what is the difference between the other mode then?
https://www.gnu.org/software/emacs/manual/html_node/reftex/Installation.html
1.1.3 Entering RefTeX Mode
To turn RefTeX Mode on and off in a particular buffer, use M-x
reftex-mode RET. To turn on RefTeX Mode for all LaTeX files, add the
following lines to your .emacs file:
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
HZ
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Detect latexmk is running on currently buffer.
2021-10-12 13:10 ` Hongyi Zhao
@ 2021-10-12 13:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-12 17:33 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-12 13:23 UTC (permalink / raw)
To: help-gnu-emacs
Hongyi Zhao wrote:
>> OK, so what is the difference between the other mode then?
>
> https://www.gnu.org/software/emacs/manual/html_node/reftex/Installation.html
>
> 1.1.3 Entering RefTeX Mode
>
> To turn RefTeX Mode on and off in a particular buffer, use
> M-x reftex-mode RET. To turn on RefTeX Mode for all LaTeX
> files, add the following lines to your .emacs file:
>
> (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
> (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
0 point awarded.
Yeah, this exam is tough but no one said it was supposed to be
simple ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Detect latexmk is running on currently buffer.
2021-10-12 13:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-12 17:33 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-12 17:33 UTC (permalink / raw)
To: help-gnu-emacs
>> (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
>> (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
>
> 0 point awarded.
>
> Yeah, this exam is tough but no one said it was supposed to
> be simple ...
Ah, I can't find the quote!
It is by S. Monnier anyway. Please tell him (the OP) if/as you
understand what I refer to ...
But I do remember, only I don't want to quote from memory
because my understanding of this is superficial ...
But, it has to do with LaTeX packages and how the different
modes handle that!
B)
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-10-12 17:33 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-12 7:54 Detect latexmk is running on currently buffer Hongyi Zhao
2021-10-12 9:32 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-12 12:08 ` Hongyi Zhao
2021-10-12 12:58 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-12 12:15 ` Hongyi Zhao
2021-10-12 12:59 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-12 13:10 ` Hongyi Zhao
2021-10-12 13:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-12 17:33 ` Emanuel Berg via Users list for the GNU Emacs text editor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).