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

[patch] modelines are ignored when a file is reloaded after W11

Expand Messages
  • Ken Takata
    Hi, I checked on 7.3.785 with the following steps: 1. $ vim -u NONE -N ... At this moment, ts is 8 because of the modelines in os_win32.c. 2. Edit os_win32.c
    Message 1 of 2 , Jan 26, 2013
    • 0 Attachment
      Hi,

      I checked on 7.3.785 with the following steps:

      1.
      $ vim -u NONE -N
      :autocmd BufRead *.c setlocal ts=4
      :e os_win32.c (This is a source file of Vim.)

      At this moment, 'ts' is 8 because of the modelines in os_win32.c.

      2.
      Edit os_win32.c by some another application, then do :checktime.
      The following message (W11) will be shown:

      W11: Warning: File "os_win32.c" has changed since editing started
      See ":help W11" for more info.
      [O]K, (L)oad File:

      Select L, then 'ts' becomes 4 because of the autocmd. The modelines
      seem to be ignored.

      Following patch fixes this:

      --- a/src/fileio.c
      +++ b/src/fileio.c
      @@ -7073,6 +7073,7 @@
      {
      /* Reload the buffer. */
      buf_reload(buf, orig_mode);
      + do_modelines(0);
      #ifdef FEAT_PERSISTENT_UNDO
      if (buf->b_p_udf && buf->b_ffname != NULL)
      {


      Actually buf_reload() is also called from spell_add_word() in spell.c,
      but I'm not sure that do_modelines() is needed in spell_add_word().

      Thanks,
      Ken Takata

      --
      --
      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
    • Bram Moolenaar
      ... Thanks. I ll verify this is the best solution. -- Witches prefer brooms: vacuum-cleaners need extension cords! /// Bram Moolenaar -- Bram@Moolenaar.net --
      Message 2 of 2 , Jan 27, 2013
      • 0 Attachment
        Ken Takata wrote:

        > I checked on 7.3.785 with the following steps:
        >
        > 1.
        > $ vim -u NONE -N
        > :autocmd BufRead *.c setlocal ts=4
        > :e os_win32.c (This is a source file of Vim.)
        >
        > At this moment, 'ts' is 8 because of the modelines in os_win32.c.
        >
        > 2.
        > Edit os_win32.c by some another application, then do :checktime.
        > The following message (W11) will be shown:
        >
        > W11: Warning: File "os_win32.c" has changed since editing started
        > See ":help W11" for more info.
        > [O]K, (L)oad File:
        >
        > Select L, then 'ts' becomes 4 because of the autocmd. The modelines
        > seem to be ignored.
        >
        > Following patch fixes this:
        >
        > --- a/src/fileio.c
        > +++ b/src/fileio.c
        > @@ -7073,6 +7073,7 @@
        > {
        > /* Reload the buffer. */
        > buf_reload(buf, orig_mode);
        > + do_modelines(0);
        > #ifdef FEAT_PERSISTENT_UNDO
        > if (buf->b_p_udf && buf->b_ffname != NULL)
        > {
        >
        >
        > Actually buf_reload() is also called from spell_add_word() in spell.c,
        > but I'm not sure that do_modelines() is needed in spell_add_word().

        Thanks. I'll verify this is the best solution.

        --
        Witches prefer brooms: vacuum-cleaners need extension cords!

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        --
        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
      Your message has been successfully submitted and would be delivered to recipients shortly.