dcaee6
To: vim_dev@googlegroups.com
dcaee6
Subject: Patch 7.4.079
dcaee6
Fcc: outbox
dcaee6
From: Bram Moolenaar <Bram@moolenaar.net>
dcaee6
Mime-Version: 1.0
dcaee6
Content-Type: text/plain; charset=UTF-8
dcaee6
Content-Transfer-Encoding: 8bit
dcaee6
------------
dcaee6
dcaee6
Patch 7.4.079
dcaee6
Problem:    A script cannot detect whether 'hlsearch' highlighting is actually
dcaee6
            displayed.
dcaee6
Solution:   Add the "v:hlsearch" variable. (ZyX)
dcaee6
Files:      src/runtime/doc/eval.txt, src/eval.c, src/ex_docmd.c,
dcaee6
            src/option.c, src/screen.c, src/search.c, src/tag.c, src/vim.h,
dcaee6
            src/testdir/test101.in, src/testdir/test101.ok,
dcaee6
            src/testdir/Make_amiga.mak, src/testdir/Make_dos.mak,
dcaee6
            src/testdir/Make_ming.mak, src/testdir/Make_os2.mak,
dcaee6
            src/testdir/Make_vms.mms, src/testdir/Makefile
dcaee6
dcaee6
dcaee6
diff: ../vim-7.4.078/src/runtime/doc/eval.txt: No such file or directory
dcaee6
diff: src/runtime/doc/eval.txt: No such file or directory
dcaee6
*** ../vim-7.4.078/src/eval.c	2013-11-05 07:12:59.000000000 +0100
dcaee6
--- src/eval.c	2013-11-08 04:11:46.000000000 +0100
dcaee6
***************
dcaee6
*** 356,361 ****
dcaee6
--- 356,362 ----
dcaee6
      {VV_NAME("mouse_col",	 VAR_NUMBER), 0},
dcaee6
      {VV_NAME("operator",	 VAR_STRING), VV_RO},
dcaee6
      {VV_NAME("searchforward",	 VAR_NUMBER), 0},
dcaee6
+     {VV_NAME("hlsearch",	 VAR_NUMBER), 0},
dcaee6
      {VV_NAME("oldfiles",	 VAR_LIST), 0},
dcaee6
      {VV_NAME("windowid",	 VAR_NUMBER), VV_RO},
dcaee6
  };
dcaee6
***************
dcaee6
*** 871,876 ****
dcaee6
--- 872,878 ----
dcaee6
  	    hash_add(&compat_hashtab, p->vv_di.di_key);
dcaee6
      }
dcaee6
      set_vim_var_nr(VV_SEARCHFORWARD, 1L);
dcaee6
+     set_vim_var_nr(VV_HLSEARCH, 1L);
dcaee6
      set_reg_var(0);  /* default for v:register is not 0 but '"' */
dcaee6
  
dcaee6
  #ifdef EBCDIC
dcaee6
***************
dcaee6
*** 20613,20618 ****
dcaee6
--- 20615,20627 ----
dcaee6
  		v->di_tv.vval.v_number = get_tv_number(tv);
dcaee6
  		if (STRCMP(varname, "searchforward") == 0)
dcaee6
  		    set_search_direction(v->di_tv.vval.v_number ? '/' : '?');
dcaee6
+ #ifdef FEAT_SEARCH_EXTRA
dcaee6
+ 		else if (STRCMP(varname, "hlsearch") == 0)
dcaee6
+ 		{
dcaee6
+ 		    no_hlsearch = !v->di_tv.vval.v_number;
dcaee6
+ 		    redraw_all_later(SOME_VALID);
dcaee6
+ 		}
dcaee6
+ #endif
dcaee6
  	    }
dcaee6
  	    return;
dcaee6
  	}
dcaee6
*** ../vim-7.4.078/src/ex_docmd.c	2013-07-24 15:09:37.000000000 +0200
dcaee6
--- src/ex_docmd.c	2013-11-08 04:17:01.000000000 +0100
dcaee6
***************
dcaee6
*** 11389,11395 ****
dcaee6
  ex_nohlsearch(eap)
dcaee6
      exarg_T	*eap UNUSED;
dcaee6
  {
dcaee6
!     no_hlsearch = TRUE;
dcaee6
      redraw_all_later(SOME_VALID);
dcaee6
  }
dcaee6
  
dcaee6
--- 11389,11395 ----
dcaee6
  ex_nohlsearch(eap)
dcaee6
      exarg_T	*eap UNUSED;
dcaee6
  {
dcaee6
!     SET_NO_HLSEARCH(TRUE);
dcaee6
      redraw_all_later(SOME_VALID);
dcaee6
  }
