From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: A question about interactive Date: Fri, 22 Mar 2013 00:18:43 -0700 Message-ID: <2C911AFC62FB4E168237DA94E8D5EB75@us.oracle.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1363936743 22732 80.91.229.3 (22 Mar 2013 07:19:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 Mar 2013 07:19:03 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "'C K Kashyap'" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 22 08:19:29 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 1UIwG6-0007ZH-GG for geh-help-gnu-emacs@m.gmane.org; Fri, 22 Mar 2013 08:19:26 +0100 Original-Received: from localhost ([::1]:40859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIwFj-00081G-3p for geh-help-gnu-emacs@m.gmane.org; Fri, 22 Mar 2013 03:19:03 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIwFX-00081A-O5 for help-gnu-emacs@gnu.org; Fri, 22 Mar 2013 03:18:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIwFW-0007UQ-O3 for help-gnu-emacs@gnu.org; Fri, 22 Mar 2013 03:18:51 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:30716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIwFW-0007Tm-Hd for help-gnu-emacs@gnu.org; Fri, 22 Mar 2013 03:18:50 -0400 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r2M7Im4s017767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Mar 2013 07:18:49 GMT Original-Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r2M7IlGF016646 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 22 Mar 2013 07:18:47 GMT Original-Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id r2M7IkEl008637; Fri, 22 Mar 2013 02:18:47 -0500 Original-Received: from dradamslap1 (/10.159.248.227) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Mar 2013 00:18:46 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: Thread-Index: Ac4mys8XYTQoq9XATi+DNMZakN5t/wAASdEw X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 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:89655 Archived-At: >>> (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.