[vim/vim] Support expanding :find command argument using 'findexpr' (PR #15929)

22 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Oct 23, 2024, 12:10:16 AM10/23/24
to vim/vim, Subscribed

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

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

Commit Summary

  • 96d982f Support expanding :find command argument using 'findexpr'

File Changes

(5 files)

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/15929@github.com>

Yegappan Lakshmanan

unread,
Oct 23, 2024, 1:43:24 AM10/23/24
to vim/vim, Push

@yegappan pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15929/before/96d982f2f9261bcef6a80a1f68cc339894937e17/after/27141883e9de997cbac73f8c4a37f378bfedb6b6@github.com>

Yegappan Lakshmanan

unread,
Oct 23, 2024, 10:13:43 AM10/23/24
to vim/vim, Push

@yegappan pushed 1 commit.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15929/before/bc683f32d6ed3fdaa1f5f217cb0eb5c1cb16b143/after/f0ac5e5954ecb7ccf7f120b26bd9d826b5fb2ab8@github.com>

Yegappan Lakshmanan

unread,
Oct 23, 2024, 10:33:51 AM10/23/24
to vim/vim, Push

@yegappan pushed 1 commit.

  • 0438fde Support expanding :find command argument using 'findexpr'

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/15929/before/0f24335dbe95f08141e43ffe41bcc3b399427c97/after/0438fdefff73b14e3fd214bf4c5c89fd81247b6e@github.com>

Christian Brabandt

unread,
Oct 23, 2024, 3:04:32 PM10/23/24
to vim/vim, Subscribed

thanks!


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/15929/c2433206632@github.com>

Christian Brabandt

unread,
Oct 23, 2024, 3:08:24 PM10/23/24
to vim/vim, Subscribed

Closed #15929 via 2f6efac.


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/15929/issue_event/14827523582@github.com>

bfrg

unread,
Oct 23, 2024, 4:58:49 PM10/23/24
to vim/vim, Subscribed

It seems like v:fname is always prefixed with a ^. For example, if I type :find foo and press TAB, v:fname will be set to ^foo.


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/15929/c2433451207@github.com>

zeertzjq

unread,
Oct 23, 2024, 10:42:55 PM10/23/24
to vim/vim, Subscribed

There is also another problem:

  • When cmdline is a*b, v:fname is set to ^a.*b
  • When cmdline is a.*b, v:fname is set to ^a\..*b


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/15929/c2434122226@github.com>

zeertzjq

unread,
Oct 23, 2024, 11:09:26 PM10/23/24
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/ex_docmd.c:

> +    // File name expansion uses wildchars.  But the 'findexpr' expression
+    // expects a regular expression argument.  So convert wildchars in the
+    // argument to regular expression patterns.
+    regpat = file_pat_to_reg_pat(pat, NULL, NULL, FALSE);
+    if (regpat == NULL)
+	return FAIL;

This isn't correct. The docs for 'findexpr' doesn't require it to expect a regular expression argument.


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/15929/review/2391117540@github.com>

zeertzjq

unread,
Oct 23, 2024, 11:29:57 PM10/23/24
to vim/vim, Subscribed

Yet another problem: #15934 (comment)


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/15929/c2434170853@github.com>

Yegappan Lakshmanan

unread,
Oct 23, 2024, 11:44:37 PM10/23/24
to vim...@googlegroups.com, reply+ACY5DGFR4N5WWVOL7E...@reply.github.com, vim/vim, Subscribed
Hi,

On Wed, Oct 23, 2024 at 1:58 PM bfrg <vim-dev...@256bit.org> wrote:

It seems like v:fname is always prefixed with a ^. For example, if I type :find foo and press TAB, v:fname will be set to ^foo.



Yes.  When expanding file names, Vim internally adds wildcards to the search string.
It will be simpler to use in a Vim regular expression comparison if this is converted to
a regular expression pattern.  So when the 'findexpr' expression is evaluated for
command line argument completion, the string is converted to a regular expression.
I should have updated the document to reflect this.

- Yegappan

vim-dev ML

unread,
Oct 23, 2024, 11:45:04 PM10/23/24
to vim/vim, vim-dev ML, Your activity

Hi,

On Wed, Oct 23, 2024 at 1:58 PM bfrg ***@***.***> wrote:

> It seems like v:fname is always prefixed with a ^. For example, if I type :find
> foo and press TAB, v:fname will be set to ^foo.
>
>
>
Yes. When expanding file names, Vim internally adds wildcards to the
search string.
It will be simpler to use in a Vim regular expression comparison if this is
converted to
a regular expression pattern. So when the 'findexpr' expression is
evaluated for
command line argument completion, the string is converted to a regular
expression.
I should have updated the document to reflect this.

- 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/15929/c2434187928@github.com>

Yegappan Lakshmanan

unread,
Oct 23, 2024, 11:45:59 PM10/23/24
to vim...@googlegroups.com, reply+ACY5DGFJJRCV2BC3BE...@reply.github.com, vim/vim, Subscribed
On Wed, Oct 23, 2024 at 7:42 PM zeertzjq <vim-dev...@256bit.org> wrote:

There is also another problem:

  • When cmdline is a*b, v:fname is set to ^a.*b
  • When cmdline is a.*b, v:fname is set to ^a\..*b


Yes.  Before evaluating 'findexpr' for command line argument expansion, the command
argument is converted from a glob pattern to a regular expression pattern.  That is why
you see this behavior.

Regards,
Yegappan
 

vim-dev ML

unread,
Oct 23, 2024, 11:46:27 PM10/23/24
to vim/vim, vim-dev ML, Your activity

On Wed, Oct 23, 2024 at 7:42 PM zeertzjq ***@***.***> wrote:

> There is also another problem:
>
> - When cmdline is a*b, v:fname is set to ^a.*b
> - When cmdline is a.*b, v:fname is set to ^a\..*b
>
>
> Yes. Before evaluating 'findexpr' for command line argument expansion,
the command
argument is converted from a glob pattern to a regular expression pattern..
That is why
you see this behavior.

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/15929/c2434189128@github.com>

Reply all
Reply to author
Forward
0 new messages