From: C K Kashyap <ckkashyap@gmail.com>
To: Drew Adams <drew.adams@oracle.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: A question about interactive
Date: Fri, 22 Mar 2013 16:54:13 +0530 [thread overview]
Message-ID: <CAGdT1gqX3prN6iNvjJx7zCxmhTEoY_ZD8awaiTWJRjXusi3gtg@mail.gmail.com> (raw)
In-Reply-To: <2C911AFC62FB4E168237DA94E8D5EB75@us.oracle.com>
[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]
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 <drew.adams@oracle.com> 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.
>
>
>
>
>
[-- Attachment #2: Type: text/html, Size: 3206 bytes --]
next prev parent reply other threads:[~2013-03-22 11:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-21 6:46 A question about interactive C K Kashyap
2013-03-21 13:24 ` Drew Adams
2013-03-22 6:59 ` C K Kashyap
2013-03-22 7:18 ` Drew Adams
2013-03-22 11:24 ` C K Kashyap [this message]
2013-03-22 14:45 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGdT1gqX3prN6iNvjJx7zCxmhTEoY_ZD8awaiTWJRjXusi3gtg@mail.gmail.com \
--to=ckkashyap@gmail.com \
--cc=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).