zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Does zsh functions have this feature?
Date: Mon, 02 Sep 2013 11:22:39 -0700	[thread overview]
Message-ID: <130902112239.ZM26330@torch.brasslantern.com> (raw)
In-Reply-To: <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.


      reply	other threads:[~2013-09-02 18:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-02  1:41 vinurs
2013-09-02 18:22 ` Bart Schaefer [this message]

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=130902112239.ZM26330@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).