all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* build a macro that opens a directory and prompts for file name
@ 2009-01-23 15:13 Norm
  2009-01-23 15:27 ` Chris McMahan
  2009-01-29 13:08 ` Sebastian Tennant
  0 siblings, 2 replies; 10+ messages in thread
From: Norm @ 2009-01-23 15:13 UTC (permalink / raw)
  To: help-gnu-emacs

Hello all,

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.

Any suggestions on how to accomplish this.

Many thanks,

Norm


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

* Re: build a macro that opens a directory and prompts for file name
  2009-01-23 15:13 build a macro that opens a directory and prompts for file name Norm
@ 2009-01-23 15:27 ` Chris McMahan
  2009-01-23 15:38   ` Norm
  2009-01-29 13:08 ` Sebastian Tennant
  1 sibling, 1 reply; 10+ messages in thread
From: Chris McMahan @ 2009-01-23 15:27 UTC (permalink / raw)
  To: help-gnu-emacs

Norm <NormanBauer@gmail.com> writes:

> Hello all,
>
> 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.
>
> Any suggestions on how to accomplish this.
>
> Many thanks,
>
> Norm

I use bookmarks to take me to the directories themselves.

- Go to the directory that contains the file you want 
- Press C-x r m to memorize that location, and give it a name you can
  remember

to navigate to that directory, just press C-x r b. You'll be prompted
for the bookmark name, and it will open that directory.

See the help for the function 'command bookmark-set' for details

- Chris

-- 
     (.   .)
  =ooO=(_)=Ooo=====================================
  Chris McMahan | first_initiallastname@one.dot.net
  =================================================


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

* Re: build a macro that opens a directory and prompts for file name
  2009-01-23 15:27 ` Chris McMahan
@ 2009-01-23 15:38   ` Norm
  2009-01-24  7:16     ` Drew Adams
       [not found]     ` <mailman.5627.1232781454.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Norm @ 2009-01-23 15:38 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 23, 10:27 am, Chris McMahan <cmcma...@one.net> wrote:
> Norm <NormanBa...@gmail.com> writes:
> > Hello all,
>
> > 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.
>
> > Any suggestions on how to accomplish this.
>
> > Many thanks,
>
> > Norm
>
> I use bookmarks to take me to the directories themselves.
>
> - Go to the directory that contains the file you want
> - Press C-x r m to memorize that location, and give it a name you can
>   remember
>
> to navigate to that directory, just press C-x r b. You'll be prompted
> for the bookmark name, and it will open that directory.
>
> See the help for the function 'command bookmark-set' for details
>
> - Chris
>
> --
>      (.   .)
>   =ooO=(_)=Ooo=====================================
>   Chris McMahan | first_initiallastn...@one.dot.net
>   =================================================

Thanks Chris. That is exactly what I need. Wonderful.


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

* RE: build a macro that opens a directory and prompts for file name
  2009-01-23 15:38   ` Norm
@ 2009-01-24  7:16     ` Drew Adams
       [not found]     ` <mailman.5627.1232781454.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Drew Adams @ 2009-01-24  7:16 UTC (permalink / raw)
  To: 'Norm', help-gnu-emacs

> > > 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':

