ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
Subject: Re: Identifying context files
Date: Fri, 10 Feb 2006 23:59:00 -0500 (EST)	[thread overview]
Message-ID: <Pine.WNT.4.63.0602102353270.1048@nqvgln> (raw)
In-Reply-To: <6faad9f00602041541y5bd88b94yb2803caf347a7d3d@mail.gmail.com>

<--- On Feb 4, Mojca Miklavec wrote --->

> On 2/2/06, Aditya Mahajan wrote:
>> I use (g)vim to edit both context and latex files. Unfortunately, both
>> of them usually have *.tex extension. This mean that detecting
>> filetype from extension is not possible, so one should look into the
>> contents of the file to see if it a context file or not.
>>
>> I am planning to submit a ftdetect for context to vim. Right now, I
>> check if the first six lines of the file contain any of
>> '\\start\|\\enablemode\|\\unprotect\|\\setvariables\|\\module\|\\usemodule'
>> and if so, set the filetype to context, otherwise it is set to tex
>> (that loads latex plugins).
>>
>> This works for my context writing style. I would like to know about
>> other people's preference.
>>
>> 1. Do you write some keyword unique to context in the first few lines
>> of the file. Should I also check the last few line lines.
>
> \enableregime, \setupoutput
>
> Is \setup too general (will it recognize any LaTeX document)?

That is the main trouble. In principle, you can have latex document 
with \starttext as the first line. But most usual tex files do not 
have it. I have not seen a latex macro with \setup. So, I will include 
that also.

> I don't know how slow/fast the detection is since I only use short
> files, but if you check the last few lines, \stoptext (together with
> its international alternatives) isn't a bad idea.

The file may not necessarily end with \stoptext. It can be 
\stopcomponent, \stopproduct, \stopproject, \stopenvironment. Anything 
else?

> Also, if you check the last few lines: emacs users usually put some
> lines of code at the end to mark the document as being written in
> ConTeXt.

Ah, compatibility with Emacs. I will look at that later ;)

>> 2. Are there any other keywords that you will like to include.
>
> A keyword like
> set tex_preferred_dialect=latex/context :)

I looked it up and it seems that g:Tex_Flavor is meant for this kind 
of thing.

> and then
>
> if tex_preferred_dialect == context
>    if the first few lines contain \documentclass or \documentstyle,
>    declare it latex, otherwise ConTeXt
> else
>   [your script]:
>   if the first line contains % tex= or any keywords that Hans sent
>   or if the first six lines contain the keywords you suggested
> (together with international alternatives)

Actually, this may not be too hard to implement. Let me have a look at 
this, and I will get back to you when there is something working.

Aditya
-- 
Aditya Mahajan, EECS Systems, University of Michigan
http://www.eecs.umich.edu/~adityam || Ph: 7342624008

  reply	other threads:[~2006-02-11  4:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-03  2:17 Aditya Mahajan
2006-02-03  7:10 ` Thomas A. Schmitz
2006-02-03  8:15   ` Hans Hagen
2006-02-03  8:22     ` Taco Hoekwater
2006-02-03  9:24       ` Hans Hagen
2006-02-03 17:22     ` Aditya Mahajan
2006-02-03 20:47       ` Hans Hagen
2006-02-04 23:41 ` Mojca Miklavec
2006-02-11  4:59   ` Aditya Mahajan [this message]
2006-02-11  7:05     ` Aditya Mahajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.WNT.4.63.0602102353270.1048@nqvgln \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).