From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/25927 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: Identifying context files Date: Sat, 11 Feb 2006 02:05:23 -0500 (EST) Message-ID: References: <6faad9f00602041541y5bd88b94yb2803caf347a7d3d@mail.gmail.com> 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 1139641650 29171 80.91.229.2 (11 Feb 2006 07:07:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 11 Feb 2006 07:07:30 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Sat Feb 11 08:07:27 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 1F7oqr-0006Q6-AQ for gctc-ntg-context-518@m.gmane.org; Sat, 11 Feb 2006 08:07:25 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id EB5891277B; Sat, 11 Feb 2006 08:07:24 +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 16125-03; Sat, 11 Feb 2006 08:07:24 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id EE5341278F; Sat, 11 Feb 2006 08:05:34 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id B937F1278F for ; Sat, 11 Feb 2006 08:05:33 +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 16174-05 for ; Sat, 11 Feb 2006 08:05:33 +0100 (CET) Original-Received: from withoutevidence.mr.itd.umich.edu (withoutevidence.mr.itd.umich.edu [141.211.93.147]) by ronja.ntg.nl (Postfix) with SMTP id ABE601277B for ; Sat, 11 Feb 2006 08:05:32 +0100 (CET) Original-Received: from aditya.annarb01.mi.comcast.net (c-68-40-50-205.hsd1.mi.comcast.net [68.40.50.205]) by withoutevidence.mr.itd.umich.edu (smtp) with ESMTP id k1B75PHg028432 for ; Sat, 11 Feb 2006 02:05:30 -0500 Original-To: mailing list for ConTeXt users In-Reply-To: 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:25927 Archived-At: <--- On Feb 10, Aditya Mahajan wrote ---> > <--- On Feb 4, Mojca Miklavec wrote ---> > >> 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. This is the else part of the script (modified from Hans ruby code to vimL). I tested it on the sources of the manuals, and the only thing that it could not detect correctly was metafun/mfun-ef.tex. Looking at that file, I do not think that it contains any context specific keyword. Can others test on their context projects and see if this works correctly. I do not know the itnernational alternatives of all the commands. If your document uses any of those, let me know. Also check your latex documents to see that the script does not recognise it as context. To run the script, save it as identify.vim . Inside vim, :source identify.vim :cd directory containing tex files :argadd *.tex :redir @a :argdo call Identify_ConTeXt() :redir END :e temp_file :put a Now you have all the vim messages in temp_file :g!/ConTeXt/d Get rid of lines not containing context. The message format from the script is filename ConTeXt not detected/ detected at line ... format (en|nl|de|it) Here is the script """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " A bit more detailed evaluation for english. \\set and \\use may be too " ambiguous. Checking for setvariables and use encoding let g:ConTeXt_en = \ '\\\(starttext\|startproject\|startproduct\|startcomponent\|startenvironment'. \ '\|enablemode\|enableregime\|setvariables\|useencoding\|setup' . \ '\|starttypescript' . \ '\|usemodule\|externalfigure\)' let g:ConTeXt_nl = \ '\\\(starttekst\|startprodukt\|startprojekt\|startonderdeel\|startdocument\|startoverzicht'. \ '\|stel\|gebruik\|omgeving' . \ '\|externfiguur\)' let g:ConTeXt_de = \ '\\\(stelle\|verwende\|umgebung\|benutze' . \ '\|externeabbildung\)' let g:ConTeXt_it = \ '\\\(usa\|imposta\|ambiente' . \ '\|figuraesterna\)' let g:ConTeXt_generic = \ '\\\(protect\|unprotect\|startmode\|mainlanguage\)' function! Identify_ConTeXt() let g:ConTeXt_texformat = "" let l:last_line_num = line('$') let l:curr_line_num = 1 while l:curr_line_num <= l:last_line_num let l:curr_line = getline(l:curr_line_num) if l:curr_line !~ '^%' if l:curr_line =~ g:ConTeXt_en let g:ConTeXt_texformat = 'en' break endif if l:curr_line =~ g:ConTeXt_generic let g:ConTeXt_texformat = 'generic' endif if l:curr_line =~ g:ConTeXt_nl let g:ConTeXt_texformat = 'nl' break endif if l:curr_line =~ g:ConTeXt_de let g:ConTeXt_texformat = 'de' break endif if l:curr_line =~ g:ConTeXt_it let g:ConTeXt_texformat = 'it' break endif endif let l:curr_line_num = l:curr_line_num + 1 endwhile if g:ConTeXt_texformat == "" echo bufname("%") . ' ConTeXt not detected!' else echo bufname("%") . ' ConTeXt detected at line ' . l:curr_line_num . \ ' format: ' . g:ConTeXt_texformat endif endf """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -- Aditya Mahajan, EECS Systems, University of Michigan http://www.eecs.umich.edu/~adityam || Ph: 7342624008