zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@u.genie.co.uk>
To: zsh-workers@sunsite.dk
Subject: Re: example startup file
Date: Wed, 09 May 2001 17:46:36 +0100	[thread overview]
Message-ID: <3AF9746C.DD676141@u.genie.co.uk> (raw)
In-Reply-To: <010508125610.ZM7477@candle.brasslantern.com>

Bart Schaefer wrote:
> 
> However, if you know (as in the example) that fpath is non-empty, you can
> just do one loop like this:
> 
>     for func in $^fpath/*(N-.x:t); autoload $func

That looks good. I've switched it to that with a comment about the
non-empty issue.

> I use:
> 
>     typeset -U path cdpath fpath manpath

So do I and I'll add it to the example. I was just suprised that
compinit added duplicates.

> That never was csh-compatible.  This is:
> 
>     setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" }

ok. I'll put it in even though it ceases to be a nice simple example.
I'd like yp and yu from Functions/Example in here instead because
they are simple and easy to understand.

Has anyone got a useful and very short user-defined zle widget we could
add?

> > +freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
> 
> I'd throw in a check that the argument actually is a function before calling
> unfunction on it.

That would either need zmodloading zsh/parameter, a redirected which or
redirected stderr from unfunction. I think I'd prefer to keep it simple,
I'm even tempted to remove the while loop. If you prefer, either change
it or remove the function, I'm not really bothered but I've left it as
above for now.

Andrej wrote:

> >  manpath=($X11HOME/man /usr/man /usr/lang/man /usr/local/man)

> That's bad and does not belong to generic .zshrc. It blindly overwrites

I thought it was meant to be an example really as opposed to being
generic but judging from the comment at the top, maybe I'm wrong. That
isn't a line I added it was there before and I think it serves a useful
purpose in showing that you can setup your manpath there. I also think
it wouldn't be a bad thing if the examples break lots of things to
force them to be read before being used.

If you really want to remove those lines, I don't mind but following
the same principle much of zlogin and all of zshenv would also have to
go too.

Anyway, I'm going to be away for a few days so I'll commit this now
before I forget. Patch is to be applied on top of the previous. I also
added a few zmodload -a commands.

> zefram wrote:
> >       directory stack access with =num
> It was changed to ~num some time ago.

Ok, thanks, I've also updated that line before it is forgotten.

Oliver

Index: Etc/FEATURES
===================================================================
RCS file: /cvsroot/zsh/zsh/Etc/FEATURES,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 FEATURES
--- Etc/FEATURES        1999/04/15 18:05:37     1.1.1.1
+++ Etc/FEATURES        2001/05/09 16:41:27
@@ -5,13 +5,13 @@
 very close to ksh/sh grammar, with csh additions
 most features of ksh, bash, and tcsh
 can emulate ksh or POSIX sh
-81 builtins, 102 options, 162 key bindings
+100 builtins, 145 options, 166 key bindings
 short for loops, ex: for i (*.c) echo $i
 select
 shell functions
 conditional expressions (test builtin, [ ... ], and ksh-style [[ ... ]])
 global aliases (may be expanded anywhere on the line)
-directory stack access with =num
+directory stack access with ~num
 process substitution (vi =(cmd) edits the output of cmd)
 generalized pipes (ls foo >>(cmd1) 2>>(cmd2) pipes stdout to cmd1
   and stderr to cmd2)
--- zshrc       Tue May  8 18:42:07 2001
+++ zshrc       Wed May  9 17:30:10 2001
@@ -41,20 +41,20 @@
 alias lsa='ls -ld .*'
 
 # Shell functions
-setenv() { export $1=$2 }  # csh compatibility
+setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" }  # csh compatibility
 freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
 
 # Where to look for autoloaded function definitions
 fpath=($fpath ~/.zfunc)
 
-# Autoload all shell functions from all directories
-# in $fpath that have the executable bit on
-# (the executable bit is not necessary, but gives
-# you an easy way to stop the autoloading of a
-# particular shell function).
-#for dirname in $fpath; do
-#  autoload $dirname/*(.x:t)
-#done
+# Autoload all shell functions from all directories in $fpath (following
+# symlinks) that have the executable bit on (the executable bit is not
+# necessary, but gives you an easy way to stop the autoloading of a
+# particular shell function). $fpath should not be empty for this to work.
+for func in $^fpath/*(N-.x:t); autoload $func
+
+# automatically remove duplicates from these arrays
+typeset -U path cdpath fpath manpath
 
 # Global aliases -- These do not have to be
 # at the beginning of the command line.
@@ -93,6 +93,12 @@
 setopt   autoresume histignoredups pushdsilent noclobber
 setopt   autopushd pushdminus extendedglob rcquotes mailwarning
 unsetopt bgnice autoparamslash
+
+# Autoload zsh modules when they are referenced
+zmodload -a zsh/stat stat
+zmodload -a zsh/zpty zpty
+zmodload -a zsh/zprof zprof
+zmodload -ap zsh/mapfile mapfile
 
 # Some nice key bindings
 #bindkey '^X^Z' universal-argument ' ' magic-space


  reply	other threads:[~2001-05-09 16:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-08 17:58 Oliver Kiddle
2001-05-08 18:17 ` Zefram
2001-05-08 19:56 ` Bart Schaefer
2001-05-09 16:46   ` Oliver Kiddle [this message]
2001-05-09 17:24     ` Bart Schaefer
2001-05-09 17:34       ` Peter Stephenson
2001-05-09  5:43 ` Andrej Borsenkow
2001-05-09  6:38   ` Dan Nelson

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=3AF9746C.DD676141@u.genie.co.uk \
    --to=opk@u.genie.co.uk \
    --cc=zsh-workers@sunsite.dk \
    /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).