all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* set a "default" directory in a function when asking for a file
@ 2008-11-16 13:39 Niels Felsted Thorsen
  0 siblings, 0 replies; 3+ messages in thread
From: Niels Felsted Thorsen @ 2008-11-16 13:39 UTC (permalink / raw)
  To: help-gnu-emacs

Hi

I have a function like this:

(defun testfun (file)
  (interactive "fFile: ")
  (message file))

But it will ask for the file based on, as I understand it, the value
of "default-directory" which is buffer-local.

Is there a way to specify default-directory just for this function? So
it will always start with fx:

File: ~/foo/bar/

when asking for the file.







^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: set a "default" directory in a function when asking for a file
       [not found] <mailman.513.1226848810.26697.help-gnu-emacs@gnu.org>
@ 2008-11-16 15:47 ` Niels Giesen
  2008-11-16 18:06   ` Niels Felsted Thorsen
  0 siblings, 1 reply; 3+ messages in thread
From: Niels Giesen @ 2008-11-16 15:47 UTC (permalink / raw)
  To: help-gnu-emacs

Niels Felsted Thorsen <nift@maclisp.org> writes:

> Hi
>
> I have a function like this:
>
> (defun testfun (file)
>   (interactive "fFile: ")
>   (message file))
>
> But it will ask for the file based on, as I understand it, the value
> of "default-directory" which is buffer-local.
>
> Is there a way to specify default-directory just for this function? So
> it will always start with fx:
>
> File: ~/foo/bar/
>
> when asking for the file.
>

Define your function as follows:

(defun testfun (file)
  (interactive (list (read-file-name "File: " "~/foo/bar/")))
  (message file))



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: set a "default" directory in a function when asking for a file
  2008-11-16 15:47 ` set a "default" directory in a function when asking for a file Niels Giesen
@ 2008-11-16 18:06   ` Niels Felsted Thorsen
  0 siblings, 0 replies; 3+ messages in thread
From: Niels Felsted Thorsen @ 2008-11-16 18:06 UTC (permalink / raw)
  To: help-gnu-emacs

Niels Giesen <niels.giesen@gmail.com> writes:

> Niels Felsted Thorsen <nift@maclisp.org> writes:
>
>> Hi
>>
>> I have a function like this:
>>
>> (defun testfun (file)
>>   (interactive "fFile: ")
>>   (message file))
>>
>> But it will ask for the file based on, as I understand it, the value
>> of "default-directory" which is buffer-local.
>>
>> Is there a way to specify default-directory just for this function? So
>> it will always start with fx:
>>
>> File: ~/foo/bar/
>>
>> when asking for the file.
>>
>
> Define your function as follows:
>
> (defun testfun (file)
>   (interactive (list (read-file-name "File: " "~/foo/bar/")))
>   (message file))

Thank you :)





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-16 18:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.513.1226848810.26697.help-gnu-emacs@gnu.org>
2008-11-16 15:47 ` set a "default" directory in a function when asking for a file Niels Giesen
2008-11-16 18:06   ` Niels Felsted Thorsen
2008-11-16 13:39 Niels Felsted Thorsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.