Mads Jensen <m...@inducks.org> 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

_______________________________________________
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to