changeset 661:e93a99ef31d0

updated for version 7.0195
author vimboss
date Thu, 09 Feb 2006 23:53:20 +0000
parents 13296f8d1d3d
children 1a85f952cdfe
files runtime/doc/autocmd.txt src/edit.c src/fileio.c src/globals.h src/mbyte.c src/proto/fileio.pro src/quickfix.c src/version.h
diffstat 8 files changed, 147 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1,4 +1,4 @@
-*autocmd.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 01
+*autocmd.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 09
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -278,6 +278,9 @@ Name			triggered by ~
 |FocusGained|		Vim got input focus
 |FocusLost|		Vim lost input focus
 |CursorHold|		the user doesn't press a key for a while
+|CursorHoldI|		the user doesn't press a key for a while in Insert mode
+|CursorMoved|		the cursor was moved in Normal mode
+|CursorMovedI|		the cursor was moved in Insert mode
 
 |WinEnter|		after entering another window
 |WinLeave|		before leaving a window
@@ -440,6 +443,7 @@ CmdwinLeave			Before leaving the command
 				|cmdwin-char|
 							*ColorScheme*
 ColorScheme			After loading a color scheme. |:colorscheme|
+
 							*CursorHold*
 CursorHold			When the user doesn't press a key for the time
 				specified with 'updatetime'.  Not re-triggered
@@ -460,6 +464,18 @@ CursorHold			When the user doesn't press
 					:let &ro = &ro
 <				{only on Amiga, Unix, Win32, MSDOS and all GUI
 				versions}
+							*CursorHoldI*
+CursorHoldI			Just like CursorHold, but in Insert mode.
+
+							*CursorMoved*
+CursorMoved			After the cursor was moved in Normal mode.
+				Not triggered when there is typeahead or when
+				an operator is pending.
+				Careful: Don't do anything that the user does
+				not expect or that is slow.
+							*CursorMovedI*
+CursorMovedI			After the cursor was moved in Insert mode.
+				Otherwise the same as CursorMoved.
 							*EncodingChanged*
 EncodingChanged			Fires off after the 'encoding' option has been
 				changed.  Useful to set up fonts, for example.
