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

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

Looking for CDPATH functionality in emacs.


From: Steven W. Orr
Subject: Looking for CDPATH functionality in emacs.
Date: Mon, 03 Jan 2011 13:55:01 -0500
User-agent: Thunderbird 2.0.0.23 (X11/20090825)

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.

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.

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.

So, if you made it this far, here's the recap:

1. Does anything already exist that smells like what I want?
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.)
3. Does anyone have a better idea?

MTIA :-)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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