Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Does zsh functions have this feature?
- X-seq: zsh-users 17967
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Does zsh functions have this feature?
- Date: Mon, 02 Sep 2013 11:22:39 -0700
- In-reply-to: <CAA=69ZdBkW_vEgWtGc3nf0Z-iDX-oiF+a2Xky3LAPMs7rrxBRA@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAA=69ZdBkW_vEgWtGc3nf0Z-iDX-oiF+a2Xky3LAPMs7rrxBRA@mail.gmail.com>
On Sep 2, 9:41am, vinurs wrote:
}
} As time goes on, my functions will be more and more. But, I
} won't all of them will be treated as shell commands.
} In zsh, is there any feature like emacs lisp that when I write a
} function if I want it to be call by M-x, I should add
} (interactive)
} in it; if not, it will only be called by lisp programs.
In general, no. Zsh differentiates functions callable by the editor by
declaring them to be "widgets" via "zle -N" and related commands, but
it does not prevent widget functions from being called directly, any
more than emacs prevents a lisp program from invoking a function that
contains a call to (interactive).
There are various ways to cause functions to be excluded from command
correction and completion, and you can test for whether the editor is
active by e.g.
if zle
then zle -R "line editor is active"
else print "line editor is not active"
fi
The closest equivalent to (call-interactively) is to invoke the widget
by passing its name as an argument to the "zle" command. There are lots
of examples of this in the sample widget functions.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author