Antony Scriven wrote:

> On Jul 16, 3:58 pm, Antony Scriven <[EMAIL PROTECTED]> wrote:
> 
>  > On Jul 16, 3:45 pm, Antony Scriven <[EMAIL PROTECTED]> wrote:
>  >
>  > > Hi, the stock download for Vim 7.1 on Windows hangs when
>  > > I do the following.
>  > >
>  > > vim -u NONE
>  > > Qg/^/vi
>  > > ^C
>  >
>  > Sorry, I should have added that it does that for various
>  > regexps with varying buffer content; that was just the
>  > smallest reproducible example. --Antony
> 
> It's easy to be lazy when you are on Windows. Right, I've
> downloaded some stuff, and, I swear, the bulk of the time to
> make this patch was waiting for configure to run in Cygwin.
> Painful! The below assumes that you want a ^C when in normal
> mode after an ex-mode g/RE/vi to cancel everything, and not
> jump to the next pattern (I do). --Antony

I was wondering what the original Vi does in this situation.  I
discovered that when using CTRL-C once it just beeps, thus you stay in
Normal mode (Visual mode in Vi terms).  But when pressing CTRL-C twice
in a row Vi aborts the ":g" command.  I think that's a real good idea,
thus I made a patch to have Vim work this way.  Please try it out and
verify it doesn't break anything.


*** ../vim-7.1.056/src/main.c   Tue Jun 19 20:30:46 2007
--- src/main.c  Tue Aug  7 22:40:35 2007
***************
*** 954,960 ****
      int               cmdwin;     /* TRUE when working in the command-line 
window */
      int               noexmode;   /* TRUE when return on entering Ex mode */
  {
!     oparg_T   oa;     /* operator arguments */
  
  #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
      /* Setup to catch a terminating error from the X server.  Just ignore
--- 954,961 ----
      int               cmdwin;     /* TRUE when working in the command-line 
window */
      int               noexmode;   /* TRUE when return on entering Ex mode */
  {
!     oparg_T   oa;                             /* operator arguments */
!     int               previous_got_int = FALSE;       /* "got_int" was TRUE */
  
  #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
      /* Setup to catch a terminating error from the X server.  Just ignore
***************
*** 1015,1026 ****
                need_fileinfo = FALSE;
            }
        }
!       if (got_int && !global_busy)
        {
!           if (!quit_more)
!               (void)vgetc();          /* flush all buffers */
!           got_int = FALSE;
        }
        if (!exmode_active)
            msg_scroll = FALSE;
        quit_more = FALSE;
--- 1016,1047 ----
                need_fileinfo = FALSE;
            }
        }
! 
!       /* Reset "got_int" now that we got back to the main loop.  Except when
!        * inside a ":g/pat/cmd" command, then the "got_int" needs to abort
!        * the ":g" command.
!        * For ":g/pat/vi" we reset "got_int" when used once.  When used
!        * a second time we go back to Ex mode and abort the ":g" command. */
!       if (got_int)
        {
!           if (noexmode && global_busy && !exmode_active && previous_got_int)
!           {
!               /* Typed two CTRL-C in a row: go back to ex mode as if "Q" was
!                * used and keep "got_int" set, so that it aborts ":g". */
!               exmode_active = EXMODE_NORMAL;
!               State = NORMAL;
!           }
!           else if (!global_busy || !exmode_active)
!           {
!               if (!quit_more)
!                   (void)vgetc();              /* flush all buffers */
!               got_int = FALSE;
!           }
!           previous_got_int = TRUE;
        }
+       else
+           previous_got_int = FALSE;
+ 
        if (!exmode_active)
            msg_scroll = FALSE;
        quit_more = FALSE;

-- 
>From "know your smileys":
 :.-(   Crying

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- 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
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui