[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] LaTeX-env-document
From: |
Tassilo Horn |
Subject: |
Re: [AUCTeX-devel] LaTeX-env-document |
Date: |
Wed, 02 Jan 2013 13:27:57 +0100 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) |
Mads Jensen <address@hidden> writes:
> I have one more suggestion for `LaTeX-env-document': prevent
> documentclass from being inserted, if there's already one present in the
> file. At least I find it somewhat annoying to be prompted for it.
That's a better idea than omitting the document environment as you've
suggested in your other mail.
--- latex.el 30 Dec 2012 19:47:08 +0100 5.476
+++ latex.el 02 Jan 2013 13:02:43 +0100
@@ -764,7 +764,10 @@
(defun LaTeX-env-document (&optional ignore)
"Create new LaTeX document.
The compatibility argument IGNORE is ignored."
- (TeX-insert-macro "documentclass")
+ (save-excursion
+ (unless (re-search-backward "^\\\\documentclass.*{" nil t)
+ (TeX-insert-macro "documentclass")))
Some comments:
- The \documentclass macro doesn't need to start a line.
- A commented \documentclass shouldn't prevent it being inserted.
- The regex is a bit too lax, e.g., maybe someone has a
\documentclasssetup, which would also be matched by your regex.
You might want to have a look at `LaTeX-current-environment' wrt. the
comment stuff.
Bye,
Tassilo