[Idle-dev] RE: Current Working Directory

Kurt B. Kaiser kbk@shore.net
Sat, 31 May 2003 19:43:00 -0400


Guido van Rossum <guido@python.org> writes:

> Here's the model I'd like to see.  It's similar to what Emacs does,
> and it works very well for me there.  Each window has a directory
> associated with it.  This is normally the directory containing the
> file loaded in the window; if a window has no file loaded in it, it
> should be the directory of the window from which this window was
> created.  E.g. if I'm editing a file /foo/bar.py, and I hit ^N to
> create a new window, the new window's directory should be /foo.  The
> directory associated with a window should be used as the initial
> directory for all Open and Save dialogs.  If you use Save As into a
> different directory, the window's directory changes (but not so for
> Save A Copy).  All this has nothing to do with the current directory
> of the IDLE process itself, which is never changed.  If the initial
> window has no file associated with it (e.g. it is a Python Shell
> window) then it should be the startup directory of IDLE.

Works ok for existing modules being opened.

> (I think this is pretty much already implemented except for
> file-less windows, which seem to inherit IDLE's initial directory.)

It turns out this is rather complex to fix, involving 4 - 5 modules
in an area that has some bugs (WindowList when opening a new file)
and is in need of refactoring.  I got it working here (we've heard
that before :) but I think it's too much change for the level of
importance this close to the 2.3 release.  So I'm going to defer
it to 2.4.

> The Run command should use the file's directory as the initial cwd
> of the subprocess started, and this should also set directory
> associated with the Python Shell window where the output is sent.

Implemented.  Also, from a previously checked-in fix, the sys.path is
updated to include that directory so associated modules can be found.

--
KBK