From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: how-many/count-matches for non-interactive use Date: Sun, 24 Oct 2004 13:09:45 -0400 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: References: <87pt3m5vqk.fsf@oak.pohoyda.family> <87zn2mh5jk.fsf-monnier+emacs@gnu.org> <87is99nznd.fsf-monnier+emacs@gnu.org> <200410172053.i9HKrdL01136@raven.dms.auburn.edu> <200410190158.i9J1wrH25523@raven.dms.auburn.edu> <200410200127.i9K1Rpp28384@raven.dms.auburn.edu> <200410210308.i9L38Dm10997@raven.dms.auburn.edu> <200410222222.i9MMMD515903@raven.dms.auburn.edu> <200410240231.i9O2VlZ15381@raven.dms.auburn.edu> Reply-To: rms@gnu.org NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1098637880 19521 80.91.229.6 (24 Oct 2004 17:11:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 24 Oct 2004 17:11:20 +0000 (UTC) Cc: jpw@gnu.org, klm@zope.com, emacs-devel@gnu.org, monnier@iro.umontreal.ca, storm@cua.dk, alexander.pohoyda@gmx.net Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 24 19:11:11 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CLltf-0001mc-00 for ; Sun, 24 Oct 2004 19:11:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CLm1G-0008J0-KB for ged-emacs-devel@m.gmane.org; Sun, 24 Oct 2004 13:19:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CLm0E-0007qa-KK for emacs-devel@gnu.org; Sun, 24 Oct 2004 13:17:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CLm0D-0007pq-Kj for emacs-devel@gnu.org; Sun, 24 Oct 2004 13:17:58 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CLm0D-0007pe-AK for emacs-devel@gnu.org; Sun, 24 Oct 2004 13:17:57 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CLlsa-0008Sg-Di for emacs-devel@gnu.org; Sun, 24 Oct 2004 13:10:04 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1CLlsH-0008FL-C0; Sun, 24 Oct 2004 13:09:45 -0400 Original-To: Luc Teirlinck In-reply-to: <200410240231.i9O2VlZ15381@raven.dms.auburn.edu> (message from Luc Teirlinck on Sat, 23 Oct 2004 21:31:47 -0500 (CDT)) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:28839 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:28839 I'm thinking of installing this doc string for Finteractive_p. Any comments or suggestions? DEFUN ("interactive-p", Finteractive_p, Sinteractive_p, 0, 0, 0, doc: /* Return t if the function was run directly by user input. This means that the function was called with call-interactively (which includes being called as the binding of a key) and input is currently coming from the keyboard (not in keyboard macro). The only known proper use of `interactive-p' is in deciding whether to print a helpful message. If you're thinking of using it for any other purpose, it is quite likely that you're making a mistake. Think: what do you want to do when the command is called from a keyboard macro? If you want to test whether your function was called with `call-interactively', the way to do that is by adding an extra optional argument, and making the `interactive' spec specify non-nil unconditionally for that argument. (`p' is a good way to do this.) */) I'm also thinking of this change for commands.texi. Any comments or suggestions? *** commands.texi 08 Sep 2004 11:40:24 -0400 1.55 --- commands.texi 24 Oct 2004 04:52:32 -0400 *************** *** 605,629 **** @end deffn @defun interactive-p ! This function returns @code{t} if the containing function (the one whose ! code includes the call to @code{interactive-p}) was called ! interactively, with the function @code{call-interactively}. (It makes ! no difference whether @code{call-interactively} was called from Lisp or ! directly from the editor command loop.) If the containing function was ! called by Lisp evaluation (or with @code{apply} or @code{funcall}), then ! it was not called interactively. ! @end defun ! The most common use of @code{interactive-p} is for deciding whether to ! print an informative message. As a special exception, ! @code{interactive-p} returns @code{nil} whenever a keyboard macro is ! being run. This is to suppress the informative messages and speed ! execution of the macro. ! For example: @example @group (defun foo () (interactive) (when (interactive-p) --- 605,626 ---- @end deffn @defun interactive-p ! This function returns @code{t} if the containing function (the one ! whose code includes the call to @code{interactive-p}) was called in ! direct response to user input. This means that it was called with the ! function @code{call-interactively}, and that a keyboard macro is ! not running. ! If the containing function was called by Lisp evaluation (or with ! @code{apply} or @code{funcall}), then it was not called interactively. ! @end defun ! The most common use of @code{interactive-p} is for deciding whether ! to print an informative message. For example: @example @group + ;; @r{Here's the usual way to use @code{interactive-p}.} (defun foo () (interactive) (when (interactive-p) *************** *** 632,637 **** --- 629,635 ---- @end group @group + ;; @r{This function is just to illustrate the behavior.} (defun bar () (interactive) (setq foobar (list (foo) (interactive-p)))) *************** *** 645,651 **** @group ;; @r{Type @kbd{M-x bar}.} ! ;; @r{This does not print anything.} @end group @group --- 643,649 ---- @group ;; @r{Type @kbd{M-x bar}.} ! ;; @r{This does not display a message.} @end group @group *************** *** 654,663 **** @end group @end example ! The other way to do this sort of job is to make the command take an ! argument @code{print-message} which should be non-@code{nil} in an ! interactive call, and use the @code{interactive} spec to make sure it is ! non-@code{nil}. Here's how: @example (defun foo (&optional print-message) --- 652,662 ---- @end group @end example ! If you want to test @emph{only} whether the function was called ! using @code{call-interactively}, add an optional argument ! @code{print-message} which should be non-@code{nil} in an interactive ! call, and use the @code{interactive} spec to make sure it is ! non-@code{nil}. Here's an example: @example (defun foo (&optional print-message)