help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: build a macro that opens a directory and prompts for file name


From: Pascal J. Bourguignon
Subject: Re: build a macro that opens a directory and prompts for file name
Date: Mon, 26 Jan 2009 11:15:01 +0100
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux)

"Drew Adams" <address@hidden> writes:

>> > > I have been googleing and reading the docs trying to figure out a
>> > > solution to this. I spend the majority of my time working 
>> > > in a single directory on a CIFS server and I am always doing a 
>> > > C-x C-f \\server\dir\long_sub_dir\subdir\filename
>> >
>> > > In the spirit of emacs I'd like to automate it so that 
>> > > when I do C-co it knows the directory and simply prompts me for
>> > > the file to be opened or if I leave it blank and press RET it
>> > > lists the directory.
>> >
>> > I use bookmarks to take me to the directories themselves.
>>
>> Thanks Chris. That is exactly what I need. Wonderful.
>
> I too use and recommend using bookmarks.
>
> But from your description, all you want is a command that reads a file name in
> some predefined directory. You can do that just by binding `default-directory'
> to the directory and calling `find-file':

This is not even needed!

You only have to type C-x C-f, that's all. By default it is in the
default-directory, which is a buffer local variable, so if your
current buffer is in the right directory, you've got nothing more to
do.

So the answer, and you won't say you've not been warned, is not to
kill your old buffers!  Just leave them alone in emacs.  Thus, with
your old buffer in the right directory, you just type C-x C-f and the
other file name.

If you really need to kill your buffer before opening another file,
you could open a directory buffer:
   C-x C-f \\server\dir\long_sub_dir\subdir\ RET

Note that in this directory buffer you may just click (or type RET) on
a file to open it.


Also, you could use some more sophisticated package such as speedbar,
but it would be overkill...

-- 
__Pascal Bourguignon__


reply via email to

[Prev in Thread] Current Thread [Next in Thread]