zsh-users
 help / color / mirror / code / Atom feed
* Re: zsh and RPM: a case of study (for me)
@ 1999-10-11 12:14 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 1999-10-11 12:14 UTC (permalink / raw)
  To: zsh-users


Francis GALIEGUE wrote:

> Oh, also, there seems to be a bug with ZLS_COLORS: empty lines are
> stuffed with some random colors and it doesn't like custom foreground
> colors for files in the dircolors mechanism...

Empty lines? In a completion listing? Oops.

Anyway, could you please give us an example when exactly this happens?

What's the dircolors mechanism?

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: zsh and RPM: a case of study (for me)
  1999-09-30 12:19   ` Francis GALIEGUE
  1999-09-30 16:40     ` Chmouel Boudjnah
@ 1999-09-30 19:10     ` Adam Spiers
  1 sibling, 0 replies; 9+ messages in thread
From: Adam Spiers @ 1999-09-30 19:10 UTC (permalink / raw)
  To: ZSH users list

Francis GALIEGUE (fg@mandrakesoft.com) wrote:
> I have 3.1.6 (it's bundled with Mandrake <nudge> <nudge> :) ).

Cool.  I look forward to when we reach 3.1.7, so that Mandrake can
have all the latest stuff.  (How many more pws-* before 3.1.7?)

> > > Another probably dumb example: I'm used to the bash key sequences
> > > (C-x|Esc)(!|@|~|/|$), how can I reproduce them in a simple manner?
> > 
> > You should find that many (most?) of them already work in zsh.  If you
> > find you're really missing any of them, let us know and I'm sure one
> > of us will be only to happy to help.
> 
> They don't seem to. For info, unless you already know it, what these
> sequences do in bash are:
> 
> Esc ! -> tries to complete the current word to a command name
> Esc $ -> same, but for environment variables, whether the word is
> preceeded by a $ or not
> Esc @ -> machine names (from /etc/hosts)
> Esc / -> file name
> Esc ~ -> a user name
> 
> C-x instead of Esc with one of the above will list matches and won't
> attempt any completion

Peter's kindly just implemented these, so pws-7 will have them in.
See zsh-workers for the patch.


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

* Re: zsh and RPM: a case of study (for me)
  1999-09-30 12:19   ` Francis GALIEGUE
@ 1999-09-30 16:40     ` Chmouel Boudjnah
  1999-09-30 19:10     ` Adam Spiers
  1 sibling, 0 replies; 9+ messages in thread
From: Chmouel Boudjnah @ 1999-09-30 16:40 UTC (permalink / raw)
  To: Francis GALIEGUE; +Cc: ZSH users list

Francis GALIEGUE <fg@mandrakesoft.com> writes:

> > Oh, the above won't work unless you've configured your setup to work
> > with the new completion system.  Read the `zshcompsys' man page for
> > details on how to do this (or just type `compinstall' if you can't be
> > bothered to read it :-)

> It runs automagically, I got this at the end of my .zshrc:

because i have add them by default for mandrake.

> _compdir=/usr/share/zsh/functions/Core
> [[ -z $fpath[(r)$_compdir] ]] && fpath=($fpath $_compdir)
> autoload -U compinit
> compinit

-- 
MandrakeSoft          http://www.mandrakesoft.com/
			         	 --Chmouel


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

* Re: zsh and RPM: a case of study (for me)
  1999-09-29 20:10 ` Adam Spiers
@ 1999-09-30 12:19   ` Francis GALIEGUE
  1999-09-30 16:40     ` Chmouel Boudjnah
  1999-09-30 19:10     ` Adam Spiers
  0 siblings, 2 replies; 9+ messages in thread
From: Francis GALIEGUE @ 1999-09-30 12:19 UTC (permalink / raw)
  To: ZSH users list

