From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Run Non-Interactive Function with Prefix Date: Tue, 18 Oct 2005 20:09:29 +0200 Organization: Informatimago Message-ID: <87d5m27l46.fsf@thalassa.informatimago.com> References: <87ach6dbh2.fsf@be.cs.appstate.edu> <4355290F.3030008@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1129659158 8087 80.91.229.2 (18 Oct 2005 18:12:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 18 Oct 2005 18:12:38 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 18 20:12:35 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ERvuo-0002Wq-3D for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Oct 2005 20:10:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ERvun-0005Gr-Cc for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Oct 2005 14:10:21 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news2.google.com!proxad.net!proxad.net!easynet-quince!easynet.net!easynet-post2!not-for-mail Original-Newsgroups: gnu.emacs.help Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:MDqaUZfweamHLcSEWtt3jH1wre4= Original-Lines: 53 Original-NNTP-Posting-Host: 62.93.174.79 Original-X-Trace: DXC=aC;2?PeiZMV9P4BAi5NHR^9faNSh;fPf^bBd4DjF1d]Q Original-Xref: shelby.stanford.edu gnu.emacs.help:134754 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:30336 Archived-At: Kenneth Jacker writes: > lb> Do you mean (foobar ARG), perhaps (foobar t) or (foobar 1)? > > No. The function 'foobar' might or might not require an ARG. > > > What I want to do is specify a *prefix* before invoking 'foobar'. > Note that this is independent of whether the function has a required > argument or not. > > I specify this interactively with "C-u", but how to do it *non*-interactively? But really, prefixes are awkward. We cope with them for interactive commands, but for functions it is silly to try to use them. For functions, the best is to pass arguments. If you have optional arguments, then declare them optional: (defun foo (mandatory-arg-1 mandatory-arg-2 &optional optional-arg-1 optional-arg-2) ...) When you call interactively a function, you must type: M-: (foo "arg1" 2 :optional-value-1) RET In some cases you can use global variables: (defvar *parameter-for-foo* :default-value) (defun foo () ... *parameter-for-foo* ...) When you call interactively a function, you must type: M-: (let ((*parameter-for-foo* :my-value)) (foo)) RET or: M-: (setf *parameter-for-foo* :new-value) RET M-: (foo) RET If you insist on prefix, then write a command! Just insert (interactive) at the right place. -- __Pascal Bourguignon__ http://www.informatimago.com/ Grace personified, I leap into the window. I meant to do that.