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

68819Re: expand('%:h:h')

Expand Messages
  • Ingo Karkat
    Mar 23, 2013
    • 0 Attachment
      On 23-Mar-13 17:26:13 +0100, Bram Moolenaar wrote:

      > Christian Brabandt wrote:
      >
      >> On Sa, 23 Mär 2013, Marcin Szamotulski wrote:
      >>
      >>> Dear Vim_Dev,
      >>>
      >>> If one is in the directory of the current file '%:h:h' expands to '.',
      >>> while it should expand tas '%:p:h:h' does. This is probably is not very
      >>> useful case since using '../' is much simpler, though it might be used
      >>> in a plugin (I've never been hit by this though). Expansion of '%:h:h'
      >>> works fine when the current directory is not where the current file is.
      >>>
      >>> Another, similar issue is when the current file is:
      >>> /home/user/directory/file.txt
      >>> and the current directory is
      >>> /home/user
      >>>
      >>> Then both '%:h:h' and '%:h:h:h' expand to '.'.
      >>
      >> I think this patch fixes it. It does so, by noticing, whether *fnamep
      >> has been set to '.' and if so and we are still trying to resolve one
      >> level up, will resolve '.' to an absolute path.
      >
      > I don't really like this. If one wants to go above the current
      > directory you can use ":p".
      > What problem are we fixing here?

      I would prefer Christian's changed behavior. As it stands now, you have to
      always use :p:h:h to avoid that the upwards move stops at ".". If you forget
      about this corner case, it's likely a bug; I can't think of using this behavior
      deliberately.

      > If it's not there then turning the path into an absolute path is,
      > well, unexpected.

      Can't we change the patch so that it turns into the relative upwards move ".."
      (then "../..", etc.)?! This way, it stays relative, and one has to use :p to get
      absolute paths.

      -- regards, ingo

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 8 messages in this topic