Adam Spiers wrote:
> 
> However, it's probably good to keep the distinction between a
> (reference) manual and a tutorial/guide, and fortunately Peter's just
> published an unfinished first draft of one
> (http://www.ifh.de/~pws/computing/zshguide_intro.html if you missed
> the post) which if first looks are to go by, will be a wonderful
> complement to the very well written but tough manual.
> 

AH, good, I'll have alook at it :)

> > What are really completion widgets? Even after rereading the
> > aforementioned chapters 3, 4 times I still couldn't figure it out. When
> > are they called, what do they do, etc, and more importantly, HOW TO
> > CREATE ONE!
> >
> > Just for example, lets say I have a:
> >
> > compctl -X bar -k "(a b)" foo
> 
> That's your first problem.  `compctl' is the old style of programmable
> completion, which (in terms of configuration) is completely separate
> and different to the new, widget-based style.  What version do you
> have installed?  It sounds like you have a 3.1.something.  What I say
> below applies to 3.1.6; if you don't mind using a development version
> with warts and all, I'd recommend you try 3.1.6 or even the latest pws
> patch from http://www.ifh.de/~pws/computing/, which has all the latest
> bells and whistles.
> 

I have 3.1.6 (it's bundled with Mandrake <nudge> <nudge> :) ).


> Try an experiment: type `bindkey' from your zsh.  You'll get a list of
> keys, and what widgets those keys are bound to.  For example,
> 
>   "^[f" forward-word
> 
> means when you press ESC f (or meta-f), it will invoke the
> forward-word widget, which moves the cursor forward to the next word.
> A completion widget is one which starts the cogs of the new
> shell-script-based completion system whirring.
> 
> However, you don't normally need to make your own completion widgets;
> you just incorporate your new completion into the existing system of
> widgets.  For example, to convert your compctl example to the new
> system:
> 
>   function _foo {
>     # Generate completion matches `a' and `b' with the explanation `bar'
>     compadd -X bar - a b
>   }
> 
>   # Make the command `foo' complete arguments using the function `_foo'
>   compdef _foo foo
> 

OK, noted :)

> (Note that all such functions like _foo above should start with an
> underscore.)
> 
> Oh, the above won't work unless you've configured your setup to work
> with the new completion system.  Read the `zshcompsys' man page for
> details on how to do this (or just type `compinstall' if you can't be
> bothered to read it :-)
> 

It runs automagically, I got this at the end of my .zshrc:

_compdir=/usr/share/zsh/functions/Core
[[ -z $fpath[(r)$_compdir] ]] && fpath=($fpath $_compdir)
autoload -U compinit
compinit


> 
> > Another probably dumb example: I'm used to the bash key sequences
> > (C-x|Esc)(!|@|~|/|$), how can I reproduce them in a simple manner?
> 
> You should find that many (most?) of them already work in zsh.  If you
> find you're really missing any of them, let us know and I'm sure one
> of us will be only to happy to help.
> 

They don't seem to. For info, unless you already know it, what these
sequences do in bash are:

Esc ! -> tries to complete the current word to a command name
Esc $ -> same, but for environment variables, whether the word is
preceeded by a $ or not
Esc @ -> machine names (from /etc/hosts)
Esc / -> file name
Esc ~ -> a user name

C-x instead of Esc with one of the above will list matches and won't
attempt any completion

> 
> You're not the only one who wanted this behaviour, and so you'll be
> glad to hear that someone's already done the hard work.  There's an
> _rpm function distributed with 3.1.6-pws-6 which does all you want,
> and much more.
> 

Ahaa! I'll have a look too :)

Thanks for all the info.

Regards,
-- 
fg

# rm *;o
o: command not found


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

* Re: zsh and RPM: a case of study (for me)
  1999-09-29 19:53 ` Chmouel Boudjnah
  1999-09-29 20:11   ` Adam Spiers