dcaee6
  
dcaee6
*** ../vim-7.4.078/src/option.c	2013-11-06 05:26:08.000000000 +0100
dcaee6
--- src/option.c	2013-11-08 04:17:32.000000000 +0100
dcaee6
***************
dcaee6
*** 7811,7817 ****
dcaee6
      /* when 'hlsearch' is set or reset: reset no_hlsearch */
dcaee6
      else if ((int *)varp == &p_hls)
dcaee6
      {
dcaee6
! 	no_hlsearch = FALSE;
dcaee6
      }
dcaee6
  #endif
dcaee6
  
dcaee6
--- 7811,7817 ----
dcaee6
      /* when 'hlsearch' is set or reset: reset no_hlsearch */
dcaee6
      else if ((int *)varp == &p_hls)
dcaee6
      {
dcaee6
! 	SET_NO_HLSEARCH(FALSE);
dcaee6
      }
dcaee6
  #endif
dcaee6
  
dcaee6
*** ../vim-7.4.078/src/screen.c	2013-07-13 12:23:00.000000000 +0200
dcaee6
--- src/screen.c	2013-11-08 04:17:48.000000000 +0100
dcaee6
***************
dcaee6
*** 7447,7453 ****
dcaee6
  	    {
dcaee6
  		/* don't free regprog in the match list, it's a copy */
dcaee6
  		vim_regfree(shl->rm.regprog);
dcaee6
! 		no_hlsearch = TRUE;
dcaee6
  	    }
dcaee6
  	    shl->rm.regprog = NULL;
dcaee6
  	    shl->lnum = 0;
dcaee6
--- 7447,7453 ----
dcaee6
  	    {
dcaee6
  		/* don't free regprog in the match list, it's a copy */
dcaee6
  		vim_regfree(shl->rm.regprog);
dcaee6
! 		SET_NO_HLSEARCH(TRUE);
dcaee6
  	    }
dcaee6
  	    shl->rm.regprog = NULL;
dcaee6
  	    shl->lnum = 0;
dcaee6
*** ../vim-7.4.078/src/search.c	2013-11-07 04:46:43.000000000 +0100
dcaee6
--- src/search.c	2013-11-08 04:18:57.000000000 +0100
dcaee6
***************
dcaee6
*** 289,295 ****
dcaee6
  	/* If 'hlsearch' set and search pat changed: need redraw. */
dcaee6
  	if (p_hls)
dcaee6
  	    redraw_all_later(SOME_VALID);
dcaee6
! 	no_hlsearch = FALSE;
dcaee6
  #endif
dcaee6
      }
dcaee6
  }
dcaee6
--- 289,295 ----
dcaee6
  	/* If 'hlsearch' set and search pat changed: need redraw. */
dcaee6
  	if (p_hls)
dcaee6
  	    redraw_all_later(SOME_VALID);
dcaee6
! 	SET_NO_HLSEARCH(FALSE);
dcaee6
  #endif
dcaee6
      }
dcaee6
  }
dcaee6
***************
dcaee6
*** 333,339 ****
dcaee6
  	spats[1] = saved_spats[1];
dcaee6
  	last_idx = saved_last_idx;
dcaee6
  # ifdef FEAT_SEARCH_EXTRA
dcaee6
! 	no_hlsearch = saved_no_hlsearch;
dcaee6
  # endif
dcaee6
      }
dcaee6
  }
dcaee6
--- 333,339 ----
dcaee6
  	spats[1] = saved_spats[1];
dcaee6
  	last_idx = saved_last_idx;
dcaee6
  # ifdef FEAT_SEARCH_EXTRA
dcaee6
! 	SET_NO_HLSEARCH(saved_no_hlsearch);
dcaee6
  # endif
dcaee6
      }
dcaee6
  }
dcaee6
***************
dcaee6
*** 1148,1154 ****
dcaee6
      if (no_hlsearch && !(options & SEARCH_KEEP))
dcaee6
      {
dcaee6
  	redraw_all_later(SOME_VALID);
dcaee6
! 	no_hlsearch = FALSE;
dcaee6
      }
dcaee6
  #endif
dcaee6
  
dcaee6
--- 1148,1154 ----
dcaee6
      if (no_hlsearch && !(options & SEARCH_KEEP))
dcaee6
      {
dcaee6
  	redraw_all_later(SOME_VALID);
dcaee6
! 	SET_NO_HLSEARCH(FALSE);
dcaee6
      }
dcaee6
  #endif
dcaee6
  
