From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: build a macro that opens a directory and prompts for file name Date: Mon, 26 Jan 2009 11:15:01 +0100 Organization: Anevia SAS Message-ID: <7cwscil6fu.fsf@pbourguignon.anevia.com> References: <87f0e43c-d0e9-45eb-8d4f-ae5c7745a2a3@t26g2000prh.googlegroups.com> <4r5tz7qrqjh.fsf@one.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1232993481 11945 80.91.229.12 (26 Jan 2009 18:11:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 26 Jan 2009 18:11:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 26 19:12:30 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LRVwQ-00036a-HI for geh-help-gnu-emacs@m.gmane.org; Mon, 26 Jan 2009 19:12:10 +0100 Original-Received: from localhost ([127.0.0.1]:49745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LRVv8-0007j9-Mv for geh-help-gnu-emacs@m.gmane.org; Mon, 26 Jan 2009 13:10:50 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.wiretrip.org!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!cleanfeed4-a.proxad.net!nnrp12-1.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:MzAwOGY5ZGE0MGZlMGMxYjZiMzBiODViZjc2ZDdmM2FjZWM1NTZmMg== Original-Lines: 47 Original-NNTP-Posting-Date: 26 Jan 2009 11:15:01 MET Original-NNTP-Posting-Host: 88.170.236.224 Original-X-Trace: 1232964901 news-2.free.fr 25519 88.170.236.224:51852 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:166331 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:61651 Archived-At: "Drew Adams" 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__