From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: ELisp Interactive Calls Date: Sat, 20 Dec 2014 03:38:21 +0700 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1419021523 13190 80.91.229.3 (19 Dec 2014 20:38:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Dec 2014 20:38:43 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: mflynn@scu.edu Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 19 21:38:36 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y24Jm-0000gv-D4 for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Dec 2014 21:38:34 +0100 Original-Received: from localhost ([::1]:60458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y24Jl-0002ap-CI for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Dec 2014 15:38:33 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y24Jb-0002ak-25 for help-gnu-emacs@gnu.org; Fri, 19 Dec 2014 15:38:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y24JZ-00061S-Uv for help-gnu-emacs@gnu.org; Fri, 19 Dec 2014 15:38:23 -0500 Original-Received: from mail-ie0-x234.google.com ([2607:f8b0:4001:c03::234]:54857) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y24JZ-000615-Px for help-gnu-emacs@gnu.org; Fri, 19 Dec 2014 15:38:21 -0500 Original-Received: by mail-ie0-f180.google.com with SMTP id rp18so1436190iec.11 for ; Fri, 19 Dec 2014 12:38:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=wi/cz6oBdYlFwAp4OJagqlR2sN+KGgfeeVMjMb3ih3Q=; b=RFaq6n0plExn+NL0LeeXxVy1KAHoWVL25o8vBvdhx7NSLXjHyBC2VxLM1KWE9SF6iD BSyZpx8kabA9DU6q6kB/kpjI3Vgx0hhtCiBk4MqFOjV2Cwzv48EkCuLOFAJajmY8KPHJ aV+K7yrQc0taegh+fpCgNFZXyNlVqBedITYeL0SMS+rg0eGSomedHlQsLSJF2dMG+Yw/ Gn8ntq543uw58Dh8FAUWQ8XNjivs+c+c5JMZlyVZcrSa3hlcpFk/0pAgQuZucwlCwYuS p/7zOEomfgSxQq4tc8UI6gieG0xAVEEK7S8cieuFLBe2rBWBvtW4X13hu47WgT2sPQmc egSA== X-Received: by 10.107.11.10 with SMTP id v10mr9646115ioi.12.1419021501251; Fri, 19 Dec 2014 12:38:21 -0800 (PST) Original-Received: by 10.107.48.82 with HTTP; Fri, 19 Dec 2014 12:38:21 -0800 (PST) In-Reply-To: X-Google-Sender-Auth: R7e7ChXNgcjHJ-O_6TAYWS88psE X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::234 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:101683 Archived-At: On Sat, Dec 20, 2014 at 2:13 AM, wrote: > (defun my-test-function (arg1 arg2) > "DOC: Multiply two numbers." > (interactive "p p") > (message "The product of the args is: %d" (* arg1 arg2)) > ) > > How do I call this? If I type Ctrl-U 8 8 Esc-x my-test-function > > the call fails with a Wrong number of args message. The second 8 I type= just shows up in the scratch buffer. Have you read the documentation on =E2=80=9Cinteractive=E2=80=9D? (C-h f in= teractive) =E2=80=9CTo get several arguments, concatenate the individual strings, separating them by newline characters.=E2=80=9D (defun my-test-function (arg1 arg2) "DOC: Multiply two numbers." (interactive "p\np") (message "The product of the args is: %d" (* arg1 arg2))) C-u 8 M-x my-test-function =3D> The product of the args is: 64 It kind of works, but is kind of useless, because the universal prefix gets fed into *both* arguments. =E2=80=9Cn -- Number read using minibuffer. N -- Numeric prefix arg, or if none, do like code `n'. p -- Prefix arg converted to number. Does not do I/O.=E2=80=9D Now this looks useful. (defun my-test-function (arg1 arg2) "DOC: Multiply two numbers." (interactive "N\nn") (message "The product of the args is: %d" (* arg1 arg2))) C-u 8 M-x my-test-function 7 =3D> The product of the args is: 56 M-x my-test-function 8 7 =3D> The product of the args is: 56 =E2=80=9CUsually the argument of `interactive' is a string containing a cod= e letter followed optionally by a prompt.=E2=80=9D Let=E2=80=99s use that to give useful prompts. (defun my-test-function (arg1 arg2) "DOC: Multiply two numbers." (interactive "NMultiply what: \nnMultiply by: ") (message "The product of the args is: %d" (* arg1 arg2))) C-u 8 M-x my-test-function Multiply by: 7 =3D> The product of the args is: 56 M-x my-test-function Multiply what: 8 Multiply by: 7 =3D> The product of the args is: 56