(defun foo ()
  "Visit a file in my favorite directory."
  (interactive)
  (let ((default-directory "/my.server.somewhere:/dir/longsubdir/subdir/"))
    (call-interactively 'find-file)))





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

* Re: build a macro that opens a directory and prompts for file name
       [not found]     ` <mailman.5627.1232781454.26697.help-gnu-emacs@gnu.org>
@ 2009-01-26 10:15       ` Pascal J. Bourguignon
  2009-01-26 18:15         ` Drew Adams
       [not found]         ` <mailman.5864.1232993759.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Pascal J. Bourguignon @ 2009-01-26 10:15 UTC (permalink / raw)
  To: help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> 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__


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

* RE: build a macro that opens a directory and prompts for file name
  2009-01-26 10:15       ` Pascal J. Bourguignon
@ 2009-01-26 18:15         ` Drew Adams
       [not found]         ` <mailman.5864.1232993759.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Drew Adams @ 2009-01-26 18:15 UTC (permalink / raw)
  To: 'Pascal J. Bourguignon', help-gnu-emacs

> >> > > 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...

All of what Pascal says is true and pertinent.

FYI, you can also just use Emacs (yes, Emacs) command `cd' to change the
`default-directory' at any time. No need to open a Dired buffer.





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

* Re: build a macro that opens a directory and prompts for file name
       [not found]         ` <mailman.5864.1232993759.26697.help-gnu-emacs@gnu.org>
@ 2009-01-27 10:04           ` Stefan Kamphausen
  2009-01-27 10:45             ` roodwriter
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Kamphausen @ 2009-01-27 10:04 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

"Drew Adams" <drew.adams@oracle.com> writes:

> FYI, you can also just use Emacs (yes, Emacs) command `cd' to change the
> `default-directory' at any time. No need to open a Dired buffer.

FWIW, cdargs ([1]please excuse the self-ad) offers a kind of bookmarks for
the shell and ships with some elisp to use the cdargs bookmarks from
Emacs, too.

Cheers,
Stefan

Footnotes: 
[1]  http://www.skamphausen.de/cgi-bin/ska/CDargs

-- 
Stefan Kamphausen --- http://www.skamphausen.de
a blessed +42 regexp of confusion (weapon in hand)
You hit. The format string crumbles and turns to dust.


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

* Re: build a macro that opens a directory and prompts for file name
  2009-01-27 10:04           ` Stefan Kamphausen
@ 2009-01-27 10:45             ` roodwriter
  2009-01-28  8:09               ` Kevin Rodgers
  0 siblings, 1 reply; 10+ messages in thread
From: roodwriter @ 2009-01-27 10:45 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Kamphausen <skampi@gmx.net> writes:

> Hi,
>
> "Drew Adams" <drew.adams@oracle.com> writes:
>
>> FYI, you can also just use Emacs (yes, Emacs) command
>> `cd' to change the `default-directory' at any time. No
>> need to open a Dired buffer.
>
> FWIW, cdargs ([1]please excuse the self-ad) offers a kind
> of bookmarks for the shell and ships with some elisp to
> use the cdargs bookmarks from Emacs, too.
>
> Cheers, Stefan
>
> Footnotes: [1]
> http://www.skamphausen.de/cgi-bin/ska/CDargs
>
> -- Stefan Kamphausen --- http://www.skamphausen.de a
> blessed +42 regexp of confusion (weapon in hand) You hit.
> The format string crumbles and turns to dust.


Bookmarks, which I use, work great for small numbers of
files. But since I generate tons of small files, I keep an
index list of files, with their descriptions, plus the
entire path and file name for that file. So they look
something like this:

/home/rod/vacation.txt How I spent my summer vacation.

I have a macro that copies the entire file name and path and
pastes it into C-x C-f. I've bound it to a function key so
my index kind of works like a hyperlink.

Rod


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

* Re: build a macro that opens a directory and prompts for file name
  2009-01-27 10:45             ` roodwriter
@ 2009-01-28  8:09               ` Kevin Rodgers
  0 siblings, 0 replies; 10+ messages in thread
From: Kevin Rodgers @ 2009-01-28  8:09 UTC (permalink / raw)
  To: help-gnu-emacs

roodwriter@ureach.com wrote:
> Bookmarks, which I use, work great for small numbers of
> files. But since I generate tons of small files, I keep an
> index list of files, with their descriptions, plus the
> entire path and file name for that file. So they look
> something like this:
> 
> /home/rod/vacation.txt How I spent my summer vacation.
> 
> I have a macro that copies the entire file name and path and
> pastes it into C-x C-f. I've bound it to a function key so
> my index kind of works like a hyperlink.

If you're visiting your index file, then `M-x find-file-at-point'
will do the trick.  Or just `C-x C-f' with this in your ~/.emacs:

(ffap-bindings)

-- 
Kevin Rodgers
Denver, Colorado, USA





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

* Re: build a macro that opens a directory and prompts for file name
  2009-01-23 15:13 build a macro that opens a directory and prompts for file name Norm
  2009-01-23 15:27 ` Chris McMahan
@ 2009-01-29 13:08 ` Sebastian Tennant
  1 sibling, 0 replies; 10+ messages in thread
From: Sebastian Tennant @ 2009-01-29 13:08 UTC (permalink / raw)
  To: help-gnu-emacs

Quoth Norm <NormanBauer@gmail.com>:
> 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.
>
> Any suggestions on how to accomplish this.

I don't have time to read this (fairly long) thread but I've been using
a (tiny) macro for years which I think may meet your needs perfectly.

You can get it from here:

 http://article.gmane.org/gmane.emacs.sources/3157

In your case, you could define a command 'M-x cifs' in your ~/.emacs
like so:

 (require 'commandir)

 (commandir cifs                                  ; command name
            "CIFS hosted filename: "              ; prompt
            "\\server\dir=long_sub_dir\subdir"    ; directory
            "<name-of-file-you-visit-most"        ; default
            )

The great thing is you can define as many commands as you like:

 (commandir cifs2 ...)


HTH,

Sebastian
-- 
Emacs' AlsaPlayer - Music Without Jolts
Lightweight, full-featured and mindful of your idyllic happiness.
http://home.gna.org/eap





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

end of thread, other threads:[~2009-01-29 13:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-23 15:13 build a macro that opens a directory and prompts for file name Norm
2009-01-23 15:27 ` Chris McMahan
2009-01-23 15:38   ` Norm
2009-01-24  7:16     ` Drew Adams
     [not found]     ` <mailman.5627.1232781454.26697.help-gnu-emacs@gnu.org>
2009-01-26 10:15       ` Pascal J. Bourguignon
2009-01-26 18:15         ` Drew Adams
     [not found]         ` <mailman.5864.1232993759.26697.help-gnu-emacs@gnu.org>
2009-01-27 10:04           ` Stefan Kamphausen
2009-01-27 10:45             ` roodwriter
2009-01-28  8:09               ` Kevin Rodgers
2009-01-29 13:08 ` Sebastian Tennant

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.