Karsten Hopp fa5876
To: vim_dev@googlegroups.com
Karsten Hopp fa5876
Subject: Patch 7.3.618
Karsten Hopp fa5876
Fcc: outbox
Karsten Hopp fa5876
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp fa5876
Mime-Version: 1.0
Karsten Hopp fa5876
Content-Type: text/plain; charset=UTF-8
Karsten Hopp fa5876
Content-Transfer-Encoding: 8bit
Karsten Hopp fa5876
------------
Karsten Hopp fa5876
Karsten Hopp fa5876
Patch 7.3.618 (after 7.3.616)
Karsten Hopp fa5876
Problem:    Still doesn't compile with small features.
Karsten Hopp fa5876
Solution:   Move current_search() out of #ifdef. (Dominique Pelle)
Karsten Hopp fa5876
Files:	    src/normal.c, src/search.c
Karsten Hopp fa5876
Karsten Hopp fa5876
Karsten Hopp fa5876
*** ../vim-7.3.617/src/normal.c	2012-07-27 21:05:51.000000000 +0200
Karsten Hopp fa5876
--- src/normal.c	2012-07-28 13:34:13.000000000 +0200
Karsten Hopp fa5876
***************
Karsten Hopp fa5876
*** 7995,8000 ****
Karsten Hopp fa5876
--- 7995,8001 ----
Karsten Hopp fa5876
  	cap->arg = TRUE;
Karsten Hopp fa5876
  	nv_visual(cap);
Karsten Hopp fa5876
  	break;
Karsten Hopp fa5876
+ #endif /* FEAT_VISUAL */
Karsten Hopp fa5876
  
Karsten Hopp fa5876
      /* "gn", "gN" visually select next/previous search match
Karsten Hopp fa5876
       * "gn" selects next match
Karsten Hopp fa5876
***************
Karsten Hopp fa5876
*** 8006,8014 ****
Karsten Hopp fa5876
  	if (!current_search(cap->count1, cap->nchar == 'n'))
Karsten Hopp fa5876
  #endif
Karsten Hopp fa5876
  	    beep_flush();
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
  	break;
Karsten Hopp fa5876
- #endif /* FEAT_VISUAL */
Karsten Hopp fa5876
  
