On 4/25/07, Bob Hiestand <[EMAIL PROTECTED]> wrote:

On 4/25/07, Nikolai Weibull <[EMAIL PROTECTED]> wrote:

> OK, I guess then I don't understand your todo entry and Yakov's need for it.

I should clarify, it is my need, and I have no idea who added the
todo.  I found it while trying to discern if the functionality I
needed was provided already.

Ah, Yakov was only suggesting a way of doing it.

I realize you didn't add it, I'm just using "your" here to separate it
from "mine", that is, the one I suggested could be used for your need.

> Either way, wouldn't it be more useful to alter getcwd() to take an
> optional argument stating whether we want the local or global cwd?

The problem is that my plugin needs to change the current working
directory, perform an action, and then restore the previous working
directory.  I need to know whether to use :lcd or :cd to do that.  If
I use :cd in a window that had previously used :lcd, then I clobbered
the :lcd usage and that window is now stuck to the global directory;
additionally, the global directory is changed to whatever the prior
value.  If I instead use :lcd always, and the window wasn't previously
using a local directory, it now is.

let saved_cwd = getcwd('local')
let cd_cmd = (saved_cwd != getcwd('global')) ? 'lcd' : 'cd'
exec cd_cmd '…'
⋮
exec cd_cmd saved_cwd

(assuming getcwd('local') returns the local directory, if there is
one, or whatever getcwd('global') would, if not.)

 nikolai

Reply via email to