--- a/src/edit.c
+++ b/src/edit.c
@@ -149,7 +149,7 @@ static int  quote_meta __ARGS((char_u *d
 #define BACKSPACE_WORD_NOT_SPACE    3
 #define BACKSPACE_LINE		    4
 
-static void ins_redraw __ARGS((void));
+static void ins_redraw __ARGS((int ready));
 static void ins_ctrl_v __ARGS((void));
 static void undisplay_dollar __ARGS((void));
 static void insert_special __ARGS((int, int, int));
@@ -650,7 +650,7 @@ edit(cmdchar, startln, count)
 	 * Redraw the display when no characters are waiting.
 	 * Also shows mode, ruler and positions cursor.
 	 */
-	ins_redraw();
+	ins_redraw(TRUE);
 
 #ifdef FEAT_SCROLLBIND
 	if (curwin->w_p_scb)
@@ -732,7 +732,7 @@ edit(cmdchar, startln, count)
 	if (c == Ctrl_BSL)
 	{
 	    /* may need to redraw when no more chars available now */
-	    ins_redraw();
+	    ins_redraw(FALSE);
 	    ++no_mapping;
 	    ++allow_keys;
 	    c = safe_vgetc();
@@ -1038,6 +1038,13 @@ doESCkey:
 	case K_IGNORE:	/* Something mapped to nothing */
 	    break;
 
+#ifdef FEAT_AUTOCMD
+	case K_CURSORHOLD:	/* Didn't type something for a while. */
+	    apply_autocmds(EVENT_CURSORHOLDI, NULL, NULL, FALSE, curbuf);
+	    did_cursorhold = TRUE;
+	    break;
+#endif
+
 #ifdef FEAT_GUI_W32
 	    /* On Win32 ignore <M-F4>, we get it when closing the window was
 	     * cancelled. */
@@ -1345,11 +1352,22 @@ force_cindent:
  * Only redraw when there are no characters available.  This speeds up
  * inserting sequences of characters (e.g., for CTRL-R).
  */
+/*ARGSUSED*/
     static void
-ins_redraw()
+ins_redraw(ready)
+    int		ready;	    /* not busy with something */
 {
     if (!char_avail())
     {
+#ifdef FEAT_AUTOCMD
+	    /* Trigger CursorMoved if the cursor moved. */
+	if (ready && has_cursormovedI()
+			     && !equalpos(last_cursormoved, curwin->w_cursor))
+	{
+	    apply_autocmds(EVENT_CURSORMOVEDI, NULL, NULL, FALSE, curbuf);
+	    last_cursormoved = curwin->w_cursor;
+	}
+#endif
 	if (must_redraw)
 	    update_screen(0);
 	else if (clear_cmdline || redraw_cmdline)
@@ -1369,7 +1387,7 @@ ins_ctrl_v()
     int		c;
 
     /* may need to redraw when no more chars available now */
-    ins_redraw();
+    ins_redraw(FALSE);
 
     if (redrawing() && !char_avail())
 	edit_putchar('^', TRUE);
@@ -6652,7 +6670,7 @@ ins_reg()
     if (redrawing() && !char_avail())
     {
 	/* may need to redraw when no more chars available now */
-	ins_redraw();
+	ins_redraw(FALSE);
 
 	edit_putchar('"', TRUE);
 #ifdef FEAT_CMDL_INFO
@@ -8324,7 +8342,7 @@ ins_digraph()
     if (redrawing() && !char_avail())
     {
 	/* may need to redraw when no more chars available now */
-	ins_redraw();
+	ins_redraw(FALSE);
 
 	edit_putchar('?', TRUE);
 #ifdef FEAT_CMDL_INFO
@@ -8356,14 +8374,14 @@ ins_digraph()
 	if (redrawing() && !char_avail())
 	{
 	    /* may need to redraw when no more chars available now */
-	    ins_redraw();
+	    ins_redraw(FALSE);
 
 	    if (char2cells(c) == 1)
 	    {
 		/* first remove the '?', otherwise it's restored when typing
 		 * an ESC next */
 		edit_unputchar();
-		ins_redraw();
+		ins_redraw(FALSE);
 		edit_putchar(c, TRUE);
 	    }
 #ifdef FEAT_CMDL_INFO
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -65,7 +65,7 @@ static void msg_add_eol __ARGS((void));
 static int check_mtime __ARGS((buf_T *buf, struct stat *s));
 static int time_differs __ARGS((long t1, long t2));
 #ifdef FEAT_AUTOCMD
-static int apply_autocmds_exarg __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap));
+static int apply_autocmds_exarg __ARGS((event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap));
 #endif
 
 #if defined(FEAT_CRYPT) || defined(FEAT_MBYTE)
@@ -6894,7 +6894,7 @@ typedef struct AutoPat
 static struct event_name
 {
     char	*name;	/* event name */
-    EVENT_T	event;	/* event number */
+    event_T	event;	/* event number */
 } event_names[] =
 {
     {"BufAdd",		EVENT_BUFADD},
@@ -6922,9 +6922,12 @@ static struct event_name
     {"CmdwinEnter",	EVENT_CMDWINENTER},
     {"CmdwinLeave",	EVENT_CMDWINLEAVE},
     {"ColorScheme",	EVENT_COLORSCHEME},
+    {"CursorHold",	EVENT_CURSORHOLD},
+    {"CursorHoldI",	EVENT_CURSORHOLDI},
+    {"CursorMoved",	EVENT_CURSORMOVED},
+    {"CursorMovedI",	EVENT_CURSORMOVEDI},
     {"EncodingChanged",	EVENT_ENCODINGCHANGED},
     {"FileEncoding",	EVENT_ENCODINGCHANGED},
-    {"CursorHold",	EVENT_CURSORHOLD},
     {"FileAppendPost",	EVENT_FILEAPPENDPOST},
     {"FileAppendPre",	EVENT_FILEAPPENDPRE},
     {"FileAppendCmd",	EVENT_FILEAPPENDCMD},
@@ -6966,7 +6969,7 @@ static struct event_name
     {"VimLeavePre",	EVENT_VIMLEAVEPRE},
     {"WinEnter",	EVENT_WINENTER},
     {"WinLeave",	EVENT_WINLEAVE},
-    {NULL,		(EVENT_T)0}
+    {NULL,		(event_T)0}
 };
 
 static AutoPat *first_autopat[NUM_EVENTS] =
@@ -6990,7 +6993,7 @@ typedef struct AutoPatCmd
     char_u	*fname;		/* fname to match with */
     char_u	*sfname;	/* sfname to match with */
     char_u	*tail;		/* tail of fname */
-    EVENT_T	event;		/* current event */
+    event_T	event;		/* current event */
     int		arg_bufnr;	/* initially equal to <abuf>, set to zero when
 				   buf is deleted */
     struct AutoPatCmd   *next;	/* chain of active apc-s for auto-invalidation*/
@@ -7014,25 +7017,25 @@ static int current_augroup = AUGROUP_DEF
 
 static int au_need_clean = FALSE;   /* need to delete marked patterns */
 
-static void show_autocmd __ARGS((AutoPat *ap, EVENT_T event));
+static void show_autocmd __ARGS((AutoPat *ap, event_T event));
 static void au_remove_pat __ARGS((AutoPat *ap));
 static void au_remove_cmds __ARGS((AutoPat *ap));
 static void au_cleanup __ARGS((void));
 static int au_new_group __ARGS((char_u *name));
 static void au_del_group __ARGS((char_u *name));
 static int au_find_group __ARGS((char_u *name));
-static EVENT_T event_name2nr __ARGS((char_u *start, char_u **end));
-static char_u *event_nr2name __ARGS((EVENT_T event));
+static event_T event_name2nr __ARGS((char_u *start, char_u **end));
+static char_u *event_nr2name __ARGS((event_T event));
 static char_u *find_end_event __ARGS((char_u *arg, int have_group));
-static int event_ignored __ARGS((EVENT_T event));
+static int event_ignored __ARGS((event_T event));
 static int au_get_grouparg __ARGS((char_u **argp));
-static int do_autocmd_event __ARGS((EVENT_T event, char_u *pat, int nested, char_u *cmd, int forceit, int group));
+static int do_autocmd_event __ARGS((event_T event, char_u *pat, int nested, char_u *cmd, int forceit, int group));
 static char_u *getnextac __ARGS((int c, void *cookie, int indent));
-static int apply_autocmds_group __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, int group, buf_T *buf, exarg_T *eap));
+static int apply_autocmds_group __ARGS((event_T event, char_u *fname, char_u *fname_io, int force, int group, buf_T *buf, exarg_T *eap));
 static void auto_next_pat __ARGS((AutoPatCmd *apc, int stop_at_last));
 
 
-static EVENT_T	last_event;
+static event_T	last_event;
 static int	last_group;
 
 /*
@@ -7041,7 +7044,7 @@ static int	last_group;
     static void
 show_autocmd(ap, event)
     AutoPat	*ap;
-    EVENT_T	event;
+    event_T	event;
 {
     AutoCmd *ac;
 
@@ -7140,14 +7143,14 @@ au_cleanup()
 {
     AutoPat	*ap, **prev_ap;
     AutoCmd	*ac, **prev_ac;
-    EVENT_T	event;
+    event_T	event;
 
     if (autocmd_busy || !au_need_clean)
 	return;
 
     /* loop over all events */
-    for (event = (EVENT_T)0; (int)event < (int)NUM_EVENTS;
-					    event = (EVENT_T)((int)event + 1))
+    for (event = (event_T)0; (int)event < (int)NUM_EVENTS;
+					    event = (event_T)((int)event + 1))
     {
 	/* loop over all autocommand patterns */
 	prev_ap = &(first_autopat[(int)event]);
@@ -7193,7 +7196,7 @@ aubuflocal_remove(buf)
     buf_T	*buf;
 {
     AutoPat	*ap;
-    EVENT_T	event;
+    event_T	event;
     AutoPatCmd	*apc;
 
     /* invalidate currently executing autocommands */
@@ -7202,8 +7205,8 @@ aubuflocal_remove(buf)
 	    apc->arg_bufnr = 0;
 
     /* invalidate buflocals looping through events */
-    for (event = (EVENT_T)0; (int)event < (int)NUM_EVENTS;
-					    event = (EVENT_T)((int)event + 1))
+    for (event = (event_T)0; (int)event < (int)NUM_EVENTS;
+					    event = (event_T)((int)event + 1))
 	/* loop over all autocommand patterns */
 	for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
 	    if (ap->buflocal_nr == buf->b_fnum)
@@ -7352,7 +7355,7 @@ free_all_autocmds()
  * Return NUM_EVENTS if the event name was not found.
  * Return a pointer to the next event name in "end".
  */
-    static EVENT_T
+    static event_T
 event_name2nr(start, end)
     char_u  *start;
     char_u  **end;
@@ -7383,7 +7386,7 @@ event_name2nr(start, end)
  */
     static char_u *
 event_nr2name(event)
-    EVENT_T	event;
+    event_T	event;
 {
     int	    i;
 
@@ -7435,7 +7438,7 @@ find_end_event(arg, have_group)
  */
     static int
 event_ignored(event)
-    EVENT_T	event;
+    event_T	event;
 {
     char_u	*p = p_ei;
 
@@ -7547,7 +7550,7 @@ do_autocmd(arg, forceit)
     char_u	*pat;
     char_u	*envpat = NULL;
     char_u	*cmd;
-    EVENT_T	event;
+    event_T	event;
     int		need_free = FALSE;
     int		nested = FALSE;
     int		group;
@@ -7628,12 +7631,12 @@ do_autocmd(arg, forceit)
     /*
      * Loop over the events.
      */
-    last_event = (EVENT_T)-1;		/* for listing the event name */
+    last_event = (event_T)-1;		/* for listing the event name */
     last_group = AUGROUP_ERROR;		/* for listing the group name */
     if (*arg == '*' || *arg == NUL)
     {
-	for (event = (EVENT_T)0; (int)event < (int)NUM_EVENTS;
-					    event = (EVENT_T)((int)event + 1))
+	for (event = (event_T)0; (int)event < (int)NUM_EVENTS;
+					    event = (event_T)((int)event + 1))
 	    if (do_autocmd_event(event, pat,
 					 nested, cmd, forceit, group) == FAIL)
 		break;
@@ -7691,7 +7694,7 @@ au_get_grouparg(argp)
  */
     static int
 do_autocmd_event(event, pat, nested, cmd, forceit, group)
-    EVENT_T	event;
+    event_T	event;
     char_u	*pat;
     int		nested;
     char_u	*cmd;
@@ -8162,7 +8165,7 @@ static int	autocmd_nested = FALSE;
  */
     int
 apply_autocmds(event, fname, fname_io, force, buf)
-    EVENT_T	event;
+    event_T	event;
     char_u	*fname;	    /* NULL or empty means use actual file name */
     char_u	*fname_io;  /* fname to use for <afile> on cmdline */
     int		force;	    /* when TRUE, ignore autocmd_busy */
@@ -8178,7 +8181,7 @@ apply_autocmds(event, fname, fname_io, f
  */
     static int
 apply_autocmds_exarg(event, fname, fname_io, force, buf, eap)
-    EVENT_T	event;
+    event_T	event;
     char_u	*fname;
     char_u	*fname_io;
     int		force;
@@ -8197,7 +8200,7 @@ apply_autocmds_exarg(event, fname, fname
  */
     int
 apply_autocmds_retval(event, fname, fname_io, force, buf, retval)
-    EVENT_T	event;
+    event_T	event;
     char_u	*fname;	    /* NULL or empty means use actual file name */
     char_u	*fname_io;  /* fname to use for <afile> on cmdline */
     int		force;	    /* when TRUE, ignore autocmd_busy */
@@ -8222,14 +8225,14 @@ apply_autocmds_retval(event, fname, fnam
     return did_cmd;
 }
 
-#if defined(FEAT_AUTOCMD) || defined(PROTO)
 /*
  * Return TRUE when there is a CursorHold autocommand defined.
  */
     int
 has_cursorhold()
 {
-    return (first_autopat[(int)EVENT_CURSORHOLD] != NULL);
+    return (first_autopat[(int)(get_real_state() == NORMAL_BUSY
+			    ? EVENT_CURSORHOLD : EVENT_CURSORHOLDI)] != NULL);
 }
 
 /*
@@ -8238,16 +8241,38 @@ has_cursorhold()
     int
 trigger_cursorhold()
 {
-    return (!did_cursorhold
-	    && has_cursorhold()
-	    && !Recording
-	    && get_real_state() == NORMAL_BUSY);
+    int		state;
+
+    if (!did_cursorhold && has_cursorhold() && !Recording)
+    {
+	state = get_real_state();
+	if (state == NORMAL_BUSY || (state & INSERT) != 0)
+	    return TRUE;
+    }
+    return FALSE;
 }
-#endif
+
+/*
+ * Return TRUE when there is a CursorMoved autocommand defined.
+ */
+    int
+has_cursormoved()
+{
+    return (first_autopat[(int)EVENT_CURSORMOVED] != NULL);
+}
+
+/*
+ * Return TRUE when there is a CursorMovedI autocommand defined.
+ */
+    int
+has_cursormovedI()
+{
+    return (first_autopat[(int)EVENT_CURSORMOVEDI] != NULL);
+}
 
     static int
 apply_autocmds_group(event, fname, fname_io, force, group, buf, eap)
-    EVENT_T	event;
+    event_T	event;
     char_u	*fname;	    /* NULL or empty means use actual file name */
     char_u	*fname_io;  /* fname to use for <afile> on cmdline, NULL means
 			       use fname */
@@ -8735,7 +8760,7 @@ getnextac(c, cookie, indent)
  */
     int
 has_autocmd(event, sfname, buf)
-    EVENT_T	event;
+    event_T	event;
     char_u	*sfname;
     buf_T       *buf;
 {
@@ -8902,7 +8927,7 @@ au_exists(arg)
     char_u	*pattern = NULL;
     char_u	*event_name;
     char_u	*p;
-    EVENT_T	event;
+    event_T	event;
     AutoPat	*ap;
     buf_T	*buflocal_buf = NULL;
     int		group;
--- a/src/globals.h
+++ b/src/globals.h
@@ -781,8 +781,10 @@ EXTERN int		xim_changed_while_preediting
 # else
 EXTERN XIC		xic INIT(= NULL);
 # endif
+# ifdef FEAT_GUI
 EXTERN guicolor_T	xim_fg_color INIT(= INVALCOLOR);
 EXTERN guicolor_T	xim_bg_color INIT(= INVALCOLOR);
+# endif
 #endif
 
 #ifdef FEAT_HANGULIN
@@ -952,7 +954,12 @@ EXTERN char_u	*new_last_cmdline INIT(= N
 EXTERN char_u	*autocmd_fname INIT(= NULL); /* fname for <afile> on cmdline */
 EXTERN int	autocmd_bufnr INIT(= 0);     /* fnum for <abuf> on cmdline */
 EXTERN char_u	*autocmd_match INIT(= NULL); /* name for <amatch> on cmdline */
-EXTERN int	did_cursorhold INIT(= FALSE); /* set when CursorHold triggered */
+EXTERN int	did_cursorhold INIT(= FALSE); /* set when CursorHold t'gerd */
+EXTERN pos_T	last_cursormoved	    /* for CursorMoved event */
+# ifdef DO_INIT
+			= INIT_POS_T
+# endif
+			;
 #endif
 
 EXTERN linenr_T	write_no_eol_lnum INIT(= 0); /* non-zero lnum when last line
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -100,7 +100,7 @@
 #include <X11/Xlocale.h>
 #endif
 
-#if defined(FEAT_XIM) && defined(HAVE_GTK2)
+#if defined(FEAT_GUI_GTK) && defined(FEAT_XIM) && defined(HAVE_GTK2)
 # include <gdk/gdkkeysyms.h>
 # ifdef WIN3264
 #  include <gdk/gdkwin32.h>
--- a/src/proto/fileio.pro
+++ b/src/proto/fileio.pro
@@ -33,11 +33,13 @@ int do_doautocmd __ARGS((char_u *arg, in
 void ex_doautoall __ARGS((exarg_T *eap));
 void aucmd_prepbuf __ARGS((aco_save_T *aco, buf_T *buf));
 void aucmd_restbuf __ARGS((aco_save_T *aco));
-int apply_autocmds __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf));
-int apply_autocmds_retval __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, int *retval));
+int apply_autocmds __ARGS((event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf));
+int apply_autocmds_retval __ARGS((event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, int *retval));
 int has_cursorhold __ARGS((void));
 int trigger_cursorhold __ARGS((void));
-int has_autocmd __ARGS((EVENT_T event, char_u *sfname, buf_T *buf));
+int has_cursormoved __ARGS((void));
+int has_cursormovedI __ARGS((void));
+int has_autocmd __ARGS((event_T event, char_u *sfname, buf_T *buf));
 char_u *get_augroup_name __ARGS((expand_T *xp, int idx));
 char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd));
 char_u *get_event_name __ARGS((expand_T *xp, int idx));
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2575,8 +2575,10 @@ buf_hide(buf)
 grep_internal(cmdidx)
     cmdidx_T	cmdidx;
 {
-    return ((cmdidx == CMD_grep || cmdidx == CMD_lgrep
-	     || cmdidx == CMD_grepadd || cmdidx == CMD_lgrepadd)
+    return ((cmdidx == CMD_grep
+		|| cmdidx == CMD_lgrep
+		|| cmdidx == CMD_grepadd
+		|| cmdidx == CMD_lgrepadd)
 	    && STRCMP("internal",
 			*curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0);
 }
@@ -2598,12 +2600,12 @@ ex_make(eap)
 
     switch (eap->cmdidx)
     {
-	case CMD_make: au_name = (char_u *)"make"; break;
-	case CMD_lmake: au_name = (char_u *)"lmake"; break;
-	case CMD_grep: au_name = (char_u *)"grep"; break;
-	case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
-	case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
-	case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
+	case CMD_make:	    au_name = (char_u *)"make"; break;
+	case CMD_lmake:	    au_name = (char_u *)"lmake"; break;
+	case CMD_grep:	    au_name = (char_u *)"grep"; break;
+	case CMD_lgrep:	    au_name = (char_u *)"lgrep"; break;
+	case CMD_grepadd:   au_name = (char_u *)"grepadd"; break;
+	case CMD_lgrepadd:  au_name = (char_u *)"lgrepadd"; break;
 	default: break;
     }
     if (au_name != NULL)
@@ -2908,7 +2910,7 @@ ex_vimgrep(eap)
     }
 #endif
 
-    if (eap->cmdidx == CMD_grep
+    if (eap->cmdidx == CMD_lgrep
 	    || eap->cmdidx == CMD_lvimgrep
 	    || eap->cmdidx == CMD_lgrepadd
 	    || eap->cmdidx == CMD_lvimgrepadd)
@@ -2939,7 +2941,7 @@ ex_vimgrep(eap)
 	goto theend;
     }
 
-    if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd && 
+    if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd &&
 	 eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd)
 					|| qi->qf_curlist == qi->qf_listcount)
 	/* make place for a new list */
@@ -3476,10 +3478,15 @@ ex_cbuffer(eap)
 		|| eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count)
 	    EMSG(_(e_invrange));
 	else
-	    qf_init_ext(qi, NULL, buf, NULL, p_efm,
-			(eap->cmdidx == CMD_cbuffer
-			 || eap->cmdidx == CMD_lbuffer),
-			eap->line1, eap->line2);
+	{
+	    int		buffer_cmd = (eap->cmdidx == CMD_cbuffer
+					       || eap->cmdidx == CMD_lbuffer);
+
+	    if (qf_init_ext(qi, NULL, buf, NULL, p_efm, buffer_cmd,
+						   eap->line1, eap->line2) > 0
+		    && buffer_cmd)
+		qf_jump(qi, 0, 0, eap->forceit);  /* display first error */
+	}
     }
 }
 
@@ -3673,8 +3680,7 @@ ex_helpgrep(eap)
     if (eap->cmdidx == CMD_lhelpgrep)
     {
 	/* If the help window is not opened or if it already points to the
-	 * correct location list, then free the new location list
-	 */ 
+	 * correct location list, then free the new location list. */
 	if (!curwin->w_buffer->b_help || curwin->w_llist == qi)
 	{
 	    if (new_qi)
--- a/src/version.h
+++ b/src/version.h
@@ -36,5 +36,5 @@
 #define VIM_VERSION_NODOT	"vim70aa"
 #define VIM_VERSION_SHORT	"7.0aa"
 #define VIM_VERSION_MEDIUM	"7.0aa ALPHA"
-#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 7)"
-#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 7, compiled "
+#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 9)"
+#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2006 Feb 9, compiled "