@ 1999-09-30 10:03   ` Francis GALIEGUE
  1 sibling, 0 replies; 9+ messages in thread
From: Francis GALIEGUE @ 1999-09-30 10:03 UTC (permalink / raw)
  To: zsh-users

> 
> > Just for example, lets say I have a:
> > compctl -X bar -k "(a b)" foo
>           ^^
> 
> small x "-x"
> 
> 

No, I actually mean the big X, for a help text - I know you're not fond
of them, but I am :)

-- 
fg

# rm *;o
o: command not found


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

* Re: zsh and RPM: a case of study (for me)
  1999-09-29 19:53 ` Chmouel Boudjnah
@ 1999-09-29 20:11   ` Adam Spiers
  1999-09-30 10:03   ` Francis GALIEGUE
  1 sibling, 0 replies; 9+ messages in thread
From: Adam Spiers @ 1999-09-29 20:11 UTC (permalink / raw)
  To: zsh-users

Chmouel Boudjnah (chmouel@mandrakesoft.com) wrote:
> Francis GALIEGUE <fg@mandrakesoft.com> writes:
> 
> How it's you ;),
> 
> > Just for example, lets say I have a:
> > compctl -X bar -k "(a b)" foo
>           ^^
> small x "-x"

No, I think he meant big X in this case, for providing an explanation
message.


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

* Re: zsh and RPM: a case of study (for me)
  1999-09-29 19:27 Francis GALIEGUE
  1999-09-29 19:53 ` Chmouel Boudjnah
@ 1999-09-29 20:10 ` Adam Spiers
  1999-09-30 12:19   ` Francis GALIEGUE
  1 sibling, 1 reply; 9+ messages in thread
From: Adam Spiers @ 1999-09-29 20:10 UTC (permalink / raw)
  To: zsh-users

Francis GALIEGUE (fg@mandrakesoft.com) wrote:
> Hi,
> 
> I'm a new subscriber to this list. I've used zsh for only 4 days now,
> but to my opinion it plain rocks.

It sure does :-)

> It already saves me a lot of time, no
> doubt on this, and I've even hacked a bit the base distribution that
> comes with it so that it can handle lftp (a change in a #compdef, no big
> deal) and .tar.bz2 archives cleanly.
> 
> But all the rest is obscure to me.
> 
> I've d/led the postscript of the manual and printed out, guess what,
> chapters 20, 21 and 23. But I haven't got what I want. Like all manuals,
> unfortunately, it's exhaustive but doesn't give enough examples :(

Agreed - I've been using zsh for quite a while now, but I found it
very tough at first even understanding the new completion system in
3.1.6.  At the end of the day, zsh is a very intricate shell and
there's no getting away from its complexity, but examples do go a long
way, and I found the ones given very helpful.

However, it's probably good to keep the distinction between a
(reference) manual and a tutorial/guide, and fortunately Peter's just
published an unfinished first draft of one
(http://www.ifh.de/~pws/computing/zshguide_intro.html if you missed
the post) which if first looks are to go by, will be a wonderful
complement to the very well written but tough manual.

> What are really completion widgets? Even after rereading the
> aforementioned chapters 3, 4 times I still couldn't figure it out. When
> are they called, what do they do, etc, and more importantly, HOW TO
> CREATE ONE!
> 
> Just for example, lets say I have a:
> 
> compctl -X bar -k "(a b)" foo

That's your first problem.  `compctl' is the old style of programmable
completion, which (in terms of configuration) is completely separate
and different to the new, widget-based style.  What version do you
have installed?  It sounds like you have a 3.1.something.  What I say
below applies to 3.1.6; if you don't mind using a development version
with warts and all, I'd recommend you try 3.1.6 or even the latest pws
patch from http://www.ifh.de/~pws/computing/, which has all the latest
bells and whistles.

Try an experiment: type `bindkey' from your zsh.  You'll get a list of
keys, and what widgets those keys are bound to.  For example,

  "^[f" forward-word

means when you press ESC f (or meta-f), it will invoke the
forward-word widget, which moves the cursor forward to the next word.
A completion widget is one which starts the cogs of the new
shell-script-based completion system whirring.

However, you don't normally need to make your own completion widgets;
you just incorporate your new completion into the existing system of
widgets.  For example, to convert your compctl example to the new
system:

  function _foo {
    # Generate completion matches `a' and `b' with the explanation `bar'
    compadd -X bar - a b
  }

  # Make the command `foo' complete arguments using the function `_foo'
  compdef _foo foo

