Article View: gnu.emacs.bug
Article #87954tex-mode doesn't select LaTeX mode for LaTeX2e documents
From: J Scott Berg
Date: Wed, 17 Aug 1994 18:08
Date: Wed, 17 Aug 1994 18:08
83 lines
3298 bytes
3298 bytes
Emacs version: 19.25
IBM RS6000 AIX 3.2.5
./configure rs6000-ibm-aix --with-x11
No modifications to emacs source
There is a fairly recently updated version of LaTeX out known as
LaTeX2e. LaTeX2e requires documents to begin with a command of the
form
\documentclass[options]{doctype}
instead of
\documentstyle{doctype}
or whatever it used to be. The problem is that emacs doesn't realize
that the former is a LaTeX document. So, for example, if both files
file test.tex:
\documentstyle{article}
\begin{document}
Hi there.
\end{document}
file test1.tex:
\documentclass{article}
\begin{document}
Hi there.
\end{document}
The first file will come up in LaTeX mode (indicated in the mode
line), while the second will come up in TeX mode.
I renamed my .emacs file so that it doesn't get loaded, and still got
this error.
Here is a fix that I put into my .emacs that fixes the problem; it
could replace the function definition in tex-mode.el. I've also
included a potential change-log entry:
* tex-mode.el (tex-mode): Choose LaTeX mode based on \documentclass
as well as \documentstyle to be compatible with LaTeX2e; allow options
in \documentclass for slitex-mode.
(defun tex-mode ()
"Major mode for editing files of input for TeX, LaTeX, or SliTeX.
Tries to determine (by looking at the beginning of the file) whether
this file is for plain TeX, LaTeX, or SliTeX and calls `plain-tex-mode',
`latex-mode', or `slitex-mode', respectively. If it cannot be determined,
such as if there are no commands in the file, the value of `tex-default-mode'
says which mode to use."
(interactive)
(let (mode slash comment)
(save-excursion
(goto-char (point-min))
(while (and (setq slash (search-forward "\\" nil t))
(setq comment (let ((search-end (point)))
(save-excursion
(beginning-of-line)
(search-forward "%" search-end t))))))
(if (and slash (not comment))
; Insert my own private improvments for latex2e
(setq mode (if (looking-at "document\\(style\\|class\\)")
(if (looking-at
"document\\(style\\|class\\)\\(\\[.*\\]\\)?{slides}")
'slitex-mode
'latex-mode)
'plain-tex-mode))))
(if mode (funcall mode)
(funcall tex-default-mode))))
Thanks much
-Scott Berg
--
J. Scott Berg Real mail: Varian Physics; Stanford CA 94305-4060
email: ALHY@slac.stanford.edu
phone: (415) 926-4732 (w) (415) 854-2713 (h)
Technical Details
Message-ID:
<9408171801.AA03574@unixhub.SLAC.Stanford.EDU>Path:
arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!redstone.interpath.net!ddsw1!news.cic.net!magnus.acs.ohio-state.edu!math.ohio-state.edu!cis.ohio-state.edu!courant.slac.stanford.edu!alhyShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,cc5cd755a1112a85,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1994-08-17 13:48:45 PST Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!redstone.interpath.net!ddsw1!news.cic.net!magnus.acs.ohio-state.edu!math.ohio-state.edu!cis.ohio-state.edu!courant.slac.stanford.edu!alhy From: alhy@courant.slac.stanford.edu (J Scott Berg) Newsgroups: gnu.emacs.bug Subject: tex-mode doesn't select LaTeX mode for LaTeX2e documents Date: 17 Aug 1994 14:08:14 -0400 Organization: GNUs Not Usenet Lines: 83 Sender: daemon@cis.ohio-state.edu Approved: bug-gnu-emacs@prep.ai.mit.edu Distribution: gnu Message-ID: <9408171801.AA03574@unixhub.SLAC.Stanford.EDU>