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

MRU does not remember files opened across sessions

Expand Messages
  • Alan Schmitt
    Hi, I just tried the mru script (http://vim.sourceforge.net/script.php?script_id=521), and I noticed that it does not remember the files opened across
    Message 1 of 15 , Jan 2, 2003
    • 0 Attachment
      Hi,

      I just tried the mru script
      (http://vim.sourceforge.net/script.php?script_id=521), and I noticed
      that it does not remember the files opened across sessions. The '!' is
      set for viminfo, so this does not seem to be the problem. I did add a
      let MRU_Max_Entries = 70
      in my .vimrc, but nothing else.

      Has someone made it work ?

      Alan

      --
      The hacker: someone who figured things out and made something cool happen.
    • Yegappan Lakshmanan
      ... Are you running more than one instance of Vim at the same time? In this case, the MRU plugin behaves exactly same as the Vim buffer list. If you have more
      Message 2 of 15 , Jan 2, 2003
      • 0 Attachment
        --- Alan Schmitt <alan.schmitt@...> wrote:
        > Hi,
        >
        > I just tried the mru script
        > (http://vim.sourceforge.net/script.php?script_id=521), and I noticed
        > that it does not remember the files opened across sessions.

        Are you running more than one instance of Vim at the same time?

        In this case, the MRU plugin behaves exactly same as the Vim buffer
        list. If you have more than one instance of Vim running at the same
        time, then the buffers loaded in one instance of Vim will not be
        displayed in the other instances of Vim. Also, when you quit one
        instance of Vim, it will save the buffer list in the viminfo file.
        After this, if you quit another instance of Vim, it will overwrite the
        viminfo file with it's own buffer list. You will end up losing the
        buffer list from the first instance of Vim.

        This applies to the MRU plugin also. The MRU plugin saves the MRU file
        list in a global variable which is stored in the viminfo file. If you
        are running two or more instances of Vim at the same time, when you
        quit one instance of Vim, the MRU plugin will store the MRU file list
        from that instance of Vim in the viminfo file. Now if you quit another
        instance of Vim, the MRU plugin will overwrite the MRU file list from
        the previous instance of Vim.

        One approach to solve this problem is to use the ":rviminfo" command
        to read the viminfo file and get the existing MRU file list from the
        viminfo file and merge the current MRU file list. But this will also
        load other settings (buffer list, register contents, etc) from the
        viminfo file.

        >
        > The '!' is set for viminfo, so this does not seem to be the problem.
        >

        You don't need to add the '!' flag to the 'viminfo' option in the
        .vimrc file. The MRU plugin will automatically add the '!' flag to
        the 'viminfo' option.

        > I did add a let MRU_Max_Entries = 70 in my .vimrc, but nothing else.
        >
        > Has someone made it work ?
        >

        - Yegappan


        __________________________________________________
        Do you Yahoo!?
        Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
        http://mailplus.yahoo.com
      • Alan Schmitt
        ... Usually no. ... Here is my setting: I have one main vim (well, gvim to be precise) in which I do all my editing. Then from time to time I write mail
        Message 3 of 15 , Jan 2, 2003
        • 0 Attachment
          * Yegappan Lakshmanan (yegappan@...) wrote:
          >
          > --- Alan Schmitt <alan.schmitt@...> wrote:
          > > Hi,
          > >
          > > I just tried the mru script
          > > (http://vim.sourceforge.net/script.php?script_id=521), and I noticed
          > > that it does not remember the files opened across sessions.
          >
          > Are you running more than one instance of Vim at the same time?
          >

          Usually no.

          > In this case, the MRU plugin behaves exactly same as the Vim buffer
          > list. If you have more than one instance of Vim running at the same
          > time, then the buffers loaded in one instance of Vim will not be
          > displayed in the other instances of Vim. Also, when you quit one
          > instance of Vim, it will save the buffer list in the viminfo file.
          > After this, if you quit another instance of Vim, it will overwrite the
          > viminfo file with it's own buffer list. You will end up losing the
          > buffer list from the first instance of Vim.
          >
          > This applies to the MRU plugin also. The MRU plugin saves the MRU file
          > list in a global variable which is stored in the viminfo file. If you
          > are running two or more instances of Vim at the same time, when you
          > quit one instance of Vim, the MRU plugin will store the MRU file list
          > from that instance of Vim in the viminfo file. Now if you quit another
          > instance of Vim, the MRU plugin will overwrite the MRU file list from
          > the previous instance of Vim.
          >

          Here is my setting: I have one main "vim" (well, gvim to be precise) in
          which I do all my editing. Then from time to time I write mail using
          mutt, which opens a new gvim for me. As I quit the "mail" vim before the
          "edit" vim, the one that is saved last is the "edit" one, which is fine.
          This does not seem to be the problem since I did the following
          experiment:
          no gvim running
          lauch gvim
          :MRU -> empty list
          :e some file
          :MRU -> some file
          :q
          lauch gvim again
          :MRU -> empty list

          Notice that in this case there never were two gvims open at the same
          time.

          > One approach to solve this problem is to use the ":rviminfo" command
          > to read the viminfo file and get the existing MRU file list from the
          > viminfo file and merge the current MRU file list. But this will also
          > load other settings (buffer list, register contents, etc) from the
          > viminfo file.
          >

          You don't have to use the viminfo for that ... Why not use some text
          file to store this data ?

          So the bottom line is: I can reproduce losing MRU while never running to
          vims at the same time.

          Thanks for your help,

          Alan

          --
          The hacker: someone who figured things out and made something cool happen.
        • Antoine J. Mechelynck
          Alan Schmitt wrote: [...] ... [...] Looks like the appropriate info isn t saved in your viminfo. What is the answer to
          Message 4 of 15 , Jan 2, 2003
          • 0 Attachment
            Alan Schmitt <alan.schmitt@...> wrote:
            [...]
            > This does not seem to be the problem since I did the following
            > experiment:
            > no gvim running
            > lauch gvim
            > > MRU -> empty list
            > > e some file
            > > MRU -> some file
            > > q
            > lauch gvim again
            > > MRU -> empty list
            [...]

            Looks like the appropriate info isn't saved in your viminfo. What is the
            answer to (without quotes) ":verbose set viminfo?" ?

            Tony.
          • Yegappan Lakshmanan
            ... What is the output of the following command? ... It looks like for some reason, the MRU_LIST global variable is not stored and restored from your viminfo
            Message 5 of 15 , Jan 2, 2003
            • 0 Attachment
              --- Alan Schmitt <alan.schmitt@...> wrote:
              >
              > This does not seem to be the problem since I did the following
              > experiment:
              > no gvim running
              > lauch gvim
              > :MRU -> empty list
              > :e some file
              > :MRU -> some file
              > :q
              > lauch gvim again
              > :MRU -> empty list
              >
              > Notice that in this case there never were two gvims open at the same
              > time.

              What is the output of the following command?

              :verbose set viminfo?

              It looks like for some reason, the MRU_LIST global variable is not
              stored and restored from your viminfo file. Do you have a .viminfo
              file?

              >
              > > One approach to solve this problem is to use the ":rviminfo" command
              > > to read the viminfo file and get the existing MRU file list from the
              > > viminfo file and merge the current MRU file list. But this will also
              > > load other settings (buffer list, register contents, etc) from the
              > > viminfo file.
              > >
              >
              > You don't have to use the viminfo for that ... Why not use some text
              > file to store this data ?

              The problem with storing the MRU list in a text file is reading the
              contents back into Vim. Currently Vim doesn't provide a built-in
              function to read the contents of a file into a variable. The only
              way to read a file is to open the file in a window. So from a plugin
              to read the contents of a file, you have to do the following:

              1. Open the file in a window
              2. Read (yank) the contents of the window into a variable
              3. Close the window.

              The drawback with this approach is that the size of other Vim windows
              will be adjusted when the temporary window is closed. Also, the user
              will see a flickering on the screen. So I decided to use a Vim
              global variable stored in the viminfo file to save the MRU list.

              >
              > So the bottom line is: I can reproduce losing MRU while never running to
              > vims at the same time.
              >

              - Yegappan


              __________________________________________________
              Do you Yahoo!?
              Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
              http://mailplus.yahoo.com
            • Alan Schmitt
              ... it is: viminfo=%, 50, 1000,:100,n~/.viminfo,! Last set from /home/schmitta/.vim/plugin/mru.vim which looks right, at first sight ... Alan -- The hacker:
              Message 6 of 15 , Jan 2, 2003
              • 0 Attachment
                * Antoine J. Mechelynck (antoine.mechelynck@...) wrote:
                > Alan Schmitt <alan.schmitt@...> wrote:
                > [...]
                > > This does not seem to be the problem since I did the following
                > > experiment:
                > > no gvim running
                > > lauch gvim
                > > > MRU -> empty list
                > > > e some file
                > > > MRU -> some file
                > > > q
                > > lauch gvim again
                > > > MRU -> empty list
                > [...]
                >
                > Looks like the appropriate info isn't saved in your viminfo. What is the
                > answer to (without quotes) ":verbose set viminfo?" ?

                it is:
                viminfo=%,'50,"1000,:100,n~/.viminfo,!
                Last set from /home/schmitta/.vim/plugin/mru.vim

                which looks right, at first sight ...

                Alan

                --
                The hacker: someone who figured things out and made something cool happen.
              • Yegappan Lakshmanan
                ... In the viminfo option, the n flag must be the last flag. You have to add the ! flag before the n flag. From the Vim documentation for viminfo : n
                Message 7 of 15 , Jan 2, 2003
                • 0 Attachment
                  --- Alan Schmitt <alan.schmitt@...> wrote:
                  >
                  > > Looks like the appropriate info isn't saved in your viminfo. What is the
                  > > answer to (without quotes) ":verbose set viminfo?" ?
                  >
                  > it is:
                  > viminfo=%,'50,"1000,:100,n~/.viminfo,!
                  > Last set from /home/schmitta/.vim/plugin/mru.vim
                  >
                  > which looks right, at first sight ...
                  >

                  In the 'viminfo' option, the 'n' flag must be the last flag. You have
                  to add the '!' flag before the 'n' flag. From the Vim documentation
                  for 'viminfo':

                  n Name of the viminfo file. The name must immediately follow
                  the 'n'. Must be the last one! If the "-i" argument was

                  You can add the '!' flag to the 'viminfo' option using:

                  set viminfo+=!

                  This will add the '!' flag at the proper location. As I mentioned in
                  my previous e-mail, you don't need to add this in your .vimrc file.
                  The MRU plugin will automatically add the '!' flag to the 'viminfo'
                  option.

                  - Yegappan


                  __________________________________________________
                  Do you Yahoo!?
                  Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
                  http://mailplus.yahoo.com
                • Alan Schmitt
                  ... It is: viminfo=%, 50, 1000,:100,n~/.viminfo,! Last set from /home/schmitta/.vim/plugin/mru.vim ... Yes, and there is no MRU_LIST variable in it. OK: I got
                  Message 8 of 15 , Jan 2, 2003
                  • 0 Attachment
                    * Yegappan Lakshmanan (yegappan@...) wrote:
                    > What is the output of the following command?
                    >
                    > :verbose set viminfo?

                    It is:
                    viminfo=%,'50,"1000,:100,n~/.viminfo,!
                    Last set from /home/schmitta/.vim/plugin/mru.vim

                    >
                    > It looks like for some reason, the MRU_LIST global variable is not
                    > stored and restored from your viminfo file. Do you have a .viminfo
                    > file?
                    >

                    Yes, and there is no MRU_LIST variable in it.

                    OK: I got it:

                    schmitta@alan-schm1p:~> ls -al .viminfo*
                    -rw------- 1 schmitta schmitta 12472 Jan 2 09:01 .viminfo
                    -rw------- 1 schmitta schmitta 7119 Jan 2 18:49 .viminfo,!

                    and 09:01 is when I installed the mru plugin ... So somehow there is
                    some quotting going wrong ... when I look at the viminfo variable, it
                    somehow looks like the last ",!" is included in the name ... which means
                    that the ! option is not set (and I've been using this new viminfo since
                    this morning ...).

                    I do not really know how to fix this problem, though ...

                    > The problem with storing the MRU list in a text file is reading the
                    > contents back into Vim. Currently Vim doesn't provide a built-in
                    > function to read the contents of a file into a variable. The only
                    > way to read a file is to open the file in a window. So from a plugin
                    > to read the contents of a file, you have to do the following:
                    >
                    > 1. Open the file in a window
                    > 2. Read (yank) the contents of the window into a variable
                    > 3. Close the window.
                    >
                    > The drawback with this approach is that the size of other Vim windows
                    > will be adjusted when the temporary window is closed. Also, the user
                    > will see a flickering on the screen. So I decided to use a Vim
                    > global variable stored in the viminfo file to save the MRU list.

                    I see. It might be a good addition to vim to load a file in some hidden
                    buffer, then.

                    Alan

                    --
                    The hacker: someone who figured things out and made something cool happen.
                  • Alan Schmitt
                    Our mail crossed ... ... So I should set this option in my .vimrc ? ... or is it automatic, as you seem to be saying ... I have in my .vimrc: set
                    Message 9 of 15 , Jan 2, 2003
                    • 0 Attachment
                      Our mail crossed ...

                      * Yegappan Lakshmanan (yegappan@...) wrote:
                      > In the 'viminfo' option, the 'n' flag must be the last flag. You have
                      > to add the '!' flag before the 'n' flag. From the Vim documentation
                      > for 'viminfo':
                      >
                      > n Name of the viminfo file. The name must immediately follow
                      > the 'n'. Must be the last one! If the "-i" argument was
                      >
                      > You can add the '!' flag to the 'viminfo' option using:
                      >
                      > set viminfo+=!
                      >

                      So I should set this option in my .vimrc ?

                      > This will add the '!' flag at the proper location. As I mentioned in
                      > my previous e-mail, you don't need to add this in your .vimrc file.
                      > The MRU plugin will automatically add the '!' flag to the 'viminfo'
                      > option.

                      or is it automatic, as you seem to be saying ...

                      I have in my .vimrc:
                      set viminfo=%,'50,\"1000,:100,n~/.viminfo

                      so the automatic addition of '!' wrecks everything, am I right ?
                      I can add it manually, but I want to be sure that mru.vim will not add
                      another extra ",!" at the end.

                      Alan

                      --
                      The hacker: someone who figured things out and made something cool happen.
                    • Benji Fisher
                      ... A quick experiment confirms my suspicion: using += appends. If your plugin does ... then I think it should be changed to ... This may be the source of
                      Message 10 of 15 , Jan 2, 2003
                      • 0 Attachment
                        Yegappan Lakshmanan wrote:
                        > You can add the '!' flag to the 'viminfo' option using:
                        >
                        > set viminfo+=!
                        >
                        > This will add the '!' flag at the proper location. As I mentioned in
                        > my previous e-mail, you don't need to add this in your .vimrc file.
                        > The MRU plugin will automatically add the '!' flag to the 'viminfo'
                        > option.

                        A quick experiment confirms my suspicion: using += appends. If
                        your plugin does

                        :set vi+=!

                        then I think it should be changed to

                        :set vi^=!

                        This may be the source of the problem.

                        HTH --Benji Fisher
                      • Yegappan Lakshmanan
                        Hi Benji, ... Yes. Thanks for the suggestion. I will modify the MRU plugin to use ^= instead of += to add the ! flag to the viminfo option. - Yegappan
                        Message 11 of 15 , Jan 2, 2003
                        • 0 Attachment
                          Hi Benji,

                          --- Benji Fisher <benji@...> wrote:
                          > Yegappan Lakshmanan wrote:
                          > > You can add the '!' flag to the 'viminfo' option using:
                          > >
                          > > set viminfo+=!
                          > >
                          > > This will add the '!' flag at the proper location. As I mentioned in
                          > > my previous e-mail, you don't need to add this in your .vimrc file.
                          > > The MRU plugin will automatically add the '!' flag to the 'viminfo'
                          > > option.
                          >
                          > A quick experiment confirms my suspicion: using += appends. If
                          > your plugin does
                          >
                          > :set vi+=!
                          >
                          > then I think it should be changed to
                          >
                          > :set vi^=!
                          >
                          > This may be the source of the problem.

                          Yes. Thanks for the suggestion. I will modify the MRU plugin
                          to use ^= instead of += to add the '!' flag to the 'viminfo' option.

                          - Yegappan

                          __________________________________________________
                          Do you Yahoo!?
                          Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
                          http://mailplus.yahoo.com
                        • Yegappan Lakshmanan
                          ... As mentioned by Benji in another email, the problem is that the MRU plugin uses += to add the ! flag to the viminfo option. This appends the ! flag
                          Message 12 of 15 , Jan 2, 2003
                          • 0 Attachment
                            --- Alan Schmitt <alan.schmitt@...> wrote:
                            >
                            > OK: I got it:
                            >
                            > schmitta@alan-schm1p:~> ls -al .viminfo*
                            > -rw------- 1 schmitta schmitta 12472 Jan 2 09:01 .viminfo
                            > -rw------- 1 schmitta schmitta 7119 Jan 2 18:49 .viminfo,!
                            >
                            > and 09:01 is when I installed the mru plugin ... So somehow there is
                            > some quotting going wrong ... when I look at the viminfo variable, it
                            > somehow looks like the last ",!" is included in the name ... which means
                            > that the ! option is not set (and I've been using this new viminfo since
                            > this morning ...).
                            >
                            > I do not really know how to fix this problem, though ...

                            As mentioned by Benji in another email, the problem is that the MRU
                            plugin uses += to add the '!' flag to the 'viminfo' option. This appends
                            the '!' flag to the end of the 'viminfo' option, leading to the above
                            filename and the problem. I will change this to use ^= to add the '!'
                            flag in the next version of the MRU plugin.

                            - Yegappan


                            __________________________________________________
                            Do you Yahoo!?
                            Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
                            http://mailplus.yahoo.com
                          • Yegappan Lakshmanan
                            ... Yes. ... If you add the ! flag to the viminfo option in the .vimrc file, it will fix this problem. When the MRU plugin adds the ! flag to the
                            Message 13 of 15 , Jan 2, 2003
                            • 0 Attachment
                              --- Alan Schmitt <alan.schmitt@...> wrote:
                              >
                              > So I should set this option in my .vimrc ?
                              >
                              > > This will add the '!' flag at the proper location. As I mentioned in
                              > > my previous e-mail, you don't need to add this in your .vimrc file.
                              > > The MRU plugin will automatically add the '!' flag to the 'viminfo'
                              > > option.
                              >
                              > or is it automatic, as you seem to be saying ...
                              >
                              > I have in my .vimrc:
                              > set viminfo=%,'50,\"1000,:100,n~/.viminfo
                              >
                              > so the automatic addition of '!' wrecks everything, am I right ?

                              Yes.

                              > I can add it manually, but I want to be sure that mru.vim will not add
                              > another extra ",!" at the end.

                              If you add the '!' flag to the 'viminfo' option in the .vimrc file,
                              it will fix this problem. When the MRU plugin adds the '!' flag to
                              the 'viminfo' option, Vim will not add it as the flag is already
                              present in the option.

                              - Yegappan


                              __________________________________________________
                              Do you Yahoo!?
                              Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
                              http://mailplus.yahoo.com
                            • Yegappan Lakshmanan
                              Hi Alan, ... I have uploaded a new version (1.1) of the MRU plugin to the Vim online website that fixes this problem. - Yegappan
                              Message 14 of 15 , Jan 2, 2003
                              • 0 Attachment
                                Hi Alan,

                                --- Alan Schmitt <alan.schmitt@...> wrote:
                                >
                                > so the automatic addition of '!' wrecks everything, am I right ?
                                > I can add it manually, but I want to be sure that mru.vim will not add
                                > another extra ",!" at the end.
                                >

                                I have uploaded a new version (1.1) of the MRU plugin to the
                                Vim online website that fixes this problem.

                                - Yegappan


                                __________________________________________________
                                Do you Yahoo!?
                                Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
                                http://mailplus.yahoo.com
                              • Alan Schmitt
                                ... It works, thanks a lot for your help. Alan -- The hacker: someone who figured things out and made something cool happen.
                                Message 15 of 15 , Jan 3, 2003
                                • 0 Attachment
                                  * Yegappan Lakshmanan (yegappan@...) wrote:
                                  > Hi Alan,
                                  >
                                  > --- Alan Schmitt <alan.schmitt@...> wrote:
                                  > >
                                  > > so the automatic addition of '!' wrecks everything, am I right ?
                                  > > I can add it manually, but I want to be sure that mru.vim will not add
                                  > > another extra ",!" at the end.
                                  > >
                                  >
                                  > I have uploaded a new version (1.1) of the MRU plugin to the
                                  > Vim online website that fixes this problem.

                                  It works, thanks a lot for your help.

                                  Alan

                                  --
                                  The hacker: someone who figured things out and made something cool happen.
                                Your message has been successfully submitted and would be delivered to recipients shortly.