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

Any limitation of autocmd when the bufdo is processing ?

Expand Messages
  • winterTTr
    Actually, i meet a problem like below. I tried to update a specific unlisted buffer every time the BufEnter event happens. the Code like below( just an
    Message 1 of 7 , Feb 25, 2010
    • 0 Attachment
      Actually, i meet a problem like below.
      I tried to update a specific "unlisted" buffer every time the BufEnter event happens.

      the Code like below( just an example, not the real code ):
      I am trying to use the "set eventignore+=BufEnter" and "set eventignore-=BufEnter" to prevent the
      process from running recursively.

      --------------------------begin-----------------------------------
      function! TestFunc()
          set eventignore+=BufEnter

          let bufname = bufname("%")
          " move to specific window
          2wincmd w
          " update buffer
          call append( 0 , bufname )
          " move back
          1wincmd w

          set eventignore-=BufEnter
      endfunction

      autocmd BufEnter * call TestFunc()
      --------------------------end--------------------------------------

      Everything is OK until i do the bufdo command. such as "bufdo s/^/1/"
      "E474: Invalid argument: eventignore+=BufEnter" message is shown.

      I can NOT find any information in the documentation showing any limitation during the bufdo command.
      And I hope anyone could give the answer to the following question:
      1. Is there a limitation that you can NOT set the variable "eventignore" during the bufdo process?
      2. If so, is the "eventignore" the only one or are there any other variable that have the same limitation?
      3. Someone told me that the ""set eventignore+=BufEnter" is unnecessary, cause the "bufdo" itself would
          prevent the recursive running ? Is this the truth ?


      If you really want to reproduce the error, i attach the file to do this. Please follow the next step:
      1. source the test.vim
      2. run a bufdo command, such as ""bufdo s/^/1/"
      And , the error would be shown.

      --
      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
    • winterTTr
      ... Anyone can give some idea ? :-) ... -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text you are
      Message 2 of 7 , Feb 28, 2010
      • 0 Attachment
        On Fri, Feb 26, 2010 at 3:41 PM, winterTTr <winterTTr.vim@gmail.com> wrote:
        Actually, i meet a problem like below.
        I tried to update a specific "unlisted" buffer every time the BufEnter event happens.

        the Code like below( just an example, not the real code ):
        I am trying to use the "set eventignore+=BufEnter" and "set eventignore-=BufEnter" to prevent the
        process from running recursively.

        --------------------------begin-----------------------------------
        function! TestFunc()
            set eventignore+=BufEnter

            let bufname = bufname("%")
            " move to specific window
            2wincmd w
            " update buffer
            call append( 0 , bufname )
            " move back
            1wincmd w

            set eventignore-=BufEnter
        endfunction

        autocmd BufEnter * call TestFunc()
        --------------------------end--------------------------------------

        Everything is OK until i do the bufdo command. such as "bufdo s/^/1/"
        "E474: Invalid argument: eventignore+=BufEnter" message is shown.

        I can NOT find any information in the documentation showing any limitation during the bufdo command.
        And I hope anyone could give the answer to the following question:
        1. Is there a limitation that you can NOT set the variable "eventignore" during the bufdo process?
        2. If so, is the "eventignore" the only one or are there any other variable that have the same limitation?
        3. Someone told me that the ""set eventignore+=BufEnter" is unnecessary, cause the "bufdo" itself would
            prevent the recursive running ? Is this the truth ?

        Anyone can give some idea ? :-)
         


        If you really want to reproduce the error, i attach the file to do this. Please follow the next step:
        1. source the test.vim
        2. run a bufdo command, such as ""bufdo s/^/1/"
        And , the error would be shown.

        --
        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
      • Ben Fritz
        ... I can reproduce on the Cream build for Windows, even after commenting out the entire contents of the TestFunc function, leaving in the :set commands. The
        Message 3 of 7 , Mar 1 6:54 AM
        • 0 Attachment
          On Feb 26, 1:41 am, winterTTr <winterTTr....@...> wrote:
          >
          > the Code like below( just an example, not the real code ):
          > I am trying to use the "set eventignore+=BufEnter" and "set
          > eventignore-=BufEnter" to prevent the
          > process from running recursively.
          >
          > --------------------------begin-----------------------------------
          > function! TestFunc()
          >     set eventignore+=BufEnter
          >
          >     let bufname = bufname("%")
          >     " move to specific window
          >     2wincmd w
          >     " update buffer
          >     call append( 0 , bufname )
          >     " move back
          >     1wincmd w
          >
          >     set eventignore-=BufEnter
          > endfunction
          >
          > autocmd BufEnter * call TestFunc()
          > --------------------------end--------------------------------------
          >
          > Everything is OK until i do the bufdo command. such as "bufdo s/^/1/"
          > "E474: Invalid argument: eventignore+=BufEnter" message is shown.
          >
          >

          I can reproduce on the "Cream" build for Windows, even after
          commenting out the entire contents of the TestFunc function, leaving
          in the :set commands. The "bufdo" command I used was 'bufdo echo
          expand("%")'.

          VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 3 2010 15:30:41)
          MS-Windows 32-bit GUI version with OLE support
          Included patches: 1-356
          Compiled by digitectNO@...
          Huge version with GUI. Features included (+) or not (-):
          +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset
          +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist
          +cmdline_info +comments
          +cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs -dnd -
          ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
          +find_in_path
          +float +folding -footer +gettext/dyn -hangul_input +iconv/dyn
          +insert_expand +jumplist +keymap +langmap +libcall +linebreak
          +lispindent +listcmds +localmap
          +menu +mksession +modify_fname +mouse +mouseshape +multi_byte_ime/dyn
          +multi_lang +mzscheme/dyn +netbeans_intg +ole -osfiletype +path_extra
          +perl/dyn
          -postscript +printer +profile +python/dyn +quickfix +reltime
          +rightleft +ruby/dyn +scrollbind +signs +smartindent -sniff
          +startuptime +statusline
          -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white +tcl/
          dyn -tgetent -termresponse +textobjects +title +toolbar +user_commands
          +vertsplit
          +virtualedit +visual +visualextra +viminfo +vreplace +wildignore
          +wildmenu +windows +writebackup -xfontset -xim -xterm_save -xpm_w32

          --
          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
        • Antony Scriven
          ... Me too. It looks to me like ei is being set to ,Syntax which is causing do_set() to fail. Maybe event_name2nr() could do with a if (*start == , )
          Message 4 of 7 , Mar 1 7:54 AM
          • 0 Attachment
            On 1 March 2010 14:54, Ben Fritz <fritzophrenic@...> wrote:

            > On Feb 26, 1:41 am, winterTTr <winterTTr....@...> wrote:
            > >
            > > the Code like below( just an example, not the real code ):
            > > I am trying to use the "set eventignore+=BufEnter" and "set
            > > eventignore-=BufEnter" to prevent the
            > > process from running recursively.
            > >
            > > --------------------------begin-----------------------------------
            > > function! TestFunc()
            > > set eventignore+=BufEnter
            > >
            > > let bufname = bufname("%")
            > > " move to specific window
            > > 2wincmd w
            > > " update buffer
            > > call append( 0 , bufname )
            > > " move back
            > > 1wincmd w
            > >
            > > set eventignore-=BufEnter
            > > endfunction
            > >
            > > autocmd BufEnter * call TestFunc()
            > > --------------------------end--------------------------------------
            > >
            > > Everything is OK until i do the bufdo command. such as "bufdo s/^/1/"
            > > "E474: Invalid argument: eventignore+=BufEnter" message is shown.
            > >
            > >
            >
            > I can reproduce on the "Cream" build for Windows, even
            > after commenting out the entire contents of the TestFunc
            > function, leaving in the :set commands. The "bufdo"
            > command I used was 'bufdo echo
            > expand("%")'.

            Me too. It looks to me like 'ei' is being set to ",Syntax"
            which is causing do_set() to fail. Maybe event_name2nr()
            could do with a "if (*start == ',') ++start;" at the
            beginning. Sorry, I don't have a debug version nor can
            I compile to test this out, so I'm afraid this is a bit of
            a guess. --Antony

            --
            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
          • Antony Scriven
            ... ... on a subsequent :set ei+= . I hope that s clearer. --Antony -- You received this message from the vim_dev maillist. Do not top-post! Type your reply
            Message 5 of 7 , Mar 1 11:23 AM
            • 0 Attachment
              I vaguely wrote:

              > [...]
              >
              > Me too. It looks to me like 'ei' is being set to
              > ",Syntax" which is causing do_set() to fail

              ... on a subsequent ":set ei+=".

              I hope that's clearer. --Antony

              --
              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
              ... This patch should fix it: ... *************** *** 7925,7931 **** new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what))); if (new_ei != NULL) { !
              Message 6 of 7 , Mar 1 12:02 PM
              • 0 Attachment
                Antony Scriven wrote:

                > I vaguely wrote:
                >
                > > [...]
                > >
                > > Me too. It looks to me like 'ei' is being set to
                > > ",Syntax" which is causing do_set() to fail
                >
                > ... on a subsequent ":set ei+=".
                >
                > I hope that's clearer. --Antony

                This patch should fix it:

                *** ../vim-7.2.377/src/fileio.c 2010-01-19 14:59:14.000000000 +0100
                --- src/fileio.c 2010-03-01 21:01:04.000000000 +0100
                ***************
                *** 7925,7931 ****
                new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
                if (new_ei != NULL)
                {
                ! STRCAT(new_ei, what);
                set_string_option_direct((char_u *)"ei", -1, new_ei,
                OPT_FREE, SID_NONE);
                vim_free(new_ei);
                --- 7925,7934 ----
                new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
                if (new_ei != NULL)
                {
                ! if (*what == ',' && *p_ei == NUL)
                ! STRCPY(new_ei, what + 1);
                ! else
                ! STRCAT(new_ei, what);
                set_string_option_direct((char_u *)"ei", -1, new_ei,
                OPT_FREE, SID_NONE);
                vim_free(new_ei);


                --
                TALL KNIGHT OF NI: Ni!
                "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/ \\\
                \\\ 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.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php
              • winterTTr
                ... Thanks Bram and everyone. I will try to compile and use the latest version. ... -- You received this message from the vim_dev maillist. Do not top-post!
                Message 7 of 7 , Mar 1 5:52 PM
                • 0 Attachment
                  On Tue, Mar 2, 2010 at 4:02 AM, Bram Moolenaar <Bram@moolenaar.net> wrote:

                  Antony Scriven wrote:

                  > I vaguely wrote:
                  >
                  >  > [...]
                  >  >
                  >  > Me too. It looks to me like 'ei' is being set to
                  >  > ",Syntax" which is causing do_set() to fail
                  >
                  > ... on a subsequent ":set ei+=".
                  >
                  > I hope that's clearer. --Antony

                  This patch should fix it:

                  *** ../vim-7.2.377/src/fileio.c 2010-01-19 14:59:14.000000000 +0100
                  --- src/fileio.c        2010-03-01 21:01:04.000000000 +0100
                  ***************
                  *** 7925,7931 ****
                         new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
                         if (new_ei != NULL)
                         {
                  !           STRCAT(new_ei, what);
                             set_string_option_direct((char_u *)"ei", -1, new_ei,
                                                                           OPT_FREE, SID_NONE);
                             vim_free(new_ei);
                  --- 7925,7934 ----
                         new_ei = vim_strnsave(p_ei, (int)(STRLEN(p_ei) + STRLEN(what)));
                         if (new_ei != NULL)
                         {
                  !           if (*what == ',' && *p_ei == NUL)
                  !               STRCPY(new_ei, what + 1);
                  !           else
                  !               STRCAT(new_ei, what);
                             set_string_option_direct((char_u *)"ei", -1, new_ei,
                                                                           OPT_FREE, SID_NONE);
                             vim_free(new_ei);

                  Thanks Bram and everyone.
                  I will try to compile and use the latest version.
                   


                  --
                  TALL KNIGHT OF NI: Ni!
                                  "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

                   /// Bram Moolenaar -- Bram@Moolenaar.net -- 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.
                  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 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.