Karsten Hopp 6012b0
To: vim_dev@googlegroups.com
Karsten Hopp 6012b0
Subject: Patch 7.3.1115
Karsten Hopp 6012b0
Fcc: outbox
Karsten Hopp 6012b0
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 6012b0
Mime-Version: 1.0
Karsten Hopp 6012b0
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 6012b0
Content-Transfer-Encoding: 8bit
Karsten Hopp 6012b0
------------
Karsten Hopp 6012b0
Karsten Hopp 6012b0
Patch 7.3.1115
Karsten Hopp 6012b0
Problem:    Many users don't like the cursor line number when 'relativenumber'
Karsten Hopp 6012b0
	    is set.
Karsten Hopp 6012b0
Solution:   Have four combinations with 'number' and 'relativenumber'.
Karsten Hopp 6012b0
	    (Christian Brabandt)
Karsten Hopp 6012b0
Files:	    runtime/doc/options.txt, src/option.c, src/screen.c,
Karsten Hopp 6012b0
	    src/testdir/test89.in, src/testdir/test89.ok
Karsten Hopp 6012b0
Karsten Hopp 6012b0
Karsten Hopp 6012b0
*** ../vim-7.3.1114/runtime/doc/options.txt	2013-03-19 16:46:59.000000000 +0100
Karsten Hopp 6012b0
--- runtime/doc/options.txt	2013-06-04 22:01:35.000000000 +0200
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 5077,5084 ****
Karsten Hopp 6012b0
  	number.
Karsten Hopp 6012b0
  	When a long, wrapped line doesn't start with the first character, '-'
Karsten Hopp 6012b0
  	characters are put before the number.
Karsten Hopp 6012b0
! 	See |hl-LineNr| for the highlighting used for the number.
Karsten Hopp 6012b0
! 	When setting this option, 'relativenumber' is reset.
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
  						*'numberwidth'* *'nuw'*
Karsten Hopp 6012b0
  'numberwidth' 'nuw'	number	(Vim default: 4  Vi default: 8)
Karsten Hopp 6012b0
--- 5130,5149 ----
Karsten Hopp 6012b0
  	number.
Karsten Hopp 6012b0
  	When a long, wrapped line doesn't start with the first character, '-'
Karsten Hopp 6012b0
  	characters are put before the number.
Karsten Hopp 6012b0
! 	See |hl-LineNr|  and |hl-CursorLineNr| for the highlighting used for
Karsten Hopp 6012b0
! 	the number.
Karsten Hopp 6012b0
! 						*number_relativenumber*
Karsten Hopp 6012b0
! 	The 'relativenumber' option changes the displayed number to be
Karsten Hopp 6012b0
! 	relative to the cursor.  Together with 'number' there are these
Karsten Hopp 6012b0
! 	four combinations (cursor in line 3):
Karsten Hopp 6012b0
! 
Karsten Hopp 6012b0
!               	'nonu'          'nu'            'nonu'          'nu'
Karsten Hopp 6012b0
! 		'nornu'         'nornu'         'rnu'           'rnu'
Karsten Hopp 6012b0
! 
Karsten Hopp 6012b0
! 	    |apple          |  1 apple      |  2 apple      |  2 apple
Karsten Hopp 6012b0
! 	    |pear           |  2 pear       |  1 pear       |  1 pear
Karsten Hopp 6012b0
! 	    |nobody         |  3 nobody     |  0 nobody     |3   nobody
Karsten Hopp 6012b0
! 	    |there          |  4 there      |  1 there      |  1 there
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
  						*'numberwidth'* *'nuw'*
Karsten Hopp 6012b0
  'numberwidth' 'nuw'	number	(Vim default: 4  Vi default: 8)
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 5484,5491 ****
Karsten Hopp 6012b0
  	number.
Karsten Hopp 6012b0
  	When a long, wrapped line doesn't start with the first character, '-'
Karsten Hopp 6012b0
  	characters are put before the number.
Karsten Hopp 6012b0
! 	See |hl-LineNr| for the highlighting used for the number.
Karsten Hopp 6012b0
! 	When setting this option, 'number' is reset.
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
  						*'remap'* *'noremap'*
Karsten Hopp 6012b0
  'remap'			boolean	(default on)
