On Thu, Sep 15, 2011 at 4:16 PM, Jakson Alves de Aquino
<jalve...@gmail.com> wrote:
> On Thu, Sep 15, 2011 at 3:51 PM, Donald Allen <donaldcal...@gmail.com> wrote:
>> If you have following in a vim buffer, file named, say, foo.awk
>>
>> /some test/ {
>> if (foo != "bar") {
>> if (baz != ""){
>> array1[xyz] = N
>> if (N > max_N) max_N = N
>> }
>> xyz = temp[1]
>> # Create
>> print "," > "something.sql"
>> split(description,temp,parse_descriptions[file])
>> print "\t-- "temp[1] > "something.sql"
>> printf "\t%s %s", xyz, pg_type > "something.sql"
>> # Load
>> insert = insert",\n\t"xyz
>> fields[M]=xyz
>> M++
>> N = 1
>> }
>> field_to_XX_field[xyz,N] = field
>> N++
>> }
>>
>> position the cursor on the '{' that ends the first line. Then do =%. You get
>
> [...]
>
> I guess that the R indent script may work better for awk code. The awk
> script was my starting point to develop the R one. Could you please
> set the file type as "r" before indenting the code and tell us whether
> the indentation becomes correct? As you certainly know, to set the
> file type you should do:
>
> :set ft=r
>
> Note: Bram added the indent/r.vim to Vim's runtime recently (today, I think).

I tried this with the same build of vim as I used for the example in
my original post, current as of last night (on the East Coast of the
US). Setting the filetype to R does indeed produce the correct result,
but after a 3-second delay. Doing the same in emacs/viper is
essentially instantaneous.

Now, honesty compells me to mention that I am running this on a
home-brew micro-ITX machine with an Intel D510MO motherboard, which
includes a dual-core 1.6 Ghz Atom processor. Each core is equivalent
in performance to about an 800 Mhz Core 2 processor, so about 3x
slower than the Intel processors we routinely encounter. So while you
could argue that this would be 3x less a problem on a normal
processor, I think you need to look at your algorithm. I tried it on a
300-line section of awk code and it took 15 or 20 seconds on this
machine, so this gets too slow pretty quickly as the number of lines
increases That's going to be annoying even on a normal machine.
emacs/viper took about a second to indent this same section.

Thanks for your response. Despite the performance issue, which I'm
confident can be fixed, your R version is a definite improvement over
the awk version.

/Don

>
> Best regards,
>
> Jakson Aquino
>
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui