zsh-users
 help / color / mirror / code / Atom feed
* Does zsh functions have this feature?
@ 2013-09-02  1:41 vinurs
  2013-09-02 18:22 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: vinurs @ 2013-09-02  1:41 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 342 bytes --]

Hi all,
           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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Does zsh functions have this feature?
  2013-09-02  1:41 Does zsh functions have this feature? vinurs
@ 2013-09-02 18:22 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2013-09-02 18:22 UTC (permalink / raw)
  To: zsh-users

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-02 18:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-02  1:41 Does zsh functions have this feature? vinurs
2013-09-02 18:22 ` Bart Schaefer

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).