From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/25857 Path: news.gmane.org!not-for-mail From: Mojca Miklavec Newsgroups: gmane.comp.tex.context Subject: Re: Identifying context files Date: Sat, 4 Feb 2006 15:41:03 -0800 Message-ID: <6faad9f00602041541y5bd88b94yb2803caf347a7d3d@mail.gmail.com> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1139096479 15319 80.91.229.2 (4 Feb 2006 23:41:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 4 Feb 2006 23:41:19 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Sun Feb 05 00:41:15 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1F5X1l-0005NV-3v for gctc-ntg-context-518@m.gmane.org; Sun, 05 Feb 2006 00:41:13 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id E430F127B7; Sun, 5 Feb 2006 00:41:11 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 21126-06; Sun, 5 Feb 2006 00:41:07 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 493141278E; Sun, 5 Feb 2006 00:41:07 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 8E5811278E for ; Sun, 5 Feb 2006 00:41:05 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 21082-06 for ; Sun, 5 Feb 2006 00:41:04 +0100 (CET) Original-Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.198]) by ronja.ntg.nl (Postfix) with SMTP id 5D53A12784 for ; Sun, 5 Feb 2006 00:41:04 +0100 (CET) Original-Received: by uproxy.gmail.com with SMTP id m2so362559uge for ; Sat, 04 Feb 2006 15:41:03 -0800 (PST) Original-Received: by 10.48.108.11 with SMTP id g11mr856199nfc; Sat, 04 Feb 2006 15:41:03 -0800 (PST) Original-Received: by 10.48.14.18 with HTTP; Sat, 4 Feb 2006 15:41:03 -0800 (PST) Original-To: mailing list for ConTeXt users In-Reply-To: Content-Disposition: inline X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:25857 Archived-At: 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)? 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. 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. > 2. Are there any other keywords that you will like to include. A keyword like set tex_preferred_dialect=latex/context :) 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) (don't take that suggestion too seriously) Mojca