Questions on formatexpr, sandbox and errors

4 views
Skip to first unread message

Silas Silva

unread,
Jul 22, 2010, 8:37:37 PM7/22/10
to vim...@googlegroups.com
Hi all,

I was writting my own formatexpr (please, see
http://vimgcwsyntax.google.com/), but found some difficulties that I
summarize below:

1. First and most important one is that I don't get any errors that
occur inside my FormatExpr() function when it is called from
formatexpr (although I get errors when I call it from : ). Why? Is
it because it is executed in a sandbox environment? Is it possible
to disable this feature? If not, what is the common way to debug
formatexpr functions? I attached a simplified .vimrc, that shows the
problem.

2. :he formatexpr says: "The expression may be evaluated in the
|sandbox|". It says *may be*. Sorry, English is not my native
language... When you use may, it means that it is optional? If so,
how disable/enable that?

3. :he sandbox says: "These items are not allowed in the sanbox: ...
- changing the buffer text", but from a formatexpr function, it is
always changed with append() and setline(). How to explain that?

Vim version here is 7.2.411.

Thank you!

--
Silas Silva

vimrc-simple

Andy Wokula

unread,
Jul 23, 2010, 5:08:32 AM7/23/10
to vim...@googlegroups.com
Am 23.07.2010 02:37, schrieb Silas Silva:
> Hi all,
>
> I was writting my own formatexpr

which can become very difficult, good luck.

> (please, see http://vimgcwsyntax.google.com/),

Server not found

> but found some difficulties that I summarize below:

> 1. First and most important one is that I don't get any errors that
> occur inside my FormatExpr() function when it is called from
> formatexpr (although I get errors when I call it from : ). Why? Is
> it because it is executed in a sandbox environment? Is it possible
> to disable this feature? If not, what is the common way to debug
> formatexpr functions? I attached a simplified .vimrc, that shows the
> problem.

:h 'debug

> 2. :he formatexpr says: "The expression may be evaluated in the
> |sandbox|". It says *may be*. Sorry, English is not my native
> language... When you use may, it means that it is optional? If so,
> how disable/enable that?
>
> 3. :he sandbox says: "These items are not allowed in the sanbox: ...
> - changing the buffer text", but from a formatexpr function, it is
> always changed with append() and setline(). How to explain that?

You were almost there:
:h sandbox-option

> Vim version here is 7.2.411.
>
> Thank you!

--
Andy

Silas Silva

unread,
Jul 23, 2010, 6:53:03 AM7/23/10
to vim...@googlegroups.com
On Fri, Jul 23, 2010 at 11:08:32AM +0200, Andy Wokula wrote:
> Am 23.07.2010 02:37, schrieb Silas Silva:
> >Hi all,
> >
> >I was writting my own formatexpr
>
> which can become very difficult, good luck.

Yeah, that is! In my simple project (right URL below), you can see the
code I'm writting (preliminary versions have still ugly code) and make
criticism.

>
> >(please, see http://vimgcwsyntax.google.com/),
>
> Server not found

Ah, sorry, http://vimgcwsyntax.googlecode.com/

> :h 'debug

Thanks, that really helps a lot.

> You were almost there:
> :h sandbox-option

Got the idea. It depends where formaexpr (and other options) is set.

Thank you again.

--
Silas Silva

Reply all
Reply to author
Forward
0 new messages