Loading ...
Sorry, an error occurred while loading the content.

44719Re: better recognising of tex vs plaintex filetype

Expand Messages
  • Benji Fisher
    Aug 31, 2006
    • 0 Attachment
      On Wed, Aug 30, 2006 at 10:36:09AM -0700, Gautam Iyer wrote:
      > On Wed, Aug 30, 2006 at 07:17:16PM +0200, Stefano Zacchiroli wrote:
      > > > I agree with the comment that plain TeX users may also define such
      > > > sectioning commands. Maybe it would be safe if you check for such
      > > > definitions, using an include-file search ... but of course, that is
      > > > more convenient after ftplugin/plaintex.vim has been :source'd.
      > >
      > > I'm not really fond of plain TeX, but I think it is not really
      > > widespread to \input slices of plain TeX. So the idea mentioned in
      > > this thread was to implement the policy: "if a document starts with a
      > > lot of blanks followed by one of the possible LaTeX sectioning
      > > commands, then it is (probably) a LaTeX source file". What do you
      > > think of this policy?

      I think my undergraduate thesis (1985, plain TeX, just about the
      time the first version of LaTeX came out) was structured that way (i.e.,
      split into separate files, each beginning with a \chapter command or
      something like that. (My thesis was also my introduction to vi.)

      I also had several collections of macros, so my TeX files usually
      started out with

      \magnification 1200
      \input standard
      \input math
      \input smiley

      or something like that. I do not recall whether I defined any
      sectioning commands in these files.

      Now that you describe your proposed policy more, I like it a little
      better. Specifically, I like the idea of looking at the first
      non-comment, non-blank line, since that gets around the problem that
      something that *looks* like LaTeX might be defined in an \input file. I
      would like it better if it were more conservative. The problem is that
      the LaTeX sectioning commands are not very LaTeX-y: if you were looking


      instead of


      then I would be a lot happier.

      > I actually like this policy a lot. Most people who break latex files up
      > into tonnes and tonnes of little files, do so based on sections. Odds
      > are, that the little files will begin with a bunch of comments, and a
      > sectioning command.
      > It would make life easier if this made it into filetype.vim. Especially
      > because changing g:tex_flavor means that every time I edit a plain tex
      > file, I need to unlet this variable.

      Another option is to add one of the lines




      at the top of the plain TeX files (assuming that they are your own).
      This is the most reliable method for determining file the TeX flavor,
      since it overrides a format specified on the command line:

      $ latex myfile

      will *not* load the LaTeX format if myfile.tex starts with one of the
      above lines. The only problem (unless this has changed since the last
      time I checked) is that the pdftex program is not smart enough to change
      %&plain to %&pdfplain .

      For now, I suggest doing what you think is right in the Debian
      package. If plain TeX is really as rare as you think (I do not
      disagree, but I am willing to be surprised!) and there are no
      complaints, then I might vote for a change to the vim distro based on
      feedback from Debian users.

      HTH --Benji Fisher
    • Show all 11 messages in this topic