zsh-users
 help / color / mirror / code / Atom feed
* completion tricks
@ 2001-03-19 20:14 Jeff Shipman
  2001-03-19 20:15 ` Marius Strom
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Jeff Shipman @ 2001-03-19 20:14 UTC (permalink / raw)
  To: zsh-users

I was wondering how to set up some completion tricks like
these:

1) Using 'man' will complete different man pages

2) Using ssh, rlogin, telnet, etc will complete
   different hosts on my network.

Any help would be greatly appreciated. Thanks!

Jeff "Shippy" Shipman     E-Mail: shippy@nmt.edu
Computer Science Major    ICQ: 1786493
New Mexico Institute of Mining and Technology
Homepage: http://www.nmt.edu/~shippy


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: completion tricks
@ 2001-03-20  8:30 Felix Rosencrantz
  0 siblings, 0 replies; 17+ messages in thread
From: Felix Rosencrantz @ 2001-03-20  8:30 UTC (permalink / raw)
  To: zsh-users

Zsh comes with a tool to convert tcsh completions to zsh compctl completions. 
It might be useful to have a tool to convert zsh compctl completions to the new
completion system.  Something like this would be useful for converting these
custom completions.

It could provide a good learning experience for how to use the new system for
folks familiar with the old (or are able to better understand the old system
that the new.)

For the timing issues, it might be useful if a completion could be stopped if a
certain time limit has been reached.  Maybe the check could occur between
completers.  So in addition to check if there were any matches, it could see if
the time limit was exceeded.

 Also, I thought there was a style to tell the completion system, if a given
filepath exists, accept it without trying to do completions on the whole
path...  Something like that might help prevent NFS from being excessively
tickled by completion.

-FR



__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: completion tricks
@ 2001-03-20  9:54 Sven Wischnowsky
  0 siblings, 0 replies; 17+ messages in thread
From: Sven Wischnowsky @ 2001-03-20  9:54 UTC (permalink / raw)
  To: zsh-users


Felix Rosencrantz wrote:

> Zsh comes with a tool to convert tcsh completions to zsh compctl completions. 
> It might be useful to have a tool to convert zsh compctl completions to the new
> completion system.  Something like this would be useful for converting these
> custom completions.

Yes, I once thought about trying to do that.  It can get pretty
complicated, though (with -T and -t and stuff).  I was just too fed up 
with compctl to mess with it again...

> It could provide a good learning experience for how to use the new system for
> folks familiar with the old (or are able to better understand the old system
> that the new.)

And I'm not sure about this.  Writing a working converter is already
non-trivial, writing one that produces nice code even more so.

> For the timing issues, it might be useful if a completion could be stopped if a
> certain time limit has been reached.  Maybe the check could occur between
> completers.  So in addition to check if there were any matches, it could see if
> the time limit was exceeded.

Hm, if seconds are accurate enough this would be extremely simple to
add using $SECONDS.

>  Also, I thought there was a style to tell the completion system, if a given
> filepath exists, accept it without trying to do completions on the whole
> path...  Something like that might help prevent NFS from being excessively
> tickled by completion.

It's the default behaviour: leading path segments are accepted as they 
are if there are files below them that can be matched by the rest of
the partially given path.


Bye
 Sven


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


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: completion tricks
@ 2001-03-20 15:36 Sven Wischnowsky
  2001-03-20 17:00 ` Adam Spiers
  0 siblings, 1 reply; 17+ messages in thread
From: Sven Wischnowsky @ 2001-03-20 15:36 UTC (permalink / raw)
  To: zsh-users


Adam Spiers wrote:

> Sven Wischnowsky (wischnow@informatik.hu-berlin.de) wrote:
> > On a stand-alone Linux box there probably really isn't that much
> > difference, but at least for me compiling the whole completion system
> > into a memory mapped digest file and using that makes things faster
> > (after the first function is loaded).  It also saves memory, of course 
> > because mapped files are shared by all instances of zsh running on the 
> > same host (if your OS supports that, but almost every Unix should).
> 
> Would you mind showing how you do this quickly?