Karsten Hopp 6012b0
--- 5556,5567 ----
Karsten Hopp 6012b0
  	number.
Karsten Hopp 6012b0
  	When a long, wrapped line doesn't start with the first character, '-'
Karsten Hopp 6012b0
  	characters are put before the number.
Karsten Hopp 6012b0
! 	See |hl-LineNr|  and |hl-CursorLineNr| for the highlighting used for
Karsten Hopp 6012b0
! 	the number.
Karsten Hopp 6012b0
! 	
Karsten Hopp 6012b0
! 	The number in front of the cursor line also depends on the value of
Karsten Hopp 6012b0
! 	'number', see |number_relativenumber| for all combinations of the two
Karsten Hopp 6012b0
! 	options.
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
  						*'remap'* *'noremap'*
Karsten Hopp 6012b0
  'remap'			boolean	(default on)
Karsten Hopp 6012b0
*** ../vim-7.3.1114/src/option.c	2013-05-21 22:38:14.000000000 +0200
Karsten Hopp 6012b0
--- src/option.c	2013-06-04 21:52:13.000000000 +0200
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 7647,7681 ****
Karsten Hopp 6012b0
      }
Karsten Hopp 6012b0
  #endif
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
-     /* If 'number' is set, reset 'relativenumber'. */
Karsten Hopp 6012b0
-     /* If 'relativenumber' is set, reset 'number'. */
Karsten Hopp 6012b0
-     else if ((int *)varp == &curwin->w_p_nu && curwin->w_p_nu)
Karsten Hopp 6012b0
-     {
Karsten Hopp 6012b0
- 	curwin->w_p_rnu = FALSE;
Karsten Hopp 6012b0
- 
Karsten Hopp 6012b0
- 	/* Only reset the global value if the own value is set globally. */
Karsten Hopp 6012b0
- 	if (((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0))
Karsten Hopp 6012b0
- 	    curwin->w_allbuf_opt.wo_rnu = FALSE;
Karsten Hopp 6012b0
-     }
Karsten Hopp 6012b0
-     else if ((int *)varp == &curwin->w_p_rnu && curwin->w_p_rnu)
Karsten Hopp 6012b0
-     {
Karsten Hopp 6012b0
- 	curwin->w_p_nu = FALSE;
Karsten Hopp 6012b0
- 
Karsten Hopp 6012b0
- 	/* Only reset the global value if the own value is set globally. */
Karsten Hopp 6012b0
- 	if (((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0))
Karsten Hopp 6012b0
- 	    curwin->w_allbuf_opt.wo_nu = FALSE;
Karsten Hopp 6012b0
-     }
Karsten Hopp 6012b0
-     else if ((int *)varp == &curwin->w_allbuf_opt.wo_nu
Karsten Hopp 6012b0
- 						&& curwin->w_allbuf_opt.wo_nu)
Karsten Hopp 6012b0
-     {
Karsten Hopp 6012b0
-         curwin->w_allbuf_opt.wo_rnu = FALSE;
Karsten Hopp 6012b0
-     }
Karsten Hopp 6012b0
-     else if ((int *)varp == &curwin->w_allbuf_opt.wo_rnu
Karsten Hopp 6012b0
- 					       && curwin->w_allbuf_opt.wo_rnu)
Karsten Hopp 6012b0
-     {
Karsten Hopp 6012b0
-         curwin->w_allbuf_opt.wo_nu = FALSE;
Karsten Hopp 6012b0
-     }
Karsten Hopp 6012b0
- 
Karsten Hopp 6012b0
      else if ((int *)varp == &curbuf->b_p_ro)
Karsten Hopp 6012b0
      {
Karsten Hopp 6012b0
  	/* when 'readonly' is reset globally, also reset readonlymode */
Karsten Hopp 6012b0
--- 7647,7652 ----
Karsten Hopp 6012b0
*** ../vim-7.3.1114/src/screen.c	2013-05-06 04:21:35.000000000 +0200
Karsten Hopp 6012b0
--- src/screen.c	2013-06-04 22:04:39.000000000 +0200
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 2329,2343 ****
Karsten Hopp 6012b0
  	    if (len > w + 1)
Karsten Hopp 6012b0
  		len = w + 1;
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! 	    if (wp->w_p_nu)
Karsten Hopp 6012b0
! 		/* 'number' */
Karsten Hopp 6012b0
  		num = (long)lnum;
Karsten Hopp 6012b0
  	    else
Karsten Hopp 6012b0
  	    {
Karsten Hopp 6012b0
  		/* 'relativenumber', don't use negative numbers */
Karsten Hopp 6012b0
  		num = labs((long)get_cursor_rel_lnum(wp, lnum));
Karsten Hopp 6012b0
! 		if (num == 0)
Karsten Hopp 6012b0
  		{
Karsten Hopp 6012b0
  		    num = lnum;
Karsten Hopp 6012b0
  		    fmt = "%-*ld ";
Karsten Hopp 6012b0
  		}
Karsten Hopp 6012b0
--- 2329,2345 ----
Karsten Hopp 6012b0
  	    if (len > w + 1)
Karsten Hopp 6012b0
  		len = w + 1;
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! 	    if (wp->w_p_nu && !wp->w_p_rnu)
Karsten Hopp 6012b0
! 		/* 'number' + 'norelativenumber' */
Karsten Hopp 6012b0
  		num = (long)lnum;
Karsten Hopp 6012b0
  	    else
Karsten Hopp 6012b0
  	    {
Karsten Hopp 6012b0
  		/* 'relativenumber', don't use negative numbers */
Karsten Hopp 6012b0
  		num = labs((long)get_cursor_rel_lnum(wp, lnum));
Karsten Hopp 6012b0
! 		if (num == 0 && wp->w_p_nu && wp->w_p_rnu)
Karsten Hopp 6012b0
  		{
Karsten Hopp 6012b0
+ 		    /* 'number' + 'relativenumber': cursor line shows absolute
Karsten Hopp 6012b0
+ 		     * line number */
Karsten Hopp 6012b0
  		    num = lnum;
Karsten Hopp 6012b0
  		    fmt = "%-*ld ";
Karsten Hopp 6012b0
  		}
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 3499,3513 ****
Karsten Hopp 6012b0
  			long num;
Karsten Hopp 6012b0
  			char *fmt = "%*ld ";
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! 			if (wp->w_p_nu)
Karsten Hopp 6012b0
! 			    /* 'number' */
Karsten Hopp 6012b0
  			    num = (long)lnum;
Karsten Hopp 6012b0
  			else
Karsten Hopp 6012b0
  			{
Karsten Hopp 6012b0
  			    /* 'relativenumber', don't use negative numbers */
Karsten Hopp 6012b0
  			    num = labs((long)get_cursor_rel_lnum(wp, lnum));
Karsten Hopp 6012b0
! 			    if (num == 0)
Karsten Hopp 6012b0
  			    {
Karsten Hopp 6012b0
  				num = lnum;
Karsten Hopp 6012b0
  				fmt = "%-*ld ";
Karsten Hopp 6012b0
  			    }
Karsten Hopp 6012b0
--- 3501,3516 ----
Karsten Hopp 6012b0
  			long num;
Karsten Hopp 6012b0
  			char *fmt = "%*ld ";
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! 			if (wp->w_p_nu && !wp->w_p_rnu)
Karsten Hopp 6012b0
! 			    /* 'number' + 'norelativenumber' */
Karsten Hopp 6012b0
  			    num = (long)lnum;
Karsten Hopp 6012b0
  			else
Karsten Hopp 6012b0
  			{
Karsten Hopp 6012b0
  			    /* 'relativenumber', don't use negative numbers */
Karsten Hopp 6012b0
  			    num = labs((long)get_cursor_rel_lnum(wp, lnum));
Karsten Hopp 6012b0
! 			    if (num == 0 && wp->w_p_nu && wp->w_p_rnu)
Karsten Hopp 6012b0
  			    {
Karsten Hopp 6012b0
+ 				/* 'number' + 'relativenumber' */
Karsten Hopp 6012b0
  				num = lnum;
Karsten Hopp 6012b0
  				fmt = "%-*ld ";
Karsten Hopp 6012b0
  			    }
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 10260,10266 ****
Karsten Hopp 6012b0
      int		n;
Karsten Hopp 6012b0
      linenr_T	lnum;
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
!     lnum = wp->w_buffer->b_ml.ml_line_count;
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
      if (lnum == wp->w_nrwidth_line_count)
Karsten Hopp 6012b0
  	return wp->w_nrwidth_width;
Karsten Hopp 6012b0
--- 10263,10274 ----
Karsten Hopp 6012b0
      int		n;
Karsten Hopp 6012b0
      linenr_T	lnum;
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
!     if (wp->w_p_rnu && !wp->w_p_nu)
Karsten Hopp 6012b0
! 	/* cursor line shows "0" */
Karsten Hopp 6012b0
! 	lnum = wp->w_height;
Karsten Hopp 6012b0
!     else
Karsten Hopp 6012b0
! 	/* cursor line shows absolute line number */
Karsten Hopp 6012b0
! 	lnum = wp->w_buffer->b_ml.ml_line_count;
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
      if (lnum == wp->w_nrwidth_line_count)
Karsten Hopp 6012b0
  	return wp->w_nrwidth_width;
Karsten Hopp 6012b0
*** ../vim-7.3.1114/src/testdir/test89.in	2013-04-24 15:47:11.000000000 +0200
Karsten Hopp 6012b0
--- src/testdir/test89.in	2013-06-04 21:59:01.000000000 +0200
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 1,4 ****
Karsten Hopp 6012b0
--- 1,6 ----
Karsten Hopp 6012b0
  Some tests for setting 'number' and 'relativenumber'
Karsten Hopp 6012b0
+ This is not all that useful now that the options are no longer reset when
Karsten Hopp 6012b0
+ setting the other.
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
  STARTTEST
Karsten Hopp 6012b0
  :so small.vim
Karsten Hopp 6012b0
*** ../vim-7.3.1114/src/testdir/test89.ok	2013-03-13 20:42:28.000000000 +0100
Karsten Hopp 6012b0
--- src/testdir/test89.ok	2013-06-04 21:58:09.000000000 +0200
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 1,9 ****
Karsten Hopp 6012b0
  results:
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! nonumber
Karsten Hopp 6012b0
    relativenumber
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! nonumber
Karsten Hopp 6012b0
    relativenumber
Karsten Hopp 6012b0
  :setlocal must NOT reset the other global value
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
--- 1,9 ----
Karsten Hopp 6012b0
  results:
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
!   number
Karsten Hopp 6012b0
    relativenumber
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
!   number
Karsten Hopp 6012b0
    relativenumber
Karsten Hopp 6012b0
  :setlocal must NOT reset the other global value
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 12,22 ****
Karsten Hopp 6012b0
    relativenumber
Karsten Hopp 6012b0
  :setglobal MUST reset the other global value
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! nonumber
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! norelativenumber
Karsten Hopp 6012b0
  :set MUST reset the other global value
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! nonumber
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
! norelativenumber
Karsten Hopp 6012b0
--- 12,22 ----
Karsten Hopp 6012b0
    relativenumber
Karsten Hopp 6012b0
  :setglobal MUST reset the other global value
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
!   number
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
!   relativenumber
Karsten Hopp 6012b0
  :set MUST reset the other global value
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
!   number
Karsten Hopp 6012b0
  
Karsten Hopp 6012b0
!   relativenumber
Karsten Hopp 6012b0
*** ../vim-7.3.1114/src/version.c	2013-06-04 21:42:19.000000000 +0200
Karsten Hopp 6012b0
--- src/version.c	2013-06-04 22:11:05.000000000 +0200
Karsten Hopp 6012b0
***************
Karsten Hopp 6012b0
*** 730,731 ****
Karsten Hopp 6012b0
--- 730,733 ----
Karsten Hopp 6012b0
  {   /* Add new patch number below this line */
Karsten Hopp 6012b0
+ /**/
Karsten Hopp 6012b0
+     1115,
Karsten Hopp 6012b0
  /**/
Karsten Hopp 6012b0
Karsten Hopp 6012b0
-- 
Karsten Hopp 6012b0
From "know your smileys":
Karsten Hopp 6012b0
 :----}  You lie like Pinocchio
Karsten Hopp 6012b0
Karsten Hopp 6012b0
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 6012b0
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 6012b0
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 6012b0
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///