ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Andreas Schneider <aksdb@gmx.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Custom parameters/options for t-vim
Date: Wed, 31 Aug 2011 09:15:52 +0200	[thread overview]
Message-ID: <4E5DDFA8.3070408@gmx.de> (raw)
In-Reply-To: <alpine.LNX.2.02.1108301233590.4483@ybpnyubfg.ybpnyqbznva>

On 29.08.2011 23:35, Aditya Mahajan wrote:
> On Tue, 30 Aug 2011, Andreas Schneider wrote:
>
>> I worked with t-vim a bit more and encountered a small problem with
>> the way vim handles syntax definitions. Some of them have several
>> modes that get activated by setting a variable first. For example the
>> syntax "sh" (shell scripts) can be enhanced for bash, ksh, etc.
>>
>> Example:
>> let g:is_bash=1
>> set syntax=sh
>>
>> Now a line like "export foo=bar" is highlighted differently than when
>> I would omit the "let g:is_bash=1".
>>
>> Therefore I would propose another options to \setupvimtyping to
>> specify custom options to be passed to vim. Preferably they should be
>> passed at least before the "set syntax=..." line to make sure that
>> this particular case -- i.e. switching syntax modes -- works well
>> (which may be the only necessary case).
>
> That is certainly possible, but the exact solution depends on how robust
> you want it to be. I can easily add an option so that
>
> \definevimtyping
> [....]
> [extras={let g:is_bash=1}]
>
> will pass the argument to vim. However, string arguments like
>
> \definevimtyping
> [....]
> [extras={let g:name="Whatever"}]
>
> will not work. The reason is that, t-vim first creates a command line
> argument that is passed to mtxrun. mtxrun parses the entire expression,
> including all the options, When mtxrun figures out that all the
> arguments were meant for an external program, it recreates the list of
> arguments (to the best of its abilities), and passes the arguments to
> the shell. Then the shell tries to interpret the quotes. I haven't been
> able to find a solution that will work correctly though these three
> transformations.
>
> Another option is to write everything to an external file and source it
> as a vimrc file. So, you could do:
>
> \definevimtyping
> [...]
> [vimrc=shell]
>
> \startvimrc[shell]
> let g:is_bash = 1
> \stopvimrc
>
> This requires more coding, but is much more flexible than the first option.
>
> Do all syntax highlighting options work with 0/1 parameters? If so, then
> the first alternative is easiest.

As far as I can see, most of the relevant options (if not all) are 0/1 
switches, so the first alternative should be enough. Thanks to the pipe 
syntax of vim's command mode, it might be even possible specify more 
parameters that way. [extras={let g:foo=bar | let g:shaz=bot}] -- at 
least vim accepts that usually, I guess it doesn't make a difference if 
specified as commandline parameter.

However I also like the idea of the optional vimrc via buffer. I think 
it might be a nice-to-have feature for the ToDo list :-)

Thank you for the analysis and for coming up with these possible 
implementations!

-- 
Best Regards,
Andreas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2011-08-31  7:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-30 14:27 Andreas Schneider
2011-08-29 21:35 ` Aditya Mahajan
2011-08-31  7:15   ` Andreas Schneider [this message]
2011-08-31 23:00     ` Aditya Mahajan
2011-09-03  6:58       ` Aditya Mahajan
2011-09-06  9:07         ` Andreas Schneider

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=4E5DDFA8.3070408@gmx.de \
    --to=aksdb@gmx.de \
    --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).