From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: C K Kashyap Newsgroups: gmane.emacs.help Subject: Re: A question about interactive Date: Fri, 22 Mar 2013 16:54:13 +0530 Message-ID: References: <2C911AFC62FB4E168237DA94E8D5EB75@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=20cf303b4187e87f2004d881b1fe X-Trace: ger.gmane.org 1363951473 31617 80.91.229.3 (22 Mar 2013 11:24:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 Mar 2013 11:24:33 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 22 12:24:59 2013 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 1UJ05d-0004tM-96 for geh-help-gnu-emacs@m.gmane.org; Fri, 22 Mar 2013 12:24:53 +0100 Original-Received: from localhost ([::1]:44812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ05F-0002em-F2 for geh-help-gnu-emacs@m.gmane.org; Fri, 22 Mar 2013 07:24:29 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ052-0002cU-8m for help-gnu-emacs@gnu.org; Fri, 22 Mar 2013 07:24:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UJ050-0001AB-HG for help-gnu-emacs@gnu.org; Fri, 22 Mar 2013 07:24:16 -0400 Original-Received: from mail-qa0-f46.google.com ([209.85.216.46]:58943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UJ050-0001A6-Bv for help-gnu-emacs@gnu.org; Fri, 22 Mar 2013 07:24:14 -0400 Original-Received: by mail-qa0-f46.google.com with SMTP id k4so767703qaq.12 for ; Fri, 22 Mar 2013 04:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=NaXb74yi9ScQ3B+uP7L9spN9Re5j1Mdc+uNSG07mXxs=; b=I9voyhSHvC4fJRGQ/CaWINkVgKG2ox0cshVJZwlt/fYnBMFl+tHtL+MA3+wDz6YtKW QUzjAd/5Rs8iDqnkXDZLTesar36JD8KHlq7fkvE7BR6KYNAz4e5UeKGK256EqVw3j+JI 7g7gWkfXjTDX6V1i14yvxf7OJe2fhoK3rtw9sa74hM3qiTmM2ZTI843UiD5wLEOqeovh TBC5N0+xfqu0YVzsJ8Ez3RjITk9nAWWcE6yR4vIGAq1UpxT4vhgtfgE7J3oQnWPHKkot 9PUDFqCLQa09xX6u0+vwD38rTpGEz0Q+skE86ijOlXmMVrJPRcpd51iAHzPuNm02qx0s Ey5w== X-Received: by 10.224.181.200 with SMTP id bz8mr114175qab.68.1363951454025; Fri, 22 Mar 2013 04:24:14 -0700 (PDT) Original-Received: by 10.229.34.3 with HTTP; Fri, 22 Mar 2013 04:24:13 -0700 (PDT) In-Reply-To: <2C911AFC62FB4E168237DA94E8D5EB75@us.oracle.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.216.46 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:89662 Archived-At: --20cf303b4187e87f2004d881b1fe Content-Type: text/plain; charset=ISO-8859-1 Thanks Drew ... After defining f this way (defun f (file) (interactive (list (read-file-name "Filename: " "c:/")) (insert file)) when I run f M-x f - it asks for the file name but it does not insert into the buffer. I was not able to read about this in C-h-f interactive - Can you explain what's happening here - interactive is supposed to take in a string as its argument -how is it working with a list? Regards, Kashyap On Fri, Mar 22, 2013 at 12:48 PM, Drew Adams wrote: > >>> (interactive "fEnter script name: ") > >>> Now, the problem is that the ineractive "f" seems to > >>> use the current buffer location as the starting point. > >>> How can I change that? > >> > >> In the `interactive' spec, let-bind `default-directory' > >> and then read the file name with `read-file-name'. > >> See the doc for `interactive'. > > > > Thanks a lot Drew ... using read-file-name worked for me > > (defun f () > > (interactive) > > (setq fn (read-file-name "Enter filename" "C:/")) > > (insert fn)) > > > > I did not have to do the let-binding of default-directory - > > actually I do not know how to do it either. It'll be great if > > you could show me what you meant. > > I meant this - read the file name in the `interactive' spec: > > (defun f (file) > (interactive (list (read-file-name "Filename: " "c:/")) > (insert file)) > > I misled you wrt `default-directory'. There's no need to let-bind > `default-directory' around `read-file-name', since you can just pass the > value > as the optional second arg, as you did. I forgot about that. I was > thinking of > this (equivalent, but unnecessary): > > (let ((default-directory "c:/")) > (read-file-name "Filename: ")) > > Sorry for the extra noise. > > > > > --20cf303b4187e87f2004d881b1fe Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks Drew ...=A0
After defini= ng f this way
(defun f (file)
=A0 (interactive (list (read-file-name "Filename: " "c:/&qu= ot;))
=A0 (insert file))
when I run f M-x f - it ask= s for the file name but it does not insert into the buffer.

I was not able to read about this i= n C-h-f interactive -=A0
Can you explain what's happeni= ng here =A0- interactive is supposed to take in a string as its argument -h= ow is it working with a list?

Regards,
Kashyap



On Fri, Mar 22, 2013 at 12:48 PM, Drew Adams <= ;drew.adams@orac= le.com> wrote:
>>> (interactive = "fEnter script name: ")
>>> Now, the problem is that =A0the ineractive "f" seems= to
>>> use the current buffer location as the starting point.
>>> How can I change that?
>>
>> In the `interactive' spec, let-bind `default-directory' >> and then read the file name with `read-file-name'.
>> See the doc for `interactive'.
>
> Thanks a lot Drew ... using read-file-name wor= ked for me
> (defun f ()
> =A0(interactive)
> =A0(setq fn (read-file-name "Enter filename" "C:/"= ))
> =A0(insert fn))
>
> I did not have to do the let-binding of default-directory -
> actually I do not know how to do it either. It'll be great if
> you could show me what you meant.

I meant this - read the file name in the `interactive' spec:

(defun f (file)
=A0 (interactive (list (read-file-name "Filename: " "c:/&quo= t;))
=A0 (insert file))

I misled you wrt `default-directory'. =A0There's no need to let-bin= d
`default-directory' around `read-file-name', since you can just pas= s the value
as the optional second arg, as you did. =A0I forgot about that. =A0I was th= inking of
this (equivalent, but unnecessary):

(let ((default-directory =A0"c:/"))
=A0 (read-file-name "Filename: "))

Sorry for the extra noise.





--20cf303b4187e87f2004d881b1fe--