Loading ...
Sorry, an error occurred while loading the content.

Re: [PATCH] Determining whether a window used :lcd

Expand Messages
  • Bob Hiestand
    ... While, again, that functionality would suit my plugin s need, I can t help but feel that that s a pretty inefficient way of checking compared to: let
    Message 1 of 13 , Apr 26, 2007
      On 4/26/07, Nikolai Weibull <now@...> wrote:
      > > > 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.)

      While, again, that functionality would suit my plugin's need, I can't
      help but feel that that's a pretty inefficient way of checking
      compared to:

      let cd_cmd = haslocaldir() ? 'lcd' : 'cd'

      In the larger picture, I don't know why you'd want to distinguish
      between local and global directory normally, other than to determine
      the correct ':l?cd' to use, so I don't think that specifying a
      parameter to getcwd() to be very useful. haslocaldir() has the
      advantage of (imo) being simpler.

      Thank you,

    Your message has been successfully submitted and would be delivered to recipients shortly.