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

Re: nowrap lost in session.

Expand Messages
  • Bram Moolenaar
    ... You disable storing options in the session file. Thus the wrap option value won t come from the session file. ... The session file has a very particular
    Message 1 of 6 , Sep 2, 2004
    • 0 Attachment
      Robert Webb wrote:

      > I think I have found a minor bug when using vim sessions and modelines
      > together. I have a modeline to set nowrap, but only one of the two
      > windows on the file make use of them. Example is attached. Contains
      > a folder with two test files and a session file (.vse).
      >
      > To reproduce:
      > =============
      >
      > 1. I am using gvim on Win2000. A _vimrc with this seems sufficient:
      >
      > set nocompatible
      > set sessionoptions+=winpos
      > set sessionoptions+=resize
      > set sessionoptions-=options

      You disable storing options in the session file. Thus the 'wrap' option
      value won't come from the session file.

      > Seems to me that when the file is first read, it's modelines should be
      > executed, then they should be inherited when other windows on the same
      > file are created. For some reason this inheritance doesn't happen.

      The session file has a very particular order for restoring the windows,
      because it has to take care of size and several other things. It's not
      strange that when you don't restore option values, they will not be
      restored properly. Nevertheless, the "edit file" commands should use
      the modeline in the file.

      --
      The software said it requires Windows 95 or better, so I installed Linux.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
    • Robert Webb
      ... Correct, I don t want all options saved. I like a clean slate in that way. That is precisely why I would expect the wrap setting to come from the
      Message 2 of 6 , Sep 3, 2004
      • 0 Attachment
        Bram replied:

        > Robert Webb wrote:
        >
        > > I think I have found a minor bug when using vim sessions and modelines
        > > together. I have a modeline to set nowrap, but only one of the two
        > > windows on the file make use of them. Example is attached. Contains
        > > a folder with two test files and a session file (.vse).
        > >
        > > To reproduce:
        > > =============
        > >
        > > 1. I am using gvim on Win2000. A _vimrc with this seems sufficient:
        > >
        > > set nocompatible
        > > set sessionoptions+=winpos
        > > set sessionoptions+=resize
        > > set sessionoptions-=options
        >
        > You disable storing options in the session file. Thus the 'wrap' option
        > value won't come from the session file.

        Correct, I don't want all options saved. I like a clean slate in that
        way. That is precisely why I would expect the wrap setting to come
        from the modeline. First it might be set in _vimrc, then it might be
        set in the modelines. The file has just been loaded afterall.

        > > Seems to me that when the file is first read, it's modelines should be
        > > executed, then they should be inherited when other windows on the same
        > > file are created. For some reason this inheritance doesn't happen.
        >
        > The session file has a very particular order for restoring the windows,
        > because it has to take care of size and several other things. It's not
        > strange that when you don't restore option values, they will not be
        > restored properly. Nevertheless, the "edit file" commands should use
        > the modeline in the file.

        Right. I didn't expect it to restore options from before, I expected
        it to set them from the modelines.

        I expect the first time the file is loaded, the modelines would be
        used. The other windows on that file should inherit that setting.

        Not sure if I pointed it out, but the first window does have the right
        setting, it's only the second window on the same file that doesn't.

        Rob.

        --

        Robert Webb <RobertW@...>,
        Want to make polyhedra?
        <http://www.software3d.com/Stella.html>
      • Bram Moolenaar
        ... It appears this has nothing to do with session files. I think you can ... CTRL-W CTRL-W ... In the second window the modelines are not read, because the
        Message 3 of 6 , Sep 3, 2004
        • 0 Attachment
          Robert Webb wrote:

          > > The session file has a very particular order for restoring the windows,
          > > because it has to take care of size and several other things. It's not
          > > strange that when you don't restore option values, they will not be
          > > restored properly. Nevertheless, the "edit file" commands should use
          > > the modeline in the file.
          >
          > Right. I didn't expect it to restore options from before, I expected
          > it to set them from the modelines.
          >
          > I expect the first time the file is loaded, the modelines would be
          > used. The other windows on that file should inherit that setting.
          >
          > Not sure if I pointed it out, but the first window does have the right
          > setting, it's only the second window on the same file that doesn't.

          It appears this has nothing to do with session files. I think you can
          reproduce it with:

          :set wrap
          :split
          :edit file-with-nowrap-in-modeline
          CTRL-W CTRL-W
          :edit file-with-nowrap-in-modeline

          In the second window the modelines are not read, because the buffer is
          already loaded. That's OK for buffer-local options, but window-local
          options are not set then.

          I'll see if the modeline can be read when displaying an already loaded
          buffer in a window, without causing unwanted side effects.

          --
          DINGO: And after the spanking ... the oral sex.
          GALAHAD: Oh, dear! Well, I...
          GIRLS: The oral sex ... The oral sex.
          GALAHAD: Well, I suppose I could stay a BIT longer.
          "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
          \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
        • Robert Webb
          ... Maybe another solution would be to inherit window and buffer options from another existing window/buffer if one exists for the same file, as if it had been
          Message 4 of 6 , Sep 12, 2004
          • 0 Attachment
            Bram wrote:

            > Robert Webb wrote:
            >
            > > > The session file has a very particular order for restoring the
            > > > windows, because it has to take care of size and several other
            > > > things. It's not strange that when you don't restore option
            > > > values, they will not be restored properly. Nevertheless, the
            > > > "edit file" commands should use the modeline in the file.
            > >
            > > Right. I didn't expect it to restore options from before, I
            > > expected it to set them from the modelines.
            > >
            > > I expect the first time the file is loaded, the modelines would be
            > > used. The other windows on that file should inherit that setting.
            > >
            > > Not sure if I pointed it out, but the first window does have the
            > > right setting, it's only the second window on the same file that
            > > doesn't.
            >
            > It appears this has nothing to do with session files. I think you
            > can reproduce it with:
            >
            > :set wrap
            > :split
            > :edit file-with-nowrap-in-modeline
            > CTRL-W CTRL-W
            > :edit file-with-nowrap-in-modeline
            >
            > In the second window the modelines are not read, because the buffer
            > is already loaded. That's OK for buffer-local options, but
            > window-local options are not set then.
            >
            > I'll see if the modeline can be read when displaying an already
            > loaded buffer in a window, without causing unwanted side effects.

            Maybe another solution would be to inherit window and buffer options
            from another existing window/buffer if one exists for the same file,
            as if it had been split from that window.

            If you are already viewing a particular file with nowrap in one
            window, chances are you also want to view it with nowrap in any other
            windows. You can then change the setting of course if you really did
            want a different setting.

            Might be a bit strange to read modelines for a file that has already
            been read. With my suggestion, the modelines are only read once, but
            inherited for new windows.

            What do you think? Obviously if there are two windows already open
            then it's ambiguous as to which one to inherit from, but I don't think
            that would matter much, just use the first one.

            Rob.

            --

            Robert Webb <RobertW@...>,
            Want to make polyhedra?
            <http://www.software3d.com/Stella.html>
          • Bram Moolenaar
            ... It s possible, but it conflicts with options you may have already set in the window. For example, if number is set you might want to keep it, instead of
            Message 5 of 6 , Sep 13, 2004
            • 0 Attachment
              Robert Webb wrote:

              > > It appears this has nothing to do with session files. I think you
              > > can reproduce it with:
              > >
              > > :set wrap
              > > :split
              > > :edit file-with-nowrap-in-modeline
              > > CTRL-W CTRL-W
              > > :edit file-with-nowrap-in-modeline
              > >
              > > In the second window the modelines are not read, because the buffer
              > > is already loaded. That's OK for buffer-local options, but
              > > window-local options are not set then.
              > >
              > > I'll see if the modeline can be read when displaying an already
              > > loaded buffer in a window, without causing unwanted side effects.
              >
              > Maybe another solution would be to inherit window and buffer options
              > from another existing window/buffer if one exists for the same file,
              > as if it had been split from that window.

              It's possible, but it conflicts with options you may have already set in
              the window. For example, if 'number' is set you might want to keep it,
              instead of using the value from another window that is displaying the
              buffer.

              The modelines overrule option values, thus using the modelines to set
              window-local options should be OK. But options from another window
              should not overrule options of the current window. Perhaps if they were
              not explicitly set, but that becomes rather unpredictable.

              > Might be a bit strange to read modelines for a file that has already
              > been read. With my suggestion, the modelines are only read once, but
              > inherited for new windows.

              I already implemented the idea to only use window-local options from the
              modeline, and it appears to work well. It looks logical to me that when
              you show a file in a window it's modelines are used.

              > What do you think? Obviously if there are two windows already open
              > then it's ambiguous as to which one to inherit from, but I don't think
              > that would matter much, just use the first one.

              That would be another reason not to use the options from another window,
              it would be arbitrary what option values you get.

              --
              BRIDGEKEEPER: What is your favorite editor?
              GAWAIN: Emacs ... No, Viiiiiiiiiiimmmmmmm!
              "Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
              \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
            Your message has been successfully submitted and would be delivered to recipients shortly.