[vim/vim] Make indentexpr evaluate from older vim scripts (PR #14936)

35 views
Skip to first unread message

Scott Mcdermott

unread,
Jun 7, 2024, 10:40:26 AM6/7/24
to vim/vim, Subscribed

Older scripts have a problem with recent changes to indentexpr for vim9, they will see it as undefined variable E121. Patch avoids the error in vim8 script as mentioned by @monkoose in #14111 (comment)

Fixes #14111


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/14936

Commit Summary

  • 929e0f2 runtime(vim): Make indentexpr evaluate from older vim scripts (#14111)

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14936@github.com>

Christian Brabandt

unread,
Jun 9, 2024, 12:52:52 PM6/9/24
to vim/vim, Subscribed

Hm, I suppose if we make this change, we also don't need the import statement anymore. @yegappan @dkearns what is your opinion on this?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14936/c2156696343@github.com>

Scott Mcdermott

unread,
Jun 10, 2024, 12:54:06 AM6/10/24
to vim/vim, Push

@smemsh pushed 1 commit.

  • a693fa0 runtime(vim): Make indentexpr evaluate from older vim scripts (#14111)


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14936/before/929e0f2817215c6eba8028a3f5a006ade095dd42/after/a693fa048716df6e98037f9ee804434ac8851cac@github.com>

Scott Mcdermott

unread,
Jun 10, 2024, 12:56:22 AM6/10/24
to vim/vim, Subscribed

ok, removed the import line.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14936/c2157267505@github.com>

Yegappan Lakshmanan

unread,
Jun 10, 2024, 1:22:48 AM6/10/24
to vim...@googlegroups.com, reply+ACY5DGFKEBM2XBYYWV...@reply.github.com, vim/vim, Subscribed
On Sun, Jun 9, 2024 at 9:52 AM Christian Brabandt <vim-dev...@256bit.org> wrote:

Hm, I suppose if we make this change, we also don't need the import statement anymore. @yegappan @dkearns what is your opinion on this?



If there is a need to support using "indentexpr" from a legacy script, then I don't see an issue with this change.

Regards,
Yegappan

vim-dev ML

unread,
Jun 10, 2024, 1:23:20 AM6/10/24
to vim/vim, vim-dev ML, Your activity

On Sun, Jun 9, 2024 at 9:52 AM Christian Brabandt ***@***.***>
wrote:

> Hm, I suppose if we make this change, we also don't need the import
> statement anymore. @yegappan <https://github.com/yegappan> @dkearns
> <https://github.com/dkearns> what is your opinion on this?
>
>
>
If there is a need to support using "indentexpr" from a legacy script, then
I don't see an issue with this change.

Regards,
Yegappan


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14936/c2157293141@github.com>

Christian Brabandt

unread,
Jun 10, 2024, 11:58:07 AM6/10/24
to vim/vim, vim-dev ML, Comment

so you want those changes because? Is this just because you need to manually call the &indentexpr?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14936/c2158745817@github.com>

dkearns

unread,
Jun 10, 2024, 3:18:12 PM6/10/24
to vim/vim, vim-dev ML, Comment

There should probably be a builtin function to evaluate the 'indentexpr' for a given line, like cindent() and lispindent().


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14936/c2159117742@github.com>

Scott Mcdermott

unread,
Jun 10, 2024, 3:25:59 PM6/10/24
to vim/vim, vim-dev ML, Comment

so you want those changes because? Is this just because you need to manually call the &indentexpr

the changes are so the plugin doesn't break with E121, it's the vim-stabs mentioned in the issue, which had been working ok until I upgraded a vim8 to 9.1. I could carry a patch to vim-stabs, or I could carry a patch in vim but if it benefits anyone else and seems like better not to break vim8 scripts, then why should the patch not go in?

these reference exist:

 $ grep -sr indentexpr plugin
plugin/stabs.vim:       if &expandtab || !(&autoindent || &indentexpr || &cindent)
plugin/stabs.vim:               if &indentexpr != ''
plugin/stabs.vim:                       sandbox exe 'let inda='.&indentexpr
plugin/stabs.vim:       let checkalign = ( &expandtab || !(&autoindent || &indentexpr || &cindent))

don't know how to do anything more complicated with the patch, just cherry-picked the fix mentioned in the linked issue, because it fixed my problem. hope that it can be fixed one way or another, so older scripts don't get undefined error.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14936/c2159129646@github.com>

Jesse Pavel

unread,
Jun 10, 2024, 3:28:02 PM6/10/24
to vim/vim, vim-dev ML, Comment

so you want those changes because? Is this just because you need to manually call the &indentexpr?

To chime in with my use case:

I've been running with a patch in my tree that exposes all vim9script indentexprs at the global scope, because I have a mapping that toggles between the standard indentexpr and a custom, minimal indentation mode, and it needs to stash away the buffer's current indentexpr so it can restore it later.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14936/c2159132971@github.com>

Christian Brabandt

unread,
Jun 10, 2024, 4:00:29 PM6/10/24
to vim/vim, vim-dev ML, Comment

Hm, it seems like those autoloaded functions are automatically translated into autoloadable form, in this case like dist#vimindent#Expr(). One also cannot use function() to refer to those autoloaded vim9 functions, may be we should make this work instead, so that you can save and restore it using function()?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14936/c2159182094@github.com>

Scott Mcdermott

unread,
Jul 12, 2024, 1:20:18 AM7/12/24
to vim/vim, vim-dev ML, Comment

@chrisbra is this patch useful in the meantime to fix vim8 users, before a more complete change can be made, or should the PR be closed?


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14936/c2224683497@github.com>

Christian Brabandt

unread,
Jul 12, 2024, 2:02:31 PM7/12/24
to vim/vim, vim-dev ML, Comment

I have another idea how to fix this, probably doesn't matter, but I wanted to keep the import and didn't want to have to use the autoloaded name. Let's see how this works for you.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14936/c2226111613@github.com>

Christian Brabandt

unread,
Jul 12, 2024, 2:03:44 PM7/12/24
to vim/vim, vim-dev ML, Comment

Closed #14936 via cb79288.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14936/issue_event/13490750142@github.com>

Scott Mcdermott

unread,
Jul 13, 2024, 3:06:20 AM7/13/24
to vim/vim, vim-dev ML, Comment

Let's see how this works for you

solves my issue afaict; thanks.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/pull/14936/c2226796456@github.com>

Reply all
Reply to author
Forward
0 new messages