zsh-users
 help / color / mirror / code / Atom feed
* Compinit tries a filename once
@ 2016-01-27 15:51 Sebastian Gniazdowski
  2016-01-27 16:21 ` Sebastian Gniazdowski
  2016-01-27 16:43 ` Peter Stephenson
  0 siblings, 2 replies; 4+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-27 15:51 UTC (permalink / raw)
  To: Zsh Users

Hello
If a fpath-added directory say ~/completions will contain empty file
"_cp", then this will block stock _cp from loading. I was removing
~/.zcompdump. Should this work that way?

Best regards,
Sebastian Gniazdowski


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

* Re: Compinit tries a filename once
  2016-01-27 15:51 Compinit tries a filename once Sebastian Gniazdowski
@ 2016-01-27 16:21 ` Sebastian Gniazdowski
  2016-01-27 16:43 ` Peter Stephenson
  1 sibling, 0 replies; 4+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-27 16:21 UTC (permalink / raw)
  To: Zsh Users

% pwd
/Users/sgniazdowski/.zplugin/completions
% ls -l _cp
-rw-rw----  1 sgniazdowski  staff  0 27 sty 17:15 _cp
% # ^ Empty
% echo $^fpath/$_comps[cp](N.)
/Users/sgniazdowski/.zplugin/completions/_cp /usr/share/zsh/5.0.8/functions/_cp

The echo shows two entries, first one points to empty _cp file, and cp
completion doesn't work

Best regards,
Sebastian Gniazdowski


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

* Re: Compinit tries a filename once
  2016-01-27 15:51 Compinit tries a filename once Sebastian Gniazdowski
  2016-01-27 16:21 ` Sebastian Gniazdowski
@ 2016-01-27 16:43 ` Peter Stephenson
  2016-01-27 23:00   ` Bart Schaefer
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2016-01-27 16:43 UTC (permalink / raw)
  To: Zsh Users

On Wed, 27 Jan 2016 16:51:47 +0100
Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
> If a fpath-added directory say ~/completions will contain empty file
> "_cp", then this will block stock _cp from loading. I was removing
> ~/.zcompdump. Should this work that way?

If fpath is set up that like that, then autoloading the function will in
any case (later on) find that first _cp, which will do nothing.  So it
makes perfect sense for compinit to stop once it's seen it, too.

This is the standard case I'm talking about --- if your system can be
smarter than that about autoloading, somehow, then in that case (but
only that case) it would presumably make sense to enable compinit to be
smarter, too.  Then it needs to be told what logic you're applying to
the autoload process to know what functions it needs to consider,
e.g. by means of a predicate function.

In case I've garbled that, what I mean is:

- [At initialisation] compinit decides <somehow> what functions to
register as a completion function.

- [The first time completion is started in that context] autoload
decides <somehow> how to load the function.

The points I'm trying to make are (i) <somehow> needs to be the same
in both cases for consistency (ii) in normal operation, the autoload
has a very simple, builtin rule for <somehow>, deep down inside the
shell --- grab the first file you see --- so compinit needs to do the
same (iii) if you want to do better, you need to arrange for some
more programmable form of <somehow> to be shared by the two.

Hope that's semi-clear...

pws


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

* Re: Compinit tries a filename once
  2016-01-27 16:43 ` Peter Stephenson
@ 2016-01-27 23:00   ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2016-01-27 23:00 UTC (permalink / raw)
  To: Zsh Users

On Jan 27,  4:43pm, Peter Stephenson wrote:
}
} The points I'm trying to make are (i) <somehow> needs to be the same
} in both cases for consistency (ii) in normal operation, the autoload
} has a very simple, builtin rule for <somehow>, deep down inside the
} shell --- grab the first file you see --- so compinit needs to do the
} same (iii) if you want to do better, you need to arrange for some
} more programmable form of <somehow> to be shared by the two.

For Sebastian's purposes the most interesting bit is the handling of
the #compdef or #autoload token as the first word in the file.  What
he actually wants to do, I think, is invoke just that part of compinit
on an arbitrary new set of function source files discovered at plugin
load time, which may be after "compinit" has been run.

"compdef" itself is already defined separately as a function (in the
course of executing "compinit"), but the #token parsing is part of the
body of compinit and evaporates when compinit unfunctions itself at the
end.

This has now become a zsh-workers-level topic and should move to a new
thread over there.


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

end of thread, other threads:[~2016-01-27 23:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-27 15:51 Compinit tries a filename once Sebastian Gniazdowski
2016-01-27 16:21 ` Sebastian Gniazdowski
2016-01-27 16:43 ` Peter Stephenson
2016-01-27 23:00   ` Bart Schaefer

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