From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: Looking for CDPATH functionality in emacs. Date: Mon, 03 Jan 2011 22:55:23 -0700 Message-ID: References: <4D221B85.5040702@syslang.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1294121215 14150 80.91.229.12 (4 Jan 2011 06:06:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 4 Jan 2011 06:06:55 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 04 07:06:51 2011 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.69) (envelope-from ) id 1Pa02k-000516-Pn for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Jan 2011 07:06:51 +0100 Original-Received: from localhost ([127.0.0.1]:35789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pa02j-0002mW-U5 for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Jan 2011 01:06:50 -0500 Original-Received: from [140.186.70.92] (port=35166 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZzrb-0005RI-92 for help-gnu-emacs@gnu.org; Tue, 04 Jan 2011 00:55:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PZzrZ-0000Zc-Vz for help-gnu-emacs@gnu.org; Tue, 04 Jan 2011 00:55:19 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:38793) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PZzrZ-0000ZV-IZ for help-gnu-emacs@gnu.org; Tue, 04 Jan 2011 00:55:17 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PZzrX-0007na-Hl for help-gnu-emacs@gnu.org; Tue, 04 Jan 2011 06:55:15 +0100 Original-Received: from c-24-8-96-241.hsd1.co.comcast.net ([24.8.96.241]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Jan 2011 06:55:15 +0100 Original-Received: from kevin.d.rodgers by c-24-8-96-241.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 04 Jan 2011 06:55:15 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 109 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: c-24-8-96-241.hsd1.co.comcast.net User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 In-Reply-To: <4D221B85.5040702@syslang.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:78150 Archived-At: On 1/3/11 11:55 AM, Steven W. Orr wrote: > This is a bit long, so all I can do is apologise. > > I have a number of directories that I use frequently. From the bash side of > things I set the CDPATH variable in bash to :d1:d2:d3 and then I can just go > to places inside d[123] and it just works. I also have the bash variable > cdable_vars set to allow me to say > > d4=/path/to/d4 > > followed by > > cd d4 > > and it all works peachy keen. > > What I'd like to do in emacs is to be able to visit a file in some directory > that I favor (somehow) so that it will automagically find it without having to > slog through the whole path to get there. > > I did find file-cache-find-directory which looks like it's half of what I > want. But that has two problems: > > 1. I added this to my .emacs > > (file-cache-add-directory "/path/to/special/dir") > > I saw no special behavior when I ran this, either from my .emacs or interactively. According to filecache.el: ;; FINDING FILES USING THE CACHE: ;; ;; You can use the file-cache with any function that expects a filename as ;; an argument. For example: ;; ;; 1) Invoke a function which expects a filename as an argument: ;; M-x find-file ;; ;; 2) Begin typing a file name. ;; ;; 3) Invoke `file-cache-minibuffer-complete' (bound by default to ;; C-TAB) to complete on the filename using the cache. ;; ;; 4) When you have found a unique completion, the minibuffer contents ;; will change to the full name of that file. ;; ;; If there are a number of directories which contain the completion, ;; invoking `file-cache-minibuffer-complete' repeatedly will cycle through ;; them. ;; ;; 5) You can then edit the minibuffer contents, or press RETURN. ;; ;; It is much easier to simply try it than trying to explain it :) > 2. I normally visit files using my own my-visit-file function: > > (defun my-visit-file (arg) > "Visit a file using completion. If there is only one window with > nothing in it, then do not split the current window. " > (interactive "Fmy-visit-file :") > (if (and (one-window-p) (zerop (buffer-size))) > (find-file arg t) > (find-file-other-window arg t))) > > I use this function so that if I visit a file from an empty buffer, I won't > end up with two windows. Actually, that is Emacs' default behavior. Using M-x my-visit-file only behaves differently than M-x find-file when you have more than one window or the current is not empty: in that case, it behaves like M-x find-file-other-window. > The problem is that if I had run file-cache-add-directory, the find-file > function starts in the directory of where the current buffer is. I'd like to > make it so that if I supplied a C-u to my-visit-file then it would *not* start > from that current directory. Instead, it should give me a prompt as if I had > done a C-a C-k to get rid of the directory. Reading a file name via (interactive "F...") always starts from the current buffer's default directory, regardless of whether file-cache-add-directory has been run. If you want to make my-find-file behave differently when reading its ARG, depending on whether a prefix arg was supplied, then change the interactive form to use a lisp expression that respects current-prefix-arg (instead of a string specifier). > So, if you made it this far, here's the recap: > > 1. Does anything already exist that smells like what I want? Use filecache as it is documented. > 2. Can I fix my-visit-file so that a C-u will prevent the default prompt from > being the current directory of the file I'm starting from? (But I do still > want filename completion.) (interactive (list (if current-prefix-arg (read-file-name "My file: " "/") (read-file-name "My file: ")))) > 3. Does anyone have a better idea? :-) -- Kevin Rodgers Denver, Colorado, USA