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

:mksession minor problem fix

Expand Messages
  • Lech Lorens
    ... This is achieved by adding the following lines to the session file: let s:sx = expand( :p:r ). x.vim if file_readable(s:sx) exe source . s:sx
    Message 1 of 2 , Dec 4, 2008
      :help :mksession states:
      > 10. If a file exists with the same name as the Session file, but ending in
      > "x.vim" (for eXtra), executes that as well. You can use *x.vim files to
      > specify additional settings and actions associated with a given Session,
      > such as creating menu items in the GUI version.

      This is achieved by adding the following lines to the session file:

      let s:sx = expand("<sfile>:p:r")."x.vim"
      if file_readable(s:sx)
      exe "source " . s:sx
      endif

      However, a problem arises when the path of the session file contains a
      whitespace character. To fix this, the contents of the session file
      should be:

      let s:sx = expand("<sfile>:p:r")."x.vim"
      if file_readable(s:sx)
      exe "source " . fnameescape(s:sx)
      endif

      The following patch makes Vim generate the latter form of the session
      file:

      Index: src/ex_docmd.c
      ===================================================================
      --- src/ex_docmd.c (revision 1289)
      +++ src/ex_docmd.c (working copy)
      @@ -10106,7 +10106,7 @@
      */
      if (put_line(fd, "let s:sx = expand(\"<sfile>:p:r\").\"x.vim\"") == FAIL
      || put_line(fd, "if file_readable(s:sx)") == FAIL
      - || put_line(fd, " exe \"source \" . s:sx") == FAIL
      + || put_line(fd, " exe \"source \" . fnameescape(s:sx)") == FAIL
      || put_line(fd, "endif") == FAIL)
      return FAIL;

      --
      Cheers,
      Lech

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Bram Moolenaar
      ... Good fix, thanks! -- ARTHUR: A scratch? Your arm s off! BLACK KNIGHT: No, it isn t. ARTHUR: Well, what s that then? BLACK KNIGHT: I ve had
      Message 2 of 2 , Dec 5, 2008
        Lech Lorens wrote:

        > :help :mksession states:
        > > 10. If a file exists with the same name as the Session file, but ending in
        > > "x.vim" (for eXtra), executes that as well. You can use *x.vim files to
        > > specify additional settings and actions associated with a given Session,
        > > such as creating menu items in the GUI version.
        >
        > This is achieved by adding the following lines to the session file:
        >
        > let s:sx = expand("<sfile>:p:r")."x.vim"
        > if file_readable(s:sx)
        > exe "source " . s:sx
        > endif
        >
        > However, a problem arises when the path of the session file contains a
        > whitespace character. To fix this, the contents of the session file
        > should be:
        >
        > let s:sx = expand("<sfile>:p:r")."x.vim"
        > if file_readable(s:sx)
        > exe "source " . fnameescape(s:sx)
        > endif
        >
        > The following patch makes Vim generate the latter form of the session
        > file:
        >
        > Index: src/ex_docmd.c
        > ===================================================================
        > --- src/ex_docmd.c (revision 1289)
        > +++ src/ex_docmd.c (working copy)
        > @@ -10106,7 +10106,7 @@
        > */
        > if (put_line(fd, "let s:sx = expand(\"<sfile>:p:r\").\"x.vim\"") == FAIL
        > || put_line(fd, "if file_readable(s:sx)") == FAIL
        > - || put_line(fd, " exe \"source \" . s:sx") == FAIL
        > + || put_line(fd, " exe \"source \" . fnameescape(s:sx)") == FAIL
        > || put_line(fd, "endif") == FAIL)
        > return FAIL;

        Good fix, thanks!

        --
        ARTHUR: A scratch? Your arm's off!
        BLACK KNIGHT: No, it isn't.
        ARTHUR: Well, what's that then?
        BLACK KNIGHT: I've had worse.
        The Quest for the Holy Grail (Monty Python)

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      Your message has been successfully submitted and would be delivered to recipients shortly.