dcaee6
***************
dcaee6
*** 5561,5567 ****
dcaee6
  		spats[idx].off.off = off;
dcaee6
  #ifdef FEAT_SEARCH_EXTRA
dcaee6
  		if (setlast)
dcaee6
! 		    no_hlsearch = !hlsearch_on;
dcaee6
  #endif
dcaee6
  	    }
dcaee6
  	}
dcaee6
--- 5561,5569 ----
dcaee6
  		spats[idx].off.off = off;
dcaee6
  #ifdef FEAT_SEARCH_EXTRA
dcaee6
  		if (setlast)
dcaee6
! 		{
dcaee6
! 		    SET_NO_HLSEARCH(!hlsearch_on);
dcaee6
! 		}
dcaee6
  #endif
dcaee6
  	    }
dcaee6
  	}
dcaee6
*** ../vim-7.4.078/src/tag.c	2013-09-05 12:06:26.000000000 +0200
dcaee6
--- src/tag.c	2013-11-08 04:19:14.000000000 +0100
dcaee6
***************
dcaee6
*** 3330,3336 ****
dcaee6
  #ifdef FEAT_SEARCH_EXTRA
dcaee6
  	/* restore no_hlsearch when keeping the old search pattern */
dcaee6
  	if (search_options)
dcaee6
! 	    no_hlsearch = save_no_hlsearch;
dcaee6
  #endif
dcaee6
  
dcaee6
  	/* Return OK if jumped to another file (at least we found the file!). */
dcaee6
--- 3330,3338 ----
dcaee6
  #ifdef FEAT_SEARCH_EXTRA
dcaee6
  	/* restore no_hlsearch when keeping the old search pattern */
dcaee6
  	if (search_options)
dcaee6
! 	{
dcaee6
! 	    SET_NO_HLSEARCH(save_no_hlsearch);
dcaee6
! 	}
dcaee6
  #endif
dcaee6
  
dcaee6
  	/* Return OK if jumped to another file (at least we found the file!). */
dcaee6
*** ../vim-7.4.078/src/vim.h	2013-08-02 16:02:27.000000000 +0200
dcaee6
--- src/vim.h	2013-11-08 04:16:57.000000000 +0100
dcaee6
***************
dcaee6
*** 1864,1872 ****
dcaee6
  #define VV_MOUSE_COL	51
dcaee6
  #define VV_OP		52
dcaee6
  #define VV_SEARCHFORWARD 53
dcaee6
! #define VV_OLDFILES	54
dcaee6
! #define VV_WINDOWID	55
dcaee6
! #define VV_LEN		56	/* number of v: vars */
dcaee6
  
dcaee6
  #ifdef FEAT_CLIPBOARD
dcaee6
  
dcaee6
--- 1864,1873 ----
dcaee6
  #define VV_MOUSE_COL	51
dcaee6
  #define VV_OP		52
dcaee6
  #define VV_SEARCHFORWARD 53
dcaee6
! #define VV_HLSEARCH	54
dcaee6
! #define VV_OLDFILES	55
dcaee6
! #define VV_WINDOWID	56
dcaee6
! #define VV_LEN		57	/* number of v: vars */
dcaee6
  
dcaee6
  #ifdef FEAT_CLIPBOARD
dcaee6
  
dcaee6
***************
dcaee6
*** 2246,2249 ****
dcaee6
--- 2247,2256 ----
dcaee6
  /* Character used as separated in autoload function/variable names. */
dcaee6
  #define AUTOLOAD_CHAR '#'
dcaee6
  
dcaee6
+ #ifdef FEAT_EVAL
dcaee6
+ # define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr(VV_HLSEARCH, !no_hlsearch)
dcaee6
+ #else
dcaee6
+ # define SET_NO_HLSEARCH(flag) no_hlsearch = (flag)
dcaee6
+ #endif
dcaee6
+ 
dcaee6
  #endif /* VIM__H */
