zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Announce of Zsh Navigation Tools
Date: Sat, 12 Sep 2015 16:43:39 -0700	[thread overview]
Message-ID: <150912164339.ZM26555@torch.brasslantern.com> (raw)
In-Reply-To: <55F4AF59.70606@eastlink.ca>

On Sep 12,  4:03pm, Ray Andrews wrote:
}
} immediately makes me want do something like this:
} 
}      for aa in /aWorking/Zsh/Source/*; do autoload $aa; done
} 
} ... remembering of course that things need to be rewritten to look like 
} scripts.

As long as there is only one function per file, you don't need to rewrite
them, just use

   ...; do autoload -k $aa; done

The "ksh-style" of autoloading is to have one complete function definition
in each file, including the "() { ... }" or "function { ... }" or whatever
wrapping syntax.

(Ksh does it this way because the syntax used to declare the function has
an effect on its semantics.)
 
} BTW, looking at $fpath, it sure is laborious.  Do we, could we have some 
} sort of automatic subdirectory inclusion?

I'm not sure what you mean by this, that is, are you trying to build up
the value of $fpath or are you trying to find all the files in $fpath
to autoload them?

If you're running an installed zsh, of course, then $fpath should have
all the necessary directories already (except e.g. personal ones in your
home dir).

If you're asking about constructing $fpath for a zsh build tree, then it
should suffice to do:

    fpath=( $build_dir/Completion/**/*(/) $build_dir/Functions/**/*(/)
            $fpath )

where you will need to define $build_dir appropriately, maybe it is $PWD.
Just be careful that you get the order right with respect to the default
$fpath -- the default should come FIRST if you are running an installed
shell.

If you're asking about autoloading everything after $fpath has been
defined, then this should work for the default paths:

    autoload $^fpath/*(N-.:t)

However, as I said you may want to add -k for your personal files, which
would need a second autoload command.

Some people also prefer to throw a (*) into the glob flags so as to only
autoload files that have been marked executable.

Putting this together, something like:

build_fpath=( $build_dir/Completion/**/*(/) $build_dir/Functions/**/*(/) )
my_fpath=( ~/zsh_functions/**/*(/) and so on )

autoload $^fpath/*(N-.:t)
autoload $^build_fpath/*(N-.:t)
autoload $^my_fpath/*(N-.:t)
fpath=( $my_fpath $build_fpath $fpath )

-- 
Barton E. Schaefer


  reply	other threads:[~2015-09-12 23:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-08 12:32 Sebastian Gniazdowski
2015-09-12 17:50 ` Ray Andrews
2015-09-12 19:41   ` ZyX
2015-09-12 21:03     ` Ray Andrews
2015-09-12 22:10       ` Bart Schaefer
2015-09-12 23:03         ` Ray Andrews
2015-09-12 23:43           ` Bart Schaefer [this message]
2015-09-12 23:53             ` Bart Schaefer
2015-09-13  0:41             ` Ray Andrews
2015-09-13  2:36               ` Bart Schaefer
2015-09-13  3:33                 ` Ray Andrews
2015-09-14  2:14             ` autoload Ray Andrews
2015-09-14  2:38               ` autoload Bart Schaefer
2015-09-14  3:34                 ` autoload Ray Andrews
2015-09-14 20:21                   ` autoload Bart Schaefer
2015-09-15  2:48                     ` autoload Ray Andrews
2015-09-15  3:48                       ` autoload Bart Schaefer
2015-09-15 16:18                         ` autoload Ray Andrews
2015-09-16  4:09                         ` autoload Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150912164339.ZM26555@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).