zsh-users
 help / color / mirror / code / Atom feed
* Can this be done with compctl?
@ 2003-10-18 16:17 DervishD
  2003-10-21 18:12 ` Bart Schaefer
  2003-10-28 11:36 ` Oliver Kiddle
  0 siblings, 2 replies; 7+ messages in thread
From: DervishD @ 2003-10-18 16:17 UTC (permalink / raw)
  To: Zsh Users

    Hi all :))

    I wanted to simulate the bash behaviour of completing command
names if you hit TAB on an empty prompt, and my first try was using
compsys (I'll use compsys for naming the new completion system). I
don't use the provided set of functions (_main_complete based), so I
do something like:

    completer () {
        compadd -a commands -k functions builtins aliases galiases
    }
    zle -C complete expand-or-complete completer
    bindkey "^O" complete

    This is just a test for showing more or less what I want:
obviously a better and more ellaborated solution should be written,
but this is not the point. The question is that I would like to do
something similar with compctl. I've tried, with no success, things
like:

    compctl -T -x 'p[0]' -c - --
    compctl -T -x 'm[0]' -c - --

    or similar commands using empty command names instead of '-T'
(which, BTW, should not be used for that...). It seems that compctl
don't even try to complete if there is not a word in the prompt :??

    Anyone can help?

    Although as I told in the past, default completion (no compsys,
no compctl) fulfills 98% of my needs, and compctl will do for a
couple of commands I want specially completed, I must confess that
compsys is more comfortable for defining some completions, even
without _arguments or things like that.

    Thanks a lot in advance.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Can this be done with compctl?
  2003-10-18 16:17 Can this be done with compctl? DervishD
@ 2003-10-21 18:12 ` Bart Schaefer
  2003-10-21 19:24   ` DervishD
  2003-10-28 11:36 ` Oliver Kiddle
  1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2003-10-21 18:12 UTC (permalink / raw)
  To: Zsh Users

On Oct 18,  6:17pm, DervishD wrote:
}
}     I wanted to simulate the bash behaviour of completing command
} names if you hit TAB on an empty prompt [...] It seems that compctl
} don't even try to complete if there is not a word in the prompt :??

That's partly correct.  TAB is magic in the old compctl system -- it
is *always* self-inserted when there is only whitespace at the prompt.
You can complete at an empty prompt by binding *another* character to
expand-or-complete (or any of the builtin completion widgets), but you
can't do so with a TAB unless you create a widget with "zle -C".

This can of course be as simple as

    function x-or-c {
	compstate[insert]="${compstate[insert]//tab /}"
	compcall
    }
    zle -C expand-or-complete expand-or-complete x-or-c

(That is, override the builtin expand-or-complete, so no bindkey changes
are required.)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Can this be done with compctl?
  2003-10-21 18:12 ` Bart Schaefer
@ 2003-10-21 19:24   ` DervishD
  0 siblings, 0 replies; 7+ messages in thread
From: DervishD @ 2003-10-21 19:24 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

    Hi Bart :)

 * Bart Schaefer <schaefer@brasslantern.com> dixit:
> }     I wanted to simulate the bash behaviour of completing command
> } names if you hit TAB on an empty prompt [...] It seems that compctl
> } don't even try to complete if there is not a word in the prompt :??
> That's partly correct.  TAB is magic in the old compctl system -- it
> is *always* self-inserted when there is only whitespace at the prompt.

    OK, that's the point :(

> can't do so with a TAB unless you create a widget with "zle -C".
> This can of course be as simple as
[...]

    Yes, I thought of it (didn't know that it was as easy as just
removing the 'tab' string from compstate...). I used to think that
the compsys was all bells and whistles and a lot of unreadable shell
code in functions starting with '_', and that compctl could do all
for you. In some way, I still think like that. I mean, for very
simple completions (sort of 'when the command is cd just complete
directory names, not files'), I would use 'compctl'. For me is more
straightforward. For very sophisticated completions I would use
compsys, together with the provided functions, that is, with
_menu_complete (the bells and whistles...). For general I suppose
that I would use a simple dispatcher (far simpler than
'_menu_complete'...) and a liberal use of compadd. By now the only
thing compctl doesn't do for me is command completion in the empty
(just whitespace) command line.

    I must confess that anyway for general use compsys is better.
I've really changed my mind. I still don't use the _menu_complete
thing, because I don't need it (for me, a very sophisticated
completion is sort of 'when the command is tar, just complete .tar.gz
files), but the mechanisms that compsys offers are very good, no
doubt. And anyway, I suppose I should go with compsys, just in case
the zsh workers decide to get rid of compctl... I'll try to decide...

    Thanks a lot for your help, Bart.

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Can this be done with compctl?
  2003-10-18 16:17 Can this be done with compctl? DervishD
  2003-10-21 18:12 ` Bart Schaefer
@ 2003-10-28 11:36 ` Oliver Kiddle
  2003-10-28 15:41   ` Bart Schaefer
  2003-10-28 15:42   ` DervishD
  1 sibling, 2 replies; 7+ messages in thread
From: Oliver Kiddle @ 2003-10-28 11:36 UTC (permalink / raw)
  To: Zsh Users

On 18 Oct, DervishD wrote:
> 
>     I wanted to simulate the bash behaviour of completing command
> names if you hit TAB on an empty prompt, and my first try was using

  zstyle ':completion:*' insert-tab false

Used to be the default and I don't think I particularly agree with the
decision to change the default. More consistent with old compctl but it
is a little odd.

Oliver


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Can this be done with compctl?
  2003-10-28 11:36 ` Oliver Kiddle
@ 2003-10-28 15:41   ` Bart Schaefer
  2003-10-28 15:44     ` DervishD
  2003-10-28 15:42   ` DervishD
  1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2003-10-28 15:41 UTC (permalink / raw)
  To: Zsh Users

On Oct 28, 12:36pm, Oliver Kiddle wrote:
}
}   zstyle ':completion:*' insert-tab false

[We've switched from discussing compctl to compsys now, obviously.]

} Used to be the default and I don't think I particularly agree with the
} decision to change the default. More consistent with old compctl but it
} is a little odd.

Where it's less odd is at the PS2 prompt, where often the input is a
result of cut'n'paste (I know, we have "insert-tab pending" for that,
though it isn't guaranteed to work everywhere) or simply that you want
to indent for readability.  IIRC at the time insert-tab was introduced
the completion system couldn't determine that it was at the PS2 prompt.
Maybe now that we have $PREBUFFER we could add "insert-tab secondary"
and change the default to that -- although this time we should remember
to update the documentation.

Administrivia:

Geoff -- the zsh.org/mla interface is messed up again.  URLs like this
are not working even though the referenced article can be found via the
search page:

    http://www.zsh.org/mla/cgi-bin/redirect?WORKERNUMBER=15653

Also, entering an article number in the "Lookup message by ..." boxes
produces an "Object not found" error page.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Can this be done with compctl?
  2003-10-28 11:36 ` Oliver Kiddle
  2003-10-28 15:41   ` Bart Schaefer
@ 2003-10-28 15:42   ` DervishD
  1 sibling, 0 replies; 7+ messages in thread
From: DervishD @ 2003-10-28 15:42 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: Zsh Users

    Hi Oliver :)

 * Oliver Kiddle <okiddle@yahoo.co.uk> dixit:
