[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX] test if buffer is a standalone document
From: |
Mosè Giordano |
Subject: |
Re: [AUCTeX] test if buffer is a standalone document |
Date: |
Tue, 12 May 2015 11:02:14 +0200 |
Hi Tamas,
2015-05-12 10:43 GMT+02:00 Tamas Papp <address@hidden>:
> Hi,
>
> I have a setup where I automatically compile a tex file upon saving, but
> only if it is a standalone document (eg not something included by
> another file):
>
> (defun LaTeX-in-document-p ()
> (interactive)
> (save-excursion
> (goto-char (point-min))
> (search-forward "documentclass" (point-max) t)))
>
> (defun LaTeX-compile-on-save ()
> (when (LaTeX-in-document-p)
> (TeX-command "LaTeX" 'TeX-master-file)))
>
> with
>
> (add-hook 'after-save-hook 'LaTeX-compile-on-save t t)
>
> executed by LaTeX-mode-hook.
>
> I am wondering if this setup could be improved with AUCTeX:
>
> 1. Is there a better way to test for LaTeX-in-document-p?
>
> 2. If A.tex includes B.tex, is there a way to compile A.tex when saving
> B.tex?
If B.tex is included in A.tex and has `TeX-master' correctly set,
(TeX-command "LaTeX" 'TeX-master-file) does the right thing, so what's
the problem?
Bye,
Mosè