zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Function not found
Date: Fri, 21 Dec 2012 10:11:25 -0800	[thread overview]
Message-ID: <121221101125.ZM31867@torch.brasslantern.com> (raw)
In-Reply-To: <20121220090305.GD1915@helium>
In-Reply-To: <CAFOazANccMcu4QQsLAk9TCfDHTVoqgezN3a9KtJUQgB9BNeO1w@mail.gmail.com>

On Dec 20,  4:03am, Brandon Sandrowicz wrote:
}
} On Wed, Dec 19, 2012 at 10:44:23PM -0800, czech@sonic.net wrote:
} > 
} > _ssh() {
} >     ssh -XC "czechar@$@"
} > }
} > 
} > autoload -- ~/.zfunc/[^_]*(:t)
} > fpath=( ~/.zfunc $fpath )
} 
} The autoload command you have here appears to be your problem.
} 
} If your _ssh function is defined in the file ~/.zfunc/_ssh, your
} original command *could* work, but you would have to remove the '[^_]'
} which prevents files beginning with underscores.

My guess is that the [^_] was copied from a recipe related to the
completion system.  In most cases (as Jeremie later mentioned) any
file with a leading underscore in its name would contain a completion
function of some kind, and would therefore have a "#compdef" line at
the top.  These files are autoloaded by the compinit command (if the
$fpath is properly set when compinit is run) and therefore don't need
to be autoloaded a second time from .zshrc.
 
} To be clear, autoload wants the names of the *functions*, not the names
} of the files. Your approach above could work so long as each function is
} in a separate file, and both (file and function) share the same exact
} name (i.e. can't be _ssh.zsh).

To be even more specific, autoload depends upon the names of the files
being the *same* as the names of the functions.  Generally, the file
should contain only the function body, not the func() { ... } syntax.
If that syntax is used in the file, you need "autoload -k".  There are
exceptions, and reasons for a file to contain more than one function,
but you should avoid that until you understand the operation in detail.

-- 
Barton E. Schaefer


  reply	other threads:[~2012-12-21 18:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-19 15:22 forbidden variable in for loop Ray Andrews
2012-12-19 23:58 ` Danek Duvall
2012-12-19 16:03   ` Ray Andrews
2012-12-20  6:44     ` Function not found czech
2012-12-20  9:03       ` Brandon Sandrowicz
2012-12-20 11:02       ` Jérémie Roquet
2012-12-21 18:11         ` Bart Schaefer [this message]
2012-12-20  0:04 ` forbidden variable in for loop Frank Terbeck

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=121221101125.ZM31867@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).