There are some metapost indentation problems like the following (.mp
file). Can somebody let me fix them?
Thanks,
Peng
for i = 0 upto 3:
for j = 0 upto 3:
dotlabel ("", (i+.5,j+.5)*8*u);
endfor
endfor
def square(expr x, y, s) =
unitsquare scaled s shifted (x,y)
enddef;
def circle(expr x, y, r) =
fullcircle scaled (2*r) shifted (x,y)
enddef;
I changed a bit of the codes in $VIMRUNTIME/indent/mp.vim to resolve
the indentation problem for nested "FOR". It seems to me that this
modification is working well for your problem. (you can download the
attached mp.vim to replace the original one after you make a backup of
it)
But, as a reminder, the original author mentioned that "First of all,
MetaPost language don't expect any identation rules." So that if you
want other indentation format, you'd better to DIY the mp.vim.
HTH,
--
Best,
Zhaojun (Joseph)
Thank you for your effort. I tried mp.vim and t works for "for". But
it becomes worse for "def". I would like to modify mp.vim by myself
when I have time. Could you please fix the indentation of "def" for
now?
Here is what I get.
def square(expr x, y, s) =
unitsquare scaled s shifted (x,y)
enddef;
def circle(expr x, y, r) =
fullcircle scaled (2*r) shifted (x,y)
enddef;
I want it to be
def square(expr x, y, s) =
unitsquare scaled s shifted (x,y)
enddef;
def circle(expr x, y, r) =
fullcircle scaled (2*r) shifted (x,y)
enddef;
Thanks,
Peng
On 8/2/07, Peng Yu <Peng...@gmail.com> wrote:
> Thank you for your effort. I tried mp.vim and t works for "for". But
> it becomes worse for "def". I would like to modify mp.vim by myself
> when I have time. Could you please fix the indentation of "def" for
> now?
>
> Here is what I get.
>
> def square(expr x, y, s) =
> unitsquare scaled s shifted (x,y)
> enddef;
>
> def circle(expr x, y, r) =
> fullcircle scaled (2*r) shifted (x,y)
> enddef;
>
Actually, I have no any experience on metapost at all, but change the
mp.vim based on the intuition trained from other languages.
For the indentation problem for "def" and "enddef", a temporary
solution is: if possible and not violating the matepost's grammar,
please add a semicolon at the end of the line before "enddef", like:
def circle(expr x, y, r) =
fullcircle scaled (2*r) shifted (x,y);
enddef;
If you don't put a ";" at the end of one statement, the mp.vim will
treat the current line as a broken line and will indent forward twice
at the beginning of next line. Thus, even though you put "enddef" in
the new line, it will only indent backward once.
However, as I mentioned before, I don't know metapost much, so I am not sure if
"fullcircle scaled (2*r) shifted (x,y);"
is the same to:
"fullcircle scaled (2*r) shifted (x,y)"
in macro definition.
Another option is that, you just put all the macro definition in one
line, similar to those macro definition examples described in MetaPost
User Manual.
Sorry, I am not capable of rewriting the whole mp.vim because of my
zero knowledge of metapost.
Good luck!
--
Best,
Zhaojun (Joseph)