dcaee6
*** ../vim-7.4.078/src/testdir/test101.in	2013-11-08 04:28:49.000000000 +0100
dcaee6
--- src/testdir/test101.in	2013-11-08 04:11:46.000000000 +0100
dcaee6
***************
dcaee6
*** 0 ****
dcaee6
--- 1,45 ----
dcaee6
+ Test for v:hlsearch     vim: set ft=vim :
dcaee6
+ 
dcaee6
+ STARTTEST
dcaee6
+ :" Last abc: Q
dcaee6
+ :so small.vim
dcaee6
+ :new
dcaee6
+ :call setline(1, repeat(['aaa'], 10))
dcaee6
+ :set hlsearch nolazyredraw
dcaee6
+ :let r=[]
dcaee6
+ :command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch])
dcaee6
+ /aaa
dcaee6
+ :AddR
dcaee6
+ :nohlsearch
dcaee6
+ :AddR
dcaee6
+ :let v:hlsearch=1
dcaee6
+ :AddR
dcaee6
+ :let v:hlsearch=0
dcaee6
+ :AddR
dcaee6
+ :set hlsearch
dcaee6
+ :AddR
dcaee6
+ :let v:hlsearch=0
dcaee6
+ :AddR
dcaee6
+ n:AddR
dcaee6
+ :let v:hlsearch=0
dcaee6
+ :AddR
dcaee6
+ /
dcaee6
+ :AddR
dcaee6
+ :let r1=r[0][0]
dcaee6
+ :" I guess it is not guaranteed that screenattr outputs always the same character
dcaee6
+ :call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")')
dcaee6
+ :try
dcaee6
+ :   let v:hlsearch=[]
dcaee6
+ :catch
dcaee6
+ :   call add(r, matchstr(v:exception,'^Vim(let):E\d\+:'))
dcaee6
+ :endtry
dcaee6
+ :bwipeout!
dcaee6
+ :$put=r
dcaee6
+ :call garbagecollect(1)
dcaee6
+ :"
dcaee6
+ :/^start:/,$wq! test.out
dcaee6
+ :" vim: et ts=4 isk-=\:
dcaee6
+ :call getchar()
dcaee6
+ ENDTEST
dcaee6
+ 
dcaee6
+ start:
dcaee6
*** ../vim-7.4.078/src/testdir/test101.ok	2013-11-08 04:28:49.000000000 +0100
dcaee6
--- src/testdir/test101.ok	2013-11-08 04:11:46.000000000 +0100
dcaee6
***************
dcaee6
*** 0 ****
dcaee6
--- 1,11 ----
dcaee6
+ start:
dcaee6
+ 1:highlighted
dcaee6
+ 0:not highlighted
dcaee6
+ 1:highlighted
dcaee6
+ 0:not highlighted
dcaee6
+ 1:highlighted
dcaee6
+ 0:not highlighted
dcaee6
+ 1:highlighted
dcaee6
+ 0:not highlighted
dcaee6
+ 1:highlighted
dcaee6
+ Vim(let):E706:
dcaee6
*** ../vim-7.4.078/src/testdir/Make_amiga.mak	2013-11-07 03:25:51.000000000 +0100
dcaee6
--- src/testdir/Make_amiga.mak	2013-11-08 04:22:13.000000000 +0100
dcaee6
***************
dcaee6
*** 34,40 ****
dcaee6
  		test81.out test82.out test83.out test84.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test97.out test98.out \
dcaee6
! 		test99.out test100.out
dcaee6
  
dcaee6
  .SUFFIXES: .in .out
dcaee6
  
dcaee6
--- 34,40 ----
dcaee6
  		test81.out test82.out test83.out test84.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test97.out test98.out \
dcaee6
! 		test99.out test100.out test101.out
dcaee6
  
dcaee6
  .SUFFIXES: .in .out
dcaee6
  
dcaee6
***************
dcaee6
*** 151,153 ****
dcaee6
--- 151,154 ----
dcaee6
  test98.out: test98.in
dcaee6
  test99.out: test99.in
dcaee6
  test100.out: test100.in
dcaee6
+ test101.out: test101.in
dcaee6
*** ../vim-7.4.078/src/testdir/Make_dos.mak	2013-11-07 03:25:51.000000000 +0100
dcaee6
--- src/testdir/Make_dos.mak	2013-11-08 04:22:17.000000000 +0100
dcaee6
***************
dcaee6
*** 33,39 ****
dcaee6
  		test84.out test85.out test86.out test87.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test98.out test99.out \
dcaee6
! 		test100.out
dcaee6
  
dcaee6
  SCRIPTS32 =	test50.out test70.out
dcaee6
  
dcaee6
--- 33,39 ----
dcaee6
  		test84.out test85.out test86.out test87.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test98.out test99.out \
dcaee6
! 		test100.out test101.out
dcaee6
  
dcaee6
  SCRIPTS32 =	test50.out test70.out
dcaee6
  
dcaee6
*** ../vim-7.4.078/src/testdir/Make_ming.mak	2013-11-07 03:25:51.000000000 +0100
dcaee6
--- src/testdir/Make_ming.mak	2013-11-08 04:22:19.000000000 +0100
dcaee6
***************
dcaee6
*** 53,59 ****
dcaee6
  		test84.out test85.out test86.out test87.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test98.out test99.out \