> >     I wanted to simulate the bash behaviour of completing command
> > names if you hit TAB on an empty prompt, and my first try was using
>   zstyle ':completion:*' insert-tab false

    Yes, I knew that, but I wanted to do that with compctl. Although
I'm using compsys (and compctl) I don't use the _main_complete
system. Thanks anyway :)
 
> Used to be the default and I don't think I particularly agree with the
> decision to change the default. More consistent with old compctl but it
> is a little odd.

    IMHO, this is going to amaze Bash users that change to Zsh than
the shwordsplit thing...

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Can this be done with compctl?
  2003-10-28 15:41   ` Bart Schaefer
@ 2003-10-28 15:44     ` DervishD
  0 siblings, 0 replies; 7+ messages in thread
From: DervishD @ 2003-10-28 15:44 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

    Hi Bart :)

 * Bart Schaefer <schaefer@brasslantern.com> dixit:
> } Used to be the default and I don't think I particularly agree with the
> } decision to change the default. More consistent with old compctl but it
> } is a little odd.
> Where it's less odd is at the PS2 prompt

    Oh, yes, I didn't think about that O:) In fact, when I write a
short function on the prompt, in PS2 I usually hit tab for
indenting...

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-10-28 15:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-18 16:17 Can this be done with compctl? DervishD
2003-10-21 18:12 ` Bart Schaefer
2003-10-21 19:24   ` DervishD
2003-10-28 11:36 ` Oliver Kiddle
2003-10-28 15:41   ` Bart Schaefer
2003-10-28 15:44     ` DervishD
2003-10-28 15:42   ` DervishD

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).