(Note that all such functions like _foo above should start with an
underscore.)

Oh, the above won't work unless you've configured your setup to work
with the new completion system.  Read the `zshcompsys' man page for
details on how to do this (or just type `compinstall' if you can't be
bothered to read it :-)

In practice, because there are so many shell functions written for
completing all (well, some of) the different UNIX commands, it would
be inefficient for every invocation of zsh to load them all in at
startup.  So the `autoload' feature is used, where functions such as
_foo above are only loaded in when they're needed.

> Another probably dumb example: I'm used to the bash key sequences
> (C-x|Esc)(!|@|~|/|$), how can I reproduce them in a simple manner?

You should find that many (most?) of them already work in zsh.  If you
find you're really missing any of them, let us know and I'm sure one
of us will be only to happy to help.

> And for the hardest part now: a set of functions|widgets|whatever for
> rpm...

[snip]

You're not the only one who wanted this behaviour, and so you'll be
glad to hear that someone's already done the hard work.  There's an
_rpm function distributed with 3.1.6-pws-6 which does all you want,
and much more.

> The problem is that I can generate each of these arrays individually (a
> mano for the options), but not tie them together so that it completes
> correctly in each of these cases... And I fear that the compctl function
> may not be enough for this :(

Actually it is, but the new system handles complex completions much
more effortlessly, and with greater success.

Damn, I can see similar questions arising when I get my friends going
on 3.1.6.  Peter, is any of that re-usable in the guide?  Probably
not.

> I don't want this message to look like a rant, it's not - I really love
> this shell, but I wish there were a good, explanative, to-the-point
> programming guide too...

It's on its way!

> # rm *;o
> o: command not found

<grin>


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

* Re: zsh and RPM: a case of study (for me)
  1999-09-29 19:27 Francis GALIEGUE
@ 1999-09-29 19:53 ` Chmouel Boudjnah
  1999-09-29 20:11   ` Adam Spiers
  1999-09-30 10:03   ` Francis GALIEGUE
  1999-09-29 20:10 ` Adam Spiers
  1 sibling, 2 replies; 9+ messages in thread
From: Chmouel Boudjnah @ 1999-09-29 19:53 UTC (permalink / raw)
  To: Francis GALIEGUE; +Cc: zsh-users

Francis GALIEGUE <fg@mandrakesoft.com> writes:

How it's you ;),

> Just for example, lets say I have a:
> compctl -X bar -k "(a b)" foo
          ^^

small x "-x"

> how can I do so that it's actually a completion widget which returns the
> "(a b)" stuff? Or am I missing the point completely?

it's depend what you want the  your command if you want the first or
second argument.

> Another probably dumb example: I'm used to the bash key sequences
> (C-x|Esc)(!|@|~|/|$), how can I reproduce them in a simple manner?

i don't understand what you want to reproduce excatly ?

> And for the hardest part now: a set of functions|widgets|whatever for
> rpm...
> I make RPMs quite often indeed, and I'd like:
> rpm -b<whatever> [ --target=whatever ] <TAB>
> to complete on *.spec files,

look in my directory i use this for rpm :

#
_rpmOPT=($(<$HOME/.sh/clist/rpm_options))
_rpmQUE=($(<$HOME/.sh/clist/rpm_query))

function _rpmAVAIL { reply=($(rpm -qa)) }

compctl  -f -x 's[--]' -s "$_rpmOPT" - \
	'W[1,-e]' -K _rpmAVAIL - \
    'p[1] s[-b]' -k '(p l c i b a)' - \
    "c[-1,--queryformat]" -k _rpmQUE -\
    'W[1,-q*] C[-1,-([^-]*|)f*]' -f - \
    'W[1,-qa]' -k '( )' - \
    'W[1,-b*], c[-1,--rmsource]' -g '*.spec' + -f - \
    "c[-1,--recompile], c[-1,--rebuild]" -g '*.src.rpm' + -f -\
    'W[1,-(i|U|q)*], W[1,-([^-]*|)p*]' -g '*.rpm' + -f -\
    -- rpm

unset _rpmOPT

when rpm_options contains :

oldpackage percent replacefiles replacepkgs noscripts root excludedocs includedocs test upgrade test clean short-circuit sign recompile rebuild resign querytags queryformat version help quiet rcfile force hash short-circuit rmsource nodeps

and rpm_query rpm --querytags

-- 
MandrakeSoft          http://www.mandrakesoft.com/
			         	 --Chmouel


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

* zsh and RPM: a case of study (for me)
@ 1999-09-29 19:27 Francis GALIEGUE
  1999-09-29 19:53 ` Chmouel Boudjnah
  1999-09-29 20:10 ` Adam Spiers
  0 siblings, 2 replies; 9+ messages in thread
From: Francis GALIEGUE @ 1999-09-29 19:27 UTC (permalink / raw)
  To: zsh-users

Hi,

I'm a new subscriber to this list. I've used zsh for only 4 days now,
but to my opinion it plain rocks. It already saves me a lot of time, no
doubt on this, and I've even hacked a bit the base distribution that
comes with it so that it can handle lftp (a change in a #compdef, no big
deal) and .tar.bz2 archives cleanly.

But all the rest is obscure to me.

I've d/led the postscript of the manual and printed out, guess what,
chapters 20, 21 and 23. But I haven't got what I want. Like all manuals,
unfortunately, it's exhaustive but doesn't give enough examples :(

What are really completion widgets? Even after rereading the
aforementioned chapters 3, 4 times I still couldn't figure it out. When
are they called, what do they do, etc, and more importantly, HOW TO
CREATE ONE!

Just for example, lets say I have a:

compctl -X bar -k "(a b)" foo

how can I do so that it's actually a completion widget which returns the
"(a b)" stuff? Or am I missing the point completely?

Another probably dumb example: I'm used to the bash key sequences
(C-x|Esc)(!|@|~|/|$), how can I reproduce them in a simple manner?

And for the hardest part now: a set of functions|widgets|whatever for
rpm...

I make RPMs quite often indeed, and I'd like:

rpm -b<whatever> [ --target=whatever ] <TAB>

to complete on *.spec files,

rpm -q<whatever but p or f> --<TAB> <TAB>

to complete on long options (--queryformat for example) then installed
rpms,

<the above but with -qp>

to complete on *.(src|any_architecture).rpm,

rpm -qf <TAB>

to complete on files, etc.etc. and this is only one major mode of RPM.
The others are certainly easier (also consider the different completions
possible on a --queryformat - ugh)

The problem is that I can generate each of these arrays individually (a
mano for the options), but not tie them together so that it completes
correctly in each of these cases... And I fear that the compctl function
may not be enough for this :(

Oh, also, there seems to be a bug with ZLS_COLORS: empty lines are
stuffed with some random colors and it doesn't like custom foreground
colors for files in the dircolors mechanism...

I don't want this message to look like a rant, it's not - I really love
this shell, but I wish there were a good, explanative, to-the-point
programming guide too...

Regards,
--
fg

# rm *;o
o: command not found


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

end of thread, other threads:[~1999-10-11 12:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-11 12:14 zsh and RPM: a case of study (for me) Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-09-29 19:27 Francis GALIEGUE
1999-09-29 19:53 ` Chmouel Boudjnah
1999-09-29 20:11   ` Adam Spiers
1999-09-30 10:03   ` Francis GALIEGUE
1999-09-29 20:10 ` Adam Spiers
1999-09-30 12:19   ` Francis GALIEGUE
1999-09-30 16:40     ` Chmouel Boudjnah
1999-09-30 19:10     ` Adam Spiers

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).