dcaee6
! 		test100out
dcaee6
  
dcaee6
  SCRIPTS32 =	test50.out test70.out
dcaee6
  
dcaee6
--- 53,59 ----
dcaee6
  		test84.out test85.out test86.out test87.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test98.out test99.out \
dcaee6
! 		test100out test101.out
dcaee6
  
dcaee6
  SCRIPTS32 =	test50.out test70.out
dcaee6
  
dcaee6
*** ../vim-7.4.078/src/testdir/Make_os2.mak	2013-11-07 03:25:51.000000000 +0100
dcaee6
--- src/testdir/Make_os2.mak	2013-11-08 04:22:21.000000000 +0100
dcaee6
***************
dcaee6
*** 35,41 ****
dcaee6
  		test81.out test82.out test83.out test84.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test98.out test99.out \
dcaee6
! 		test100.out
dcaee6
  
dcaee6
  .SUFFIXES: .in .out
dcaee6
  
dcaee6
--- 35,41 ----
dcaee6
  		test81.out test82.out test83.out test84.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test98.out test99.out \
dcaee6
! 		test100.out test101.out
dcaee6
  
dcaee6
  .SUFFIXES: .in .out
dcaee6
  
dcaee6
*** ../vim-7.4.078/src/testdir/Make_vms.mms	2013-11-07 03:25:51.000000000 +0100
dcaee6
--- src/testdir/Make_vms.mms	2013-11-08 04:22:23.000000000 +0100
dcaee6
***************
dcaee6
*** 4,10 ****
dcaee6
  # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
dcaee6
  #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
dcaee6
  #
dcaee6
! # Last change:  2013 Nov 07
dcaee6
  #
dcaee6
  # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
dcaee6
  # Edit the lines in the Configuration section below to select.
dcaee6
--- 4,10 ----
dcaee6
  # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
dcaee6
  #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
dcaee6
  #
dcaee6
! # Last change:  2013 Nov 08
dcaee6
  #
dcaee6
  # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
dcaee6
  # Edit the lines in the Configuration section below to select.
dcaee6
***************
dcaee6
*** 79,85 ****
dcaee6
  	 test82.out test83.out test84.out test88.out test89.out \
dcaee6
  	 test90.out test91.out test92.out test93.out test94.out \
dcaee6
  	 test95.out test96.out test97.out test98.out test99.out \
dcaee6
! 	 test100.out
dcaee6
  
dcaee6
  # Known problems:
dcaee6
  # Test 30: a problem around mac format - unknown reason
dcaee6
--- 79,85 ----
dcaee6
  	 test82.out test83.out test84.out test88.out test89.out \
dcaee6
  	 test90.out test91.out test92.out test93.out test94.out \
dcaee6
  	 test95.out test96.out test97.out test98.out test99.out \
dcaee6
! 	 test100.out test101.out
dcaee6
  
dcaee6
  # Known problems:
dcaee6
  # Test 30: a problem around mac format - unknown reason
dcaee6
*** ../vim-7.4.078/src/testdir/Makefile	2013-11-07 03:25:51.000000000 +0100
dcaee6
--- src/testdir/Makefile	2013-11-08 04:22:26.000000000 +0100
dcaee6
***************
dcaee6
*** 30,36 ****
dcaee6
  		test84.out test85.out test86.out test87.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test97.out test98.out \
dcaee6
! 		test99.out test100.out
dcaee6
  
dcaee6
  SCRIPTS_GUI = test16.out
dcaee6
  
dcaee6
--- 30,36 ----
dcaee6
  		test84.out test85.out test86.out test87.out test88.out \
dcaee6
  		test89.out test90.out test91.out test92.out test93.out \
dcaee6
  		test94.out test95.out test96.out test97.out test98.out \
dcaee6
! 		test99.out test100.out test101.out
dcaee6
  
dcaee6
  SCRIPTS_GUI = test16.out
dcaee6
  
dcaee6
*** ../vim-7.4.078/src/version.c	2013-11-08 03:15:39.000000000 +0100
dcaee6
--- src/version.c	2013-11-08 04:11:08.000000000 +0100
dcaee6
***************
dcaee6
*** 740,741 ****
dcaee6
--- 740,743 ----
dcaee6
  {   /* Add new patch number below this line */
dcaee6
+ /**/
dcaee6
+     79,
dcaee6
  /**/
dcaee6
dcaee6
-- 
dcaee6
Corn oil comes from corn and olive oil comes from olives, so where
dcaee6
does baby oil come from?
dcaee6
dcaee6
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
dcaee6
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
dcaee6
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
dcaee6
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///