I use this:

    zrec() {
      zrecompile "$@" -p -- \
        -R ~/.zshrc -- \
        -R ~/.zdump -- \
        -R ~/lib/zsh/comp/Core/compinit -- \
        -R ~/lib/zsh/comp/Core/compaudit -- \
        -R ~/lib/zsh/comp/Core/compdump -- \
        -M ~/lib/zsh/funcs.zwc \
           ~/funcs/*(.) \
           ~/lib/zsh/comp/*/_* \
           ~/lib/zsh/func/*/*
    }

Never mind the funny paths.  Since I just upgraded the zsh I use every 
day (above the development version) to 4.0.1-pre2 I can say that this
worked for me with the latest CVS, so I'm not sure why you get:

> ...
> 
> zsh: parse error near `|'
> zcompile: can't read file: /nfs-home/adams/local/share/zsh/4.0.1-pre-2/functions/Completion/Builtins/_vars_eq

There are only `||'s in _vars_eq, no `|'s.  Do you have any aliases
that might get in the way?  You'll have to use `zcompile -U ...', then.

> Also, for this to work, wouldn't I have to include ~/.zsh/comp.zwc in
> fpath? 

Right.

> Why did the example suggest only to compile Completion/*/_*,
> not Completion/*/* ?

So that one saves the (probably not too large) space for the comp*
functions which get called only seldom and unfunction themselves.  If
they are in a mapped zwc file they might still be kept in memory even
though they will never be called again through the lifetime of the shell.

> I get the impression there are several different strategies one could
> take with compilation.  For example, how much is there to be gained by
> replacing all the Completion/* directories from the fpath with a
> single compiled foo.zwc digest?  Could you even do that, given that
> presumably foo.zwc would be missing Completion/Core/comp* ?

Of course different strategies might be useful: everything into one
zwc (probably the fastest -- I even put my personal utility functions
in my master zwc file), one zwc digest per directory... Using one zwc
file per function would be a bad idea, though.  Most of them will not
be mapped unless forced with the -M option but then one would have so
many mapped files open that the kernel might get unhappy.

Using the zwc digest for only the completion functions (sans comp*)
works, of course (see above), but you'll have to put at least the Core 
directory in your $fpath.  Put it after the zwc file and the shell will 
starting searching that, find the function it's searching and not look 
at the directories, so it's quite fast (after the first function found 
in the digest file the `directory' from the zwc is mapped in memory
and searching it...).

> The more I think about it, the more I like the idea of `make install'
> (or maybe `make install.zwc') taking the most sensible compilation
> route.  The distribution's completion functions probably aren't going
> to change at all in between upgrades, after all.

I wouldn't be against that, I just wouldn't know what style to suggest:
one for all, one for each directory, and there are also the functions 
in the Functions directory... Although users still have to call
autoload with the function names they want so it isn't that big a
problem if the global zwc digest contains functions some users don't
want to use.  Hm.

> > > Completing files with TAB was noticeably slower with the new
> > > system over the old.
> > 
> > As Adam pointed out, this of course depends on the completers one uses 
> > (and the match specs, btw.).
> 
> Perhaps these performance hits should be mentioned in the manual?

Well, that putting many function into the completer style makes things 
slower shouldn't be that surprising.  And for the match specs I'm not
completely sure what to suggest (even thought I asked Peter to put
something about that into the Guide, which he did).  Specs with `*'
are slower than others, specs with `**' even more so.  But depending
on the number, length and complexity of the matches one probably
wouldn't notice that on modern computers.  Using many matchers with
the matcher-list style can make things slow, too, but I always think
that using to many different matchers isn't that good idea anyway
(because they will probably match too often) so that users will find
that out if they want or not anyway.

But of course I'm not against putting a little warning here and there
into the manual.  Maybe we could first collect some reports from
everyone here about things which they considered to be too slow (and
how they solved it).

Bye
 Sven


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


^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: completion tricks
@ 2001-03-21  8:23 Sven Wischnowsky
  0 siblings, 0 replies; 17+ messages in thread
From: Sven Wischnowsky @ 2001-03-21  8:23 UTC (permalink / raw)
  To: zsh-users


Adam Spiers wrote:

> ...
> 
> That's very instructive; thanks.  Why .zdump not .zcompdump?

As I said, I (now) use 4.0.1-pre2 as my normal shell -- that uses
~/.zdump.  But in at least one terminal I'm always running the latest
development version for testing -- that uses the normal ~/.zcompdump
which makes it easier with `zsh -f' and things like that.  And I can't 
use one dump file for both, because functions may change...

> ...
> 
> > > Also, for this to work, wouldn't I have to include ~/.zsh/comp.zwc in
> > > fpath? 
> > 
> > Right.
> 
> OK.  Presumably it has to come before the normal Completion/* paths?
> I find the ELEMENT.zwc bit of the manual pretty hard to understand.
> 
> When I put it at the head of fpath, memory consumption appears to
> grow from:
> 
> USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
> adams     1421  0.2  0.7  3092 2052 pts/12   S    16:48   0:00 ..../zsh
> 
> to:
> 
> USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
> adams     1617  8.0  0.8  3772 2172 pts/3    S    16:50   0:00 ..../zsh
> 
> Why's that?  Startup time is better though, as expected.

That's because the shell has to map the `directory' contained in the
digest file (i.e. the list of function names whose definitions are in
the digest).  Also, your OS may choose to map more pages than are
actually used.  If the digest file is at the end of $fpath, the shell
will first find the definition file, load the function from it and
never touch the digest -- which may result in slightly lower memory
consumption at the beginning.  However, as soon as there is a second
zsh running using the digest file will occupy less memory because the
second shell shares the mapped digest.  Given the different memory
mapping policies one probably can't predict which way to load
functions looks better at the beginning.

> ... [ giving tips about performance in the docs ]
> 
> Sounds good.  So far, we have already mentioned _approximate and
> _correct (I still haven't got round to figuring out the difference
> between the two), and match specs.  Some completions used to be really
> expensive, e.g. _perl_modules, _man, and _rpm, but hopefully the
> caching helps a lot with that.  (Incidentally there are some rough
> edges with the caching mechanism which I *still* haven't got round to
> smoothing.)  Anything else?

_cvs. I'm not sure if we should mention normal completion functions -- 
it could make some people not use the system even if their hardware is 
very well capable of supporting the completion system.


Bye
 Sven

P.S.: _approximate = _correct + _complete.  One could say that
      _approximate expects missing characters at the end of the word
      (and doesn't count them as errors), while _correct thinks that
      the word on the line is thought to be correct -- and checks if
      it is.

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


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

end of thread, other threads:[~2001-03-21  8:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-19 20:14 completion tricks Jeff Shipman
2001-03-19 20:15 ` Marius Strom
2001-03-19 21:30   ` Adam Spiers
2001-03-19 21:46     ` Matt Armstrong
2001-03-19 22:04       ` Adam Spiers
2001-03-19 22:25         ` Matt Armstrong
2001-03-19 23:06           ` Adam Spiers
2001-03-20  8:28             ` Sven Wischnowsky
2001-03-20  8:37               ` Bart Schaefer
2001-03-20 14:57               ` Adam Spiers
2001-03-19 20:47 ` Stephane Bortzmeyer
2001-03-20 14:41 ` Stephane Bortzmeyer
2001-03-20  8:30 Felix Rosencrantz
2001-03-20  9:54 Sven Wischnowsky
2001-03-20 15:36 Sven Wischnowsky
2001-03-20 17:00 ` Adam Spiers
2001-03-21  8:23 Sven Wischnowsky

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