Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Finding the file offsets for functions



On Fri, May 20, 2022 at 11:27 PM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>
> Autoloadable functions show up differently.
>
> $ whence -v zztop
> zztop is an autoload shell function

In recent zsh you can use
  autoload -r zztop
and then whence -v output and $functions_source will include the path
(but you also can't change that path later by changing $fpath).

> $ cat /Users/zachriggle/.zprezto/modules/zach-riggle/functions/zztop
> #!/usr/bin/env zsh#
> zztop() {
>     echo This is zztop
> }
> echo Zztop module loaded

That pretty much obliterates the whole reason for "autoload".

If you don't like "autoload -r" at the time of declaring all the
autoloads, you can use "autoload +X" at the time you want the source
of a particular function.

     The flag +X attempts to load each NAME as an autoloaded function,
     but does _not_ execute it. ...
     ... This does _not_ replace any existing definition ...

> I've run into issues where I'd like to create a path/to/autoloadable:$lineno such that I can easily pass it to vim or another editor.  This saves a lot of time on my end

Wouldn't
  vim "+/function $name\\|$name *()" $functions_source[$name]
be sufficient in nearly all cases?




Messages sorted by: Reverse Date, Date, Thread, Author