Karsten Hopp fa5876
      /*
Karsten Hopp fa5876
       * "gj" and "gk" two new funny movement keys -- up and down
Karsten Hopp fa5876
--- 8007,8013 ----
Karsten Hopp fa5876
*** ../vim-7.3.617/src/search.c	2012-07-25 15:06:20.000000000 +0200
Karsten Hopp fa5876
--- src/search.c	2012-07-28 13:37:19.000000000 +0200
Karsten Hopp fa5876
***************
Karsten Hopp fa5876
*** 3397,3547 ****
Karsten Hopp fa5876
      return OK;
Karsten Hopp fa5876
  }
Karsten Hopp fa5876
  
Karsten Hopp fa5876
- #if defined(FEAT_VISUAL) || defined(PROTO)
Karsten Hopp fa5876
- /*
Karsten Hopp fa5876
-  * Find next search match under cursor, cursor at end.
Karsten Hopp fa5876
-  * Used while an operator is pending, and in Visual mode.
Karsten Hopp fa5876
-  * TODO: redo only works when used in operator pending mode
Karsten Hopp fa5876
-  */
Karsten Hopp fa5876
-     int
Karsten Hopp fa5876
- current_search(count, forward)
Karsten Hopp fa5876
-     long	count;
Karsten Hopp fa5876
-     int		forward;	/* move forward or backwards */
Karsten Hopp fa5876
- {
Karsten Hopp fa5876
-     pos_T	start_pos;	/* position before the pattern */
Karsten Hopp fa5876
-     pos_T	orig_pos;	/* position of the cursor at beginning */
Karsten Hopp fa5876
-     pos_T	pos;		/* position after the pattern */
Karsten Hopp fa5876
-     int		i;
Karsten Hopp fa5876
-     int		dir;
Karsten Hopp fa5876
-     int		result;		/* result of various function calls */
Karsten Hopp fa5876
-     char_u	old_p_ws = p_ws;
Karsten Hopp fa5876
-     int		visual_active = FALSE;
Karsten Hopp fa5876
-     int		flags = 0;
Karsten Hopp fa5876
-     pos_T	save_VIsual;
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     /* wrapping should not occur */
Karsten Hopp fa5876
-     p_ws = FALSE;
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     /* Correct cursor when 'selection' is exclusive */
Karsten Hopp fa5876
-     if (VIsual_active && *p_sel == 'e' && lt(VIsual, curwin->w_cursor))
Karsten Hopp fa5876
- 	dec_cursor();
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     if (VIsual_active)
Karsten Hopp fa5876
-     {
Karsten Hopp fa5876
- 	orig_pos = curwin->w_cursor;
Karsten Hopp fa5876
- 	save_VIsual = VIsual;
Karsten Hopp fa5876
- 	visual_active = TRUE;
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
- 	/* just started visual selection, only one character */
Karsten Hopp fa5876
- 	if (equalpos(VIsual, curwin->w_cursor))
Karsten Hopp fa5876
- 	    visual_active = FALSE;
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
- 	pos = curwin->w_cursor;
Karsten Hopp fa5876
- 	start_pos = VIsual;
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
- 	/* make sure, searching further will extend the match */
Karsten Hopp fa5876
- 	if (VIsual_active)
Karsten Hopp fa5876
- 	{
Karsten Hopp fa5876
- 	    if (forward)
Karsten Hopp fa5876
- 		incl(&pos;;
Karsten Hopp fa5876
- 	    else
Karsten Hopp fa5876
- 		decl(&pos;;
Karsten Hopp fa5876
- 	}
Karsten Hopp fa5876
-     }
Karsten Hopp fa5876
-     else
Karsten Hopp fa5876
- 	orig_pos = pos = start_pos = curwin->w_cursor;
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     /*
Karsten Hopp fa5876
-      * The trick is to first search backwards and then search forward again,
Karsten Hopp fa5876
-      * so that a match at the current cursor position will be correctly
Karsten Hopp fa5876
-      * captured.
Karsten Hopp fa5876
-      */
Karsten Hopp fa5876
-     for (i = 0; i < 2; i++)
Karsten Hopp fa5876
-     {
Karsten Hopp fa5876
- 	if (i && count == 1)
Karsten Hopp fa5876
- 	    flags = SEARCH_START;
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
- 	if (forward)
Karsten Hopp fa5876
- 	    dir = i;
Karsten Hopp fa5876
- 	else
Karsten Hopp fa5876
- 	    dir = !i;
Karsten Hopp fa5876
- 	result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD),
Karsten Hopp fa5876
- 		spats[last_idx].pat, (long) (i ? count : 1),
Karsten Hopp fa5876
- 		SEARCH_KEEP | flags | (dir ? 0 : SEARCH_END),
Karsten Hopp fa5876
- 		RE_SEARCH, 0, NULL);
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
- 	/* First search may fail, but then start searching from the
Karsten Hopp fa5876
- 	 * beginning of the file (cursor might be on the search match)
Karsten Hopp fa5876
- 	 * except when Visual mode is active, so that extending the visual
Karsten Hopp fa5876
- 	 * selection works. */
Karsten Hopp fa5876
- 	if (!result && i) /* not found, abort */
Karsten Hopp fa5876
- 	{
Karsten Hopp fa5876
- 	    curwin->w_cursor = orig_pos;
Karsten Hopp fa5876
- 	    if (VIsual_active)
Karsten Hopp fa5876
- 		VIsual = save_VIsual;
Karsten Hopp fa5876
- 	    p_ws = old_p_ws;
Karsten Hopp fa5876
- 	    return FAIL;
Karsten Hopp fa5876
- 	}
Karsten Hopp fa5876
- 	else if (!i && !result && !visual_active)
Karsten Hopp fa5876
- 	{
Karsten Hopp fa5876
- 	    if (forward) /* try again from start of buffer */
Karsten Hopp fa5876
- 	    {
Karsten Hopp fa5876
- 		clearpos(&pos;;
Karsten Hopp fa5876
- 	    }
Karsten Hopp fa5876
- 	    else /* try again from end of buffer */
Karsten Hopp fa5876
- 	    {
Karsten Hopp fa5876
- 		/* searching backwards, so set pos to last line and col */
Karsten Hopp fa5876
- 		pos.lnum = curwin->w_buffer->b_ml.ml_line_count;
Karsten Hopp fa5876
- 		pos.col  = STRLEN(ml_get(curwin->w_buffer->b_ml.ml_line_count));
Karsten Hopp fa5876
- 	    }
Karsten Hopp fa5876
- 	}
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     }
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     start_pos = pos;
Karsten Hopp fa5876
-     flags = (forward ? SEARCH_END : 0);
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     /* move to match */
Karsten Hopp fa5876
-     result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD),
Karsten Hopp fa5876
- 	    spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL);
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     if (!VIsual_active)
Karsten Hopp fa5876
- 	VIsual = start_pos;
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     p_ws = old_p_ws;
Karsten Hopp fa5876
-     curwin->w_cursor = pos;
Karsten Hopp fa5876
-     VIsual_active = TRUE;
Karsten Hopp fa5876
-     VIsual_mode = 'v';
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     if (VIsual_active)
Karsten Hopp fa5876
-     {
Karsten Hopp fa5876
- 	redraw_curbuf_later(INVERTED);	/* update the inversion */
Karsten Hopp fa5876
- 	if (*p_sel == 'e' && ltoreq(VIsual, curwin->w_cursor))
Karsten Hopp fa5876
- 	    inc_cursor();
Karsten Hopp fa5876
-     }
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
- #ifdef FEAT_FOLDING
Karsten Hopp fa5876
-     if (fdo_flags & FDO_SEARCH && KeyTyped)
Karsten Hopp fa5876
- 	foldOpenCursor();
Karsten Hopp fa5876
- #endif
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     may_start_select('c');
Karsten Hopp fa5876
- #ifdef FEAT_MOUSE
Karsten Hopp fa5876
-     setmouse();
Karsten Hopp fa5876
- #endif
Karsten Hopp fa5876
- #ifdef FEAT_CLIPBOARD
Karsten Hopp fa5876
-     /* Make sure the clipboard gets updated.  Needed because start and
Karsten Hopp fa5876
-      * end are still the same, and the selection needs to be owned */
Karsten Hopp fa5876
-     clip_star.vmode = NUL;
Karsten Hopp fa5876
- #endif
Karsten Hopp fa5876
-     redraw_curbuf_later(INVERTED);
Karsten Hopp fa5876
-     showmode();
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
-     return OK;
Karsten Hopp fa5876
- }
Karsten Hopp fa5876
- #endif /* FEAT_VISUAL */
Karsten Hopp fa5876
- 
Karsten Hopp fa5876
  /*
Karsten Hopp fa5876
   * Find sentence(s) under the cursor, cursor at end.
Karsten Hopp fa5876
   * When Visual active, extend it by one or more sentences.
Karsten Hopp fa5876
--- 3397,3402 ----
Karsten Hopp fa5876
***************
Karsten Hopp fa5876
*** 4670,4675 ****
Karsten Hopp fa5876
--- 4525,4675 ----
Karsten Hopp fa5876
  
Karsten Hopp fa5876
  #endif /* FEAT_TEXTOBJ */
Karsten Hopp fa5876
  
Karsten Hopp fa5876
+ #if defined(FEAT_VISUAL) || defined(PROTO)
Karsten Hopp fa5876
+ /*
Karsten Hopp fa5876
+  * Find next search match under cursor, cursor at end.
Karsten Hopp fa5876
+  * Used while an operator is pending, and in Visual mode.
Karsten Hopp fa5876
+  * TODO: redo only works when used in operator pending mode
Karsten Hopp fa5876
+  */
Karsten Hopp fa5876
+     int
Karsten Hopp fa5876
+ current_search(count, forward)
Karsten Hopp fa5876
+     long	count;
Karsten Hopp fa5876
+     int		forward;	/* move forward or backwards */
Karsten Hopp fa5876
+ {
Karsten Hopp fa5876
+     pos_T	start_pos;	/* position before the pattern */
Karsten Hopp fa5876
+     pos_T	orig_pos;	/* position of the cursor at beginning */
Karsten Hopp fa5876
+     pos_T	pos;		/* position after the pattern */
Karsten Hopp fa5876
+     int		i;
Karsten Hopp fa5876
+     int		dir;
Karsten Hopp fa5876
+     int		result;		/* result of various function calls */
Karsten Hopp fa5876
+     char_u	old_p_ws = p_ws;
Karsten Hopp fa5876
+     int		visual_active = FALSE;
Karsten Hopp fa5876
+     int		flags = 0;
Karsten Hopp fa5876
+     pos_T	save_VIsual;
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     /* wrapping should not occur */
Karsten Hopp fa5876
+     p_ws = FALSE;
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     /* Correct cursor when 'selection' is exclusive */
Karsten Hopp fa5876
+     if (VIsual_active && *p_sel == 'e' && lt(VIsual, curwin->w_cursor))
Karsten Hopp fa5876
+ 	dec_cursor();
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     if (VIsual_active)
Karsten Hopp fa5876
+     {
Karsten Hopp fa5876
+ 	orig_pos = curwin->w_cursor;
Karsten Hopp fa5876
+ 	save_VIsual = VIsual;
Karsten Hopp fa5876
+ 	visual_active = TRUE;
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+ 	/* just started visual selection, only one character */
Karsten Hopp fa5876
+ 	if (equalpos(VIsual, curwin->w_cursor))
Karsten Hopp fa5876
+ 	    visual_active = FALSE;
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+ 	pos = curwin->w_cursor;
Karsten Hopp fa5876
+ 	start_pos = VIsual;
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+ 	/* make sure, searching further will extend the match */
Karsten Hopp fa5876
+ 	if (VIsual_active)
Karsten Hopp fa5876
+ 	{
Karsten Hopp fa5876
+ 	    if (forward)
Karsten Hopp fa5876
+ 		incl(&pos;;
Karsten Hopp fa5876
+ 	    else
Karsten Hopp fa5876
+ 		decl(&pos;;
Karsten Hopp fa5876
+ 	}
Karsten Hopp fa5876
+     }
Karsten Hopp fa5876
+     else
Karsten Hopp fa5876
+ 	orig_pos = pos = start_pos = curwin->w_cursor;
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     /*
Karsten Hopp fa5876
+      * The trick is to first search backwards and then search forward again,
Karsten Hopp fa5876
+      * so that a match at the current cursor position will be correctly
Karsten Hopp fa5876
+      * captured.
Karsten Hopp fa5876
+      */
Karsten Hopp fa5876
+     for (i = 0; i < 2; i++)
Karsten Hopp fa5876
+     {
Karsten Hopp fa5876
+ 	if (i && count == 1)
Karsten Hopp fa5876
+ 	    flags = SEARCH_START;
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+ 	if (forward)
Karsten Hopp fa5876
+ 	    dir = i;
Karsten Hopp fa5876
+ 	else
Karsten Hopp fa5876
+ 	    dir = !i;
Karsten Hopp fa5876
+ 	result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD),
Karsten Hopp fa5876
+ 		spats[last_idx].pat, (long) (i ? count : 1),
Karsten Hopp fa5876
+ 		SEARCH_KEEP | flags | (dir ? 0 : SEARCH_END),
Karsten Hopp fa5876
+ 		RE_SEARCH, 0, NULL);
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+ 	/* First search may fail, but then start searching from the
Karsten Hopp fa5876
+ 	 * beginning of the file (cursor might be on the search match)
Karsten Hopp fa5876
+ 	 * except when Visual mode is active, so that extending the visual
Karsten Hopp fa5876
+ 	 * selection works. */
Karsten Hopp fa5876
+ 	if (!result && i) /* not found, abort */
Karsten Hopp fa5876
+ 	{
Karsten Hopp fa5876
+ 	    curwin->w_cursor = orig_pos;
Karsten Hopp fa5876
+ 	    if (VIsual_active)
Karsten Hopp fa5876
+ 		VIsual = save_VIsual;
Karsten Hopp fa5876
+ 	    p_ws = old_p_ws;
Karsten Hopp fa5876
+ 	    return FAIL;
Karsten Hopp fa5876
+ 	}
Karsten Hopp fa5876
+ 	else if (!i && !result && !visual_active)
Karsten Hopp fa5876
+ 	{
Karsten Hopp fa5876
+ 	    if (forward) /* try again from start of buffer */
Karsten Hopp fa5876
+ 	    {
Karsten Hopp fa5876
+ 		clearpos(&pos;;
Karsten Hopp fa5876
+ 	    }
Karsten Hopp fa5876
+ 	    else /* try again from end of buffer */
Karsten Hopp fa5876
+ 	    {
Karsten Hopp fa5876
+ 		/* searching backwards, so set pos to last line and col */
Karsten Hopp fa5876
+ 		pos.lnum = curwin->w_buffer->b_ml.ml_line_count;
Karsten Hopp fa5876
+ 		pos.col  = STRLEN(ml_get(curwin->w_buffer->b_ml.ml_line_count));
Karsten Hopp fa5876
+ 	    }
Karsten Hopp fa5876
+ 	}
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     }
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     start_pos = pos;
Karsten Hopp fa5876
+     flags = (forward ? SEARCH_END : 0);
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     /* move to match */
Karsten Hopp fa5876
+     result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD),
Karsten Hopp fa5876
+ 	    spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL);
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     if (!VIsual_active)
Karsten Hopp fa5876
+ 	VIsual = start_pos;
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     p_ws = old_p_ws;
Karsten Hopp fa5876
+     curwin->w_cursor = pos;
Karsten Hopp fa5876
+     VIsual_active = TRUE;
Karsten Hopp fa5876
+     VIsual_mode = 'v';
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     if (VIsual_active)
Karsten Hopp fa5876
+     {
Karsten Hopp fa5876
+ 	redraw_curbuf_later(INVERTED);	/* update the inversion */
Karsten Hopp fa5876
+ 	if (*p_sel == 'e' && ltoreq(VIsual, curwin->w_cursor))
Karsten Hopp fa5876
+ 	    inc_cursor();
Karsten Hopp fa5876
+     }
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+ #ifdef FEAT_FOLDING
Karsten Hopp fa5876
+     if (fdo_flags & FDO_SEARCH && KeyTyped)
Karsten Hopp fa5876
+ 	foldOpenCursor();
Karsten Hopp fa5876
+ #endif
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     may_start_select('c');
Karsten Hopp fa5876
+ #ifdef FEAT_MOUSE
Karsten Hopp fa5876
+     setmouse();
Karsten Hopp fa5876
+ #endif
Karsten Hopp fa5876
+ #ifdef FEAT_CLIPBOARD
Karsten Hopp fa5876
+     /* Make sure the clipboard gets updated.  Needed because start and
Karsten Hopp fa5876
+      * end are still the same, and the selection needs to be owned */
Karsten Hopp fa5876
+     clip_star.vmode = NUL;
Karsten Hopp fa5876
+ #endif
Karsten Hopp fa5876
+     redraw_curbuf_later(INVERTED);
Karsten Hopp fa5876
+     showmode();
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
+     return OK;
Karsten Hopp fa5876
+ }
Karsten Hopp fa5876
+ #endif /* FEAT_VISUAL */
Karsten Hopp fa5876
+ 
Karsten Hopp fa5876
  #if defined(FEAT_LISP) || defined(FEAT_CINDENT) || defined(FEAT_TEXTOBJ) \
Karsten Hopp fa5876
  	|| defined(PROTO)
Karsten Hopp fa5876
  /*
Karsten Hopp fa5876
*** ../vim-7.3.617/src/version.c	2012-07-27 21:12:03.000000000 +0200
Karsten Hopp fa5876
--- src/version.c	2012-07-29 12:54:29.000000000 +0200
Karsten Hopp fa5876
***************
Karsten Hopp fa5876
*** 716,717 ****
Karsten Hopp fa5876
--- 716,719 ----
Karsten Hopp fa5876
  {   /* Add new patch number below this line */
Karsten Hopp fa5876
+ /**/
Karsten Hopp fa5876
+     618,
Karsten Hopp fa5876
  /**/
Karsten Hopp fa5876
Karsten Hopp fa5876
-- 
Karsten Hopp fa5876
hundred-and-one symptoms of being an internet addict:
Karsten Hopp fa5876
185. You order fast food over the Internet
Karsten Hopp fa5876
Karsten Hopp fa5876
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp fa5876
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp fa5876
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp fa5876
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///