The attached patch very simply implements the following from the todo:
7 There is no way to change directory and go back without changing the local and/or global directory. Add a way to find out if the current window uses a local directory. Add cdcmd() that returns ":cd" or ":lcd"? I personally would prefer the function be called something like 'isdirlocal()'. I need this feature for my vcscommand.vim plugin, which changes directory a fair amount, and can screw up the user environment if the user makes use of :lcd. Thank you, bob ---------- Forwarded message ---------- From: Bob Hiestand <[EMAIL PROTECTED]> Date: Apr 11, 2007 4:06 PM Subject: Re: Determining whether a window used :lcd To: Yakov Lerner <[EMAIL PROTECTED]> Cc: "vim@vim.org" <vim@vim.org> On 4/11/07, Yakov Lerner <[EMAIL PROTECTED]> wrote:
I needed this once in of my script. I ended with some rude simplification/workaround, lackng the direct simple solution. I don't know your specific case, but you might find simlpistic workaround. One weird attempt to determine this would be to (I did not do it): (1) get getcwd() in the window in quiestion (2) create temp new window with :new (3) get getcwd() in the new temp window (4) compare cwd from step (3) against cwd from step(1) (5) :bw the temp window This has lots of drawcacks: - I am not sure this sequence works in the presence of :acd thought. - I am not sure this sequence works at all, but I can't think of other method either. - This sequence won't detect one subtle case: case the :lcd is set, but is set to directory X where X is same as current directory. (This case behaves differently that case without :lcd, but this difference might not matter to you).
I don't think it works. When you use :new, you inherit the :lcd, if it was used.
Maybe vim needs new functions getlcwd(), hetgcwd(), or additional 2nd param to getcwd() to return global/local dir.
After looking in the :help todo, it appears that others have requested it. I've thrown together a quick patch to implement the described 'cdcmd()' (I prefer a more direct 'isdirlocal()'), but that's fine. I'll try submitting it. Thank you, bob
cdcmd.patch
Description: Binary data