[patch] added ":e ~user<Tab>" completion

37 views
Skip to first unread message

Dominique Pellé

unread,
Jul 29, 2012, 6:40:08 PM7/29/12
to vim_dev
Hi

Attached patch fixes the following item in in ":help todo":

===========================================================
":e ~br<Tab>" does not complete to ":e /home/bram/". Would need to use
getpwent() to find all the matches.
===========================================================

Here are 2 examples, assuming that /etc/passwd contains 3 users
names: bill, bob, bram:

Example #1: completion in Ex command

:e ~b<Tab>
... possible completions: bob bill bram

:e ~bi<Tab>
... completes to :e ~bill

:e ~bill<Tab>
... substitute home path :e /home/bill/ (as before patch)


Example #2: user completion in :command

:command! -nargs=* -complete=users Foo

:Foo b<Tab>
... possible completions: bob bill bram

It is implemented for systems supporting getpwent().
configure script checks whether getpwent() is available.
I only tested it on Linux.

Regards
-- Dominique
complete-users-7.3.618.patch

Dominique Pellé

unread,
Jul 29, 2012, 8:13:58 PM7/29/12
to vim_dev
Dominique Pellé wrote:

> Hi
>
> Attached patch fixes the following item in in ":help todo":
>
> ===================================================

> ":e ~br<Tab>" does not complete to ":e /home/bram/". Would need to use
> getpwent() to find all the matches.
> ===================================================


Sorry. I noticed an inconsistency in my patch
between ":help command-complete" which
indicated the option "-complete=user" and
the code which expected "-complete users".

I fixed it in this new updated attached patch.

Regards
-- Dominique

complete-users-7.3.618.patch

Dominique Pellé

unread,
Jul 29, 2012, 9:41:08 PM7/29/12
to vim_dev
Here is yet another update of the patch.
Previous patch broke completion when
typing ":e ~user/dir<Tab>"

It is be fixed in this updated patch.
Sorry for the noise :-(

Regards
-- Dominique
complete-users-7.3.618.patch

Dominique Pellé

unread,
Jul 30, 2012, 3:56:42 AM7/30/12
to vim_dev
Dominique Pellé wrote:

> Hi
>
> Attached patch fixes the following item in in ":help todo":
>
> ======================================================

> ":e ~br<Tab>" does not complete to ":e /home/bram/". Would need to use
> getpwent() to find all the matches.
> ======================================================

My previous patch was missing src/vim.h and src/auto/configure.
So here is yet another update of the patch.

Regards
-- Dominique

complete-users-7.3.618.patch

Charles Campbell

unread,
Jul 30, 2012, 10:13:10 AM7/30/12
to vim...@googlegroups.com
Dominique Pell� wrote:
Hello, Dominique:

May I point out that old C compilers (ie. those that conform to K&R
style C) error-out on declarations which follow compilable code. In
particular,
int match_user(name)
char_u* name;
{
init_users();
int i;
...

will not compile with them. All that's needed is to push "init_users()"
to after the initial block of declarations.

Regards,
Chip Campbell

Dominique Pellé

unread,
Jul 30, 2012, 1:49:03 PM7/30/12
to vim...@googlegroups.com
Charles Campbell wrote:

> Hello, Dominique:
>
> May I point out that old C compilers (ie. those that conform to K&R style C)
> error-out on declarations which follow compilable code. In particular,
> int match_user(name)
> char_u* name;
> {
> init_users();
> int i;
> ...
>
> will not compile with them. All that's needed is to push "init_users()" to
> after the initial block of declarations.


Thanks for spotting it. Here is another update to the
patch with a few other minor changes.

-- Dominique
complete-users-7.3.618.patch

Bram Moolenaar

unread,
Jul 30, 2012, 5:14:43 PM7/30/12
to Dominique Pellé, vim_dev
Sounds good. I'll add it to the todo list.

--
A computer program does what you tell it to do, not what you want it to do.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages