jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone
073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.5
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.542
073263
Problem:    Using a range for window and buffer commands has a few problems.
073263
	    Cannot specify the type of range for a user command.
073263
Solution:   Add the -addr argument for user commands.  Fix problems. (Marcin
073263
	    Szamotulski)
073263
Files:	    src/testdir/test_command_count.in,
073263
	    src/testdir/test_command_count.ok src/testdir/Make_amiga.mak
073263
	    src/testdir/Make_dos.mak, src/testdir/Make_ming.mak,
073263
	    src/testdir/Make_os2.mak, src/testdir/Make_vms.mms,
073263
	    src/testdir/Makefile, runtime/doc/map.txt, src/Makefile,
073263
	    src/ex_cmds.h, src/ex_docmd.c, src/ex_getln.c,
073263
	    src/proto/ex_docmd.pro, src/vim.h,
073263
073263
073263
*** ../vim-7.4.541/src/testdir/test_command_count.in	2014-12-08 04:12:53.163981827 +0100
073263
--- src/testdir/test_command_count.in	2014-12-08 03:25:41.562266976 +0100
073263
***************
073263
*** 0 ****
073263
--- 1,50 ----
073263
+ Test for user command counts	    vim: set ft=vim :
073263
+ 
073263
+ STARTTEST
073263
+ :let g:lines = []
073263
+ :so tiny.vim
073263
+ :com -range RangeLines :call add(g:lines, 'Rangeg:Lines '.<line1>.' '.<line2>)
073263
+ :com -range -addr=arguments RangeArguments :call add(g:lines, 'RangeArguments '.<line1>.' '.<line2>)
073263
+ :com -range=% -addr=arguments RangeArgumentsAll :call add(g:lines, 'RangeArgumentsAll '.<line1>.' '.<line2>)
073263
+ :com -range -addr=loaded_buffers RangeLoadedBuffers :call add(g:lines, 'RangeLoadedBuffers '.<line1>.' '.<line2>)
073263
+ :com -range=% -addr=loaded_buffers RangeLoadedBuffersAll :call add(g:lines, 'RangeLoadedBuffersAll '.<line1>.' '.<line2>)
073263
+ :com -range -addr=buffers RangeBuffers :call add(g:lines, 'RangeBuffers '.<line1>.' '.<line2>)
073263
+ :com -range=% -addr=buffers RangeBuffersAll :call add(g:lines, 'RangeBuffersAll '.<line1>.' '.<line2>)
073263
+ :com -range -addr=windows RangeWindows :call add(g:lines, 'RangeWindows '.<line1>.' '.<line2>)
073263
+ :com -range=% -addr=windows RangeWindowsAll :call add(g:lines, 'RangeWindowsAll '.<line1>.' '.<line2>)
073263
+ :com -range -addr=tabs RangeTabs :call add(g:lines, 'RangeTabs '.<line1>.' '.<line2>)
073263
+ :com -range=% -addr=tabs RangeTabsAll :call add(g:lines, 'RangeTabsAll '.<line1>.' '.<line2>)
073263
+ :set hidden
073263
+ :arga a b c d
073263
+ :argdo echo "loading buffers"
073263
+ :argu 3
073263
+ :.-,$-RangeArguments
073263
+ :%RangeArguments
073263
+ :RangeArgumentsAll
073263
+ :N
073263
+ :.RangeArguments
073263
+ :split|split|split|split
073263
+ :3wincmd w
073263
+ :.,$RangeWindows
073263
+ :%RangeWindows
073263
+ :RangeWindowsAll
073263
+ :only
073263
+ :blast|bd
073263
+ :.,$RangeLoadedBuffers
073263
+ :%RangeLoadedBuffers
073263
+ :RangeLoadedBuffersAll
073263
+ :.,$RangeBuffers
073263
+ :%RangeBuffers
073263
+ :RangeBuffersAll
073263
+ :tabe|tabe|tabe|tabe
073263
+ :normal 2gt
073263
+ :.,$RangeTabs
073263
+ :%RangeTabs
073263
+ :RangeTabsAll
073263
+ :1tabonly
073263
+ :e! test.out
073263
+ :call append(0, g:lines)
073263
+ :w|qa!
073263
+ ENDTEST
073263
+ 
073263
+ 
073263
*** ../vim-7.4.541/src/testdir/test_command_count.ok	2014-12-08 04:12:53.163981827 +0100
073263
--- src/testdir/test_command_count.ok	2014-12-08 03:26:11.769943969 +0100
073263
***************
073263
*** 0 ****
073263
--- 1,17 ----
073263
+ RangeArguments 2 4
073263
+ RangeArguments 1 5
073263
+ RangeArgumentsAll 1 5
073263
+ RangeArguments 2 2
073263
+ RangeWindows 3 5
073263
+ RangeWindows 1 5
073263
+ RangeWindowsAll 1 5
073263
+ RangeLoadedBuffers 2 4
073263
+ RangeLoadedBuffers 1 4
073263
+ RangeLoadedBuffersAll 1 4
073263
+ RangeBuffers 2 5
073263
+ RangeBuffers 1 5
073263
+ RangeBuffersAll 1 5
073263
+ RangeTabs 2 5
073263
+ RangeTabs 1 5
073263
+ RangeTabsAll 1 5
073263
+ 
073263
*** ../vim-7.4.541/src/testdir/Make_amiga.mak	2014-11-27 16:22:42.742413039 +0100
073263
--- src/testdir/Make_amiga.mak	2014-12-08 03:28:30.984456524 +0100
073263
***************
073263
*** 41,46 ****
073263
--- 41,47 ----
073263
  		test_breakindent.out \
073263
  		test_changelist.out \
073263
  		test_close_count.out \
073263
+ 		test_command_count.out \
073263
  		test_eval.out \
073263
  		test_insertcount.out \
073263
  		test_listlbr.out \
073263
***************
073263
*** 178,183 ****
073263
--- 179,185 ----
073263
  test_breakindent.out: test_breakindent.in
073263
  test_changelist.out: test_changelist.in
073263
  test_close_count.out: test_close_count.in
073263
+ test_command_count.out: test_command_count.in
073263
  test_eval.out: test_eval.in
073263
  test_insertcount.out: test_insertcount.in
073263
  test_listlbr.out: test_listlbr.in
073263
*** ../vim-7.4.541/src/testdir/Make_dos.mak	2014-11-27 16:22:42.742413039 +0100
073263
--- src/testdir/Make_dos.mak	2014-12-08 03:28:43.168326713 +0100
073263
***************
073263
*** 40,45 ****
073263
--- 40,46 ----
073263
  		test_breakindent.out \
073263
  		test_changelist.out \
073263
  		test_close_count.out \
073263
+ 		test_command_count.out \
073263
  		test_eval.out \
073263
  		test_insertcount.out \
073263
  		test_listlbr.out \
073263
*** ../vim-7.4.541/src/testdir/Make_ming.mak	2014-11-27 16:22:42.742413039 +0100
073263
--- src/testdir/Make_ming.mak	2014-12-08 03:28:54.020208323 +0100
073263
***************
073263
*** 62,67 ****
073263
--- 62,68 ----
073263
  		test_breakindent.out \
073263
  		test_changelist.out \
073263
  		test_close_count.out \
073263
+ 		test_command_count.out \
073263
  		test_eval.out \
073263
  		test_insertcount.out \
073263
  		test_listlbr.out \
073263
*** ../vim-7.4.541/src/testdir/Make_os2.mak	2014-11-27 16:22:42.742413039 +0100
073263
--- src/testdir/Make_os2.mak	2014-12-08 03:29:03.304108543 +0100
073263
***************
073263
*** 42,47 ****
073263
--- 42,48 ----
073263
  		test_breakindent.out \
073263
  		test_changelist.out \
073263
  		test_close_count.out \
073263
+ 		test_command_count.out \
073263
  		test_eval.out \
073263
  		test_insertcount.out \
073263
  		test_listlbr.out \
073263
*** ../vim-7.4.541/src/testdir/Make_vms.mms	2014-11-27 16:22:42.746412995 +0100
073263
--- src/testdir/Make_vms.mms	2014-12-08 03:29:12.596009487 +0100
073263
***************
073263
*** 4,10 ****
073263
  # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
073263
  #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
073263
  #
073263
! # Last change:  2014 Nov 27
073263
  #
073263
  # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
073263
  # Edit the lines in the Configuration section below to select.
073263
--- 4,10 ----
073263
  # Authors:	Zoltan Arpadffy, <arpadffy@polarhome.com>
073263
  #		Sandor Kopanyi,  <sandor.kopanyi@mailbox.hu>
073263
  #
073263
! # Last change:  2014 Dec 08
073263
  #
073263
  # This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
073263
  # Edit the lines in the Configuration section below to select.
073263
***************
073263
*** 101,106 ****
073263
--- 101,107 ----
073263
  	 test_breakindent.out \
073263
  	 test_changelist.out \
073263
  	 test_close_count.out \
073263
+ 	 test_command_count.out \
073263
  	 test_eval.out \
073263
  	 test_insertcount.out \
073263
  	 test_listlbr.out \
073263
*** ../vim-7.4.541/src/testdir/Makefile	2014-11-27 16:22:42.746412995 +0100
073263
--- src/testdir/Makefile	2014-12-08 03:29:36.519753429 +0100
073263
***************
073263
*** 38,43 ****
073263
--- 38,44 ----
073263
  		test_breakindent.out \
073263
  		test_changelist.out \
073263
  		test_close_count.out \
073263
+ 		test_command_count.out \
073263
  		test_eval.out \
073263
  		test_insertcount.out \
073263
  		test_listlbr.out \
073263
*** ../vim-7.4.541/runtime/doc/map.txt	2014-02-23 23:38:58.820760280 +0100
073263
--- runtime/doc/map.txt	2014-12-08 03:33:48.569056762 +0100
073263
***************
073263
*** 1344,1349 ****
073263
--- 1358,1376 ----
073263
  Note that -range=N and -count=N are mutually exclusive - only one should be
073263
  specified.
073263
  
073263
+ 					*E889* *:command-addr*
073263
+ It is possible that the special characters in the range like ., $ or % which
073263
+ by default correspond to the current line, last line and the whole buffer,
073263
+ relate to arguments, (loaded) buffers, windows or tab pages.
073263
+ 
073263
+ Possible values are:
073263
+ 	-addr=lines		Range of lines (this is the default)
073263
+ 	-addr=arguments		Range for arguments
073263
+ 	-addr=buffers		Range for buffers (also not loaded buffers)
073263
+ 	-addr=loaded_buffers	Range for loaded buffers
073263
+ 	-addr=windows		Range for windows
073263
+ 	-addr=tabs		Range for tab pages
073263
+ 
073263
  Special cases				*:command-bang* *:command-bar*
073263
  					*:command-register* *:command-buffer*
073263
  There are some special cases as well:
073263
*** ../vim-7.4.541/src/Makefile	2014-11-27 16:22:42.738413084 +0100
073263
--- src/Makefile	2014-12-08 03:30:06.167435718 +0100
073263
***************
073263
*** 1896,1901 ****
073263
--- 1896,1902 ----
073263
  	test_breakindent \
073263
  	test_changelist \
073263
  	test_close_count \
073263
+ 	test_command_count \
073263
  	test_eval \
073263
  	test_insertcount \
073263
  	test_listlbr \
073263
*** ../vim-7.4.541/src/ex_cmds.h	2014-11-27 16:22:42.742413039 +0100
073263
--- src/ex_cmds.h	2014-12-08 03:30:59.278867940 +0100
073263
***************
073263
*** 63,69 ****
073263
  #define ADDR_WINDOWS		1
073263
  #define ADDR_ARGUMENTS		2
073263
  #define ADDR_LOADED_BUFFERS	3
073263
! #define ADDR_UNLOADED_BUFFERS	4
073263
  #define ADDR_TABS		5
073263
  
073263
  #ifndef DO_DECLARE_EXCMD
073263
--- 63,69 ----
073263
  #define ADDR_WINDOWS		1
073263
  #define ADDR_ARGUMENTS		2
073263
  #define ADDR_LOADED_BUFFERS	3
073263
! #define ADDR_BUFFERS	4
073263
  #define ADDR_TABS		5
073263
  
073263
  #ifndef DO_DECLARE_EXCMD
073263
***************
073263
*** 161,167 ****
073263
  			ADDR_LINES),
073263
  EX(CMD_buffer,		"buffer",	ex_buffer,
073263
  			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|EDITCMD|TRLBAR,
073263
! 			ADDR_UNLOADED_BUFFERS),
073263
  EX(CMD_bNext,		"bNext",	ex_bprevious,
073263
  			BANG|RANGE|NOTADR|COUNT|EDITCMD|TRLBAR,
073263
  			ADDR_LINES),
073263
--- 161,167 ----
073263
  			ADDR_LINES),
073263
  EX(CMD_buffer,		"buffer",	ex_buffer,
073263
  			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|EDITCMD|TRLBAR,
073263
! 			ADDR_BUFFERS),
073263
  EX(CMD_bNext,		"bNext",	ex_bprevious,
073263
  			BANG|RANGE|NOTADR|COUNT|EDITCMD|TRLBAR,
073263
  			ADDR_LINES),
073263
***************
073263
*** 227,233 ****
073263
  			ADDR_LOADED_BUFFERS),
073263
  EX(CMD_bwipeout,	"bwipeout",	ex_bunload,
073263
  			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|TRLBAR,
073263
! 			ADDR_UNLOADED_BUFFERS),
073263
  EX(CMD_change,		"change",	ex_change,
073263
  			BANG|WHOLEFOLD|RANGE|COUNT|TRLBAR|CMDWIN|MODIFY,
073263
  			ADDR_LINES),
073263
--- 227,233 ----
073263
  			ADDR_LOADED_BUFFERS),
073263
  EX(CMD_bwipeout,	"bwipeout",	ex_bunload,
073263
  			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|TRLBAR,
073263
! 			ADDR_BUFFERS),
073263
  EX(CMD_change,		"change",	ex_change,
073263
  			BANG|WHOLEFOLD|RANGE|COUNT|TRLBAR|CMDWIN|MODIFY,
073263
  			ADDR_LINES),
073263
***************
073263
*** 1184,1190 ****
073263
  			ADDR_LINES),
073263
  EX(CMD_sbuffer,		"sbuffer",	ex_buffer,
073263
  			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|EDITCMD|TRLBAR,
073263
! 			ADDR_UNLOADED_BUFFERS),
073263
  EX(CMD_sbNext,		"sbNext",	ex_bprevious,
073263
  			RANGE|NOTADR|COUNT|EDITCMD|TRLBAR,
073263
  			ADDR_LINES),
073263
--- 1184,1190 ----
073263
  			ADDR_LINES),
073263
  EX(CMD_sbuffer,		"sbuffer",	ex_buffer,
073263
  			BANG|RANGE|NOTADR|BUFNAME|BUFUNL|COUNT|EXTRA|EDITCMD|TRLBAR,
073263
! 			ADDR_BUFFERS),
073263
  EX(CMD_sbNext,		"sbNext",	ex_bprevious,
073263
  			RANGE|NOTADR|COUNT|EDITCMD|TRLBAR,
073263
  			ADDR_LINES),
073263
*** ../vim-7.4.541/src/ex_docmd.c	2014-11-30 22:51:00.629191482 +0100
073263
--- src/ex_docmd.c	2014-12-08 04:00:14.540095591 +0100
073263
***************
073263
*** 27,32 ****
073263
--- 27,33 ----
073263
      char_u	*uc_rep;	/* The command's replacement string */
073263
      long	uc_def;		/* The default value for a range/count */
073263
      int		uc_compl;	/* completion type */
073263
+     int		uc_addr_type;	/* The command's address type */
073263
  # ifdef FEAT_EVAL
073263
      scid_T	uc_scriptID;	/* SID where the command was defined */
073263
  #  ifdef FEAT_CMDL_COMPL
073263
***************
073263
*** 2136,2142 ****
073263
--- 2137,2147 ----
073263
         )
073263
  	ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;
073263
      else
073263
+ #ifdef FEAT_USR_CMDS
073263
+ 	if (ea.cmdidx != CMD_USER)
073263
+ #endif
073263
  	ea.addr_type = ADDR_LINES;
073263
+     /* ea.addr_type for user commands is set by find_ucmd */
073263
      ea.cmd = cmd;
073263
  
073263
      /* repeat for all ',' or ';' separated addresses */
073263
***************
073263
*** 2157,2163 ****
073263
  		ea.line2 = curwin->w_arg_idx + 1;
073263
  		break;
073263
  	    case ADDR_LOADED_BUFFERS:
073263
! 	    case ADDR_UNLOADED_BUFFERS:
073263
  		ea.line2 = curbuf->b_fnum;
073263
  		break;
073263
  	    case ADDR_TABS:
073263
--- 2162,2168 ----
073263
  		ea.line2 = curwin->w_arg_idx + 1;
073263
  		break;
073263
  	    case ADDR_LOADED_BUFFERS:
073263
! 	    case ADDR_BUFFERS:
073263
  		ea.line2 = curbuf->b_fnum;
073263
  		break;
073263
  	    case ADDR_TABS:
073263
***************
073263
*** 2191,2208 ****
073263
  			    buf = buf->b_prev;
073263
  			ea.line2 = buf->b_fnum;
073263
  			break;
073263
! 		    case ADDR_UNLOADED_BUFFERS:
073263
  			ea.line1 = firstbuf->b_fnum;
073263
  			ea.line2 = lastbuf->b_fnum;
073263
  			break;
073263
  		    case ADDR_WINDOWS:
073263
  		    case ADDR_TABS:
073263
! 			errormsg = (char_u *)_(e_invrange);
073263
! 			goto doend;
073263
  			break;
073263
  		    case ADDR_ARGUMENTS:
073263
! 			ea.line1 = 1;
073263
! 			ea.line2 = ARGCOUNT;
073263
  			break;
073263
  		}
073263
  		++ea.addr_count;
073263
--- 2196,2229 ----
073263
  			    buf = buf->b_prev;
073263
  			ea.line2 = buf->b_fnum;
073263
  			break;
073263
! 		    case ADDR_BUFFERS:
073263
  			ea.line1 = firstbuf->b_fnum;
073263
  			ea.line2 = lastbuf->b_fnum;
073263
  			break;
073263
  		    case ADDR_WINDOWS:
073263
  		    case ADDR_TABS:
073263
! 			if (IS_USER_CMDIDX(ea.cmdidx))
073263
! 			{
073263
! 			    ea.line1 = 1;
073263
! 			    ea.line2 = ea.addr_type == ADDR_WINDOWS
073263
! 						  ? LAST_WIN_NR : LAST_TAB_NR;
073263
! 			}
073263
! 			else
073263
! 			{
073263
! 			    /* there is no Vim command which uses '%' and
073263
! 			     * ADDR_WINDOWS or ADDR_TABS */
073263
! 			    errormsg = (char_u *)_(e_invrange);
073263
! 			    goto doend;
073263
! 			}
073263
  			break;
073263
  		    case ADDR_ARGUMENTS:
073263
! 			if (ARGCOUNT == 0)
073263
! 			    ea.line1 = ea.line2 = 0;
073263
! 			else
073263
! 			{
073263
! 			    ea.line1 = 1;
073263
! 			    ea.line2 = ARGCOUNT;
073263
! 			}
073263
  			break;
073263
  		}
073263
  		++ea.addr_count;
073263
***************
073263
*** 2629,2636 ****
073263
  
073263
      if ((ea.argt & DFLALL) && ea.addr_count == 0)
073263
      {
073263
  	ea.line1 = 1;
073263
! 	ea.line2 = curbuf->b_ml.ml_line_count;
073263
      }
073263
  
073263
      /* accept numbered register only when no count allowed (:put) */
073263
--- 2650,2690 ----
073263
  
073263
      if ((ea.argt & DFLALL) && ea.addr_count == 0)
073263
      {
073263
+ 	buf_T	    *buf;
073263
+ 
073263
  	ea.line1 = 1;
073263
! 	switch (ea.addr_type)
073263
! 	{
073263
! 	    case ADDR_LINES:
073263
! 		ea.line2 = curbuf->b_ml.ml_line_count;
073263
! 		break;
073263
! 	    case ADDR_LOADED_BUFFERS:
073263
! 		buf = firstbuf;
073263
! 		while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL)
073263
! 		    buf = buf->b_next;
073263
! 		ea.line1 = buf->b_fnum;
073263
! 		buf = lastbuf;
073263
! 		while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL)
073263
! 		    buf = buf->b_prev;
073263
! 		ea.line2 = buf->b_fnum;
073263
! 		break;
073263
! 	    case ADDR_BUFFERS:
073263
! 		ea.line1 = firstbuf->b_fnum;
073263
! 		ea.line2 = lastbuf->b_fnum;
073263
! 		break;
073263
! 	    case ADDR_WINDOWS:
073263
! 		ea.line2 = LAST_WIN_NR;
073263
! 		break;
073263
! 	    case ADDR_TABS:
073263
! 		ea.line2 = LAST_TAB_NR;
073263
! 		break;
073263
! 	    case ADDR_ARGUMENTS:
073263
! 		if (ARGCOUNT == 0)
073263
! 		    ea.line1 = ea.line2 = 0;
073263
! 		else
073263
! 		    ea.line2 = ARGCOUNT;
073263
! 		break;
073263
! 	}
073263
      }
073263
  
073263
      /* accept numbered register only when no count allowed (:put) */
073263
***************
073263
*** 3211,3216 ****
073263
--- 3265,3271 ----
073263
  			eap->cmdidx = CMD_USER_BUF;
073263
  		    eap->argt = (long)uc->uc_argt;
073263
  		    eap->useridx = j;
073263
+ 		    eap->addr_type = uc->uc_addr_type;
073263
  
073263
  # ifdef FEAT_CMDL_COMPL
073263
  		    if (compl != NULL)
073263
***************
073263
*** 3839,3845 ****
073263
  			return NULL;
073263
  		    }
073263
  
073263
! 		    /* For the -complete and -nargs attributes, we complete
073263
  		     * their arguments as well.
073263
  		     */
073263
  		    if (STRNICMP(arg, "complete", p - arg) == 0)
073263
--- 3894,3900 ----
073263
  			return NULL;
073263
  		    }
073263
  
073263
! 		    /* For the -complete, -nargs and -addr attributes, we complete
073263
  		     * their arguments as well.
073263
  		     */
073263
  		    if (STRNICMP(arg, "complete", p - arg) == 0)
073263
***************
073263
*** 3854,3859 ****
073263
--- 3909,3920 ----
073263
  			xp->xp_pattern = p + 1;
073263
  			return NULL;
073263
  		    }
073263
+ 		    else if (STRNICMP(arg, "addr", p - arg) == 0)
073263
+ 		    {
073263
+ 			xp->xp_context = EXPAND_USER_ADDR_TYPE;
073263
+ 			xp->xp_pattern = p + 1;
073263
+ 			return NULL;
073263
+ 		    }
073263
  		    return NULL;
073263
  		}
073263
  		arg = skipwhite(p);
073263
***************
073263
*** 4264,4269 ****
073263
--- 4325,4331 ----
073263
      pos_T	pos;
073263
      pos_T	*fp;
073263
      linenr_T	lnum;
073263
+     buf_T	*buf;
073263
  
073263
      cmd = skipwhite(*ptr);
073263
      lnum = MAXLNUM;
073263
***************
073263
*** 4285,4291 ****
073263
  			lnum = curwin->w_arg_idx + 1;
073263
  			break;
073263
  		    case ADDR_LOADED_BUFFERS:
073263
! 		    case ADDR_UNLOADED_BUFFERS:
073263
  			lnum = curbuf->b_fnum;
073263
  			break;
073263
  		    case ADDR_TABS:
073263
--- 4347,4353 ----
073263
  			lnum = curwin->w_arg_idx + 1;
073263
  			break;
073263
  		    case ADDR_LOADED_BUFFERS:
073263
! 		    case ADDR_BUFFERS:
073263
  			lnum = curbuf->b_fnum;
073263
  			break;
073263
  		    case ADDR_TABS:
073263
***************
073263
*** 4308,4314 ****
073263
  			lnum = ARGCOUNT;
073263
  			break;
073263
  		    case ADDR_LOADED_BUFFERS:
073263
! 		    case ADDR_UNLOADED_BUFFERS:
073263
  			lnum = lastbuf->b_fnum;
073263
  			break;
073263
  		    case ADDR_TABS:
073263
--- 4370,4385 ----
073263
  			lnum = ARGCOUNT;
073263
  			break;
073263
  		    case ADDR_LOADED_BUFFERS:
073263
! 			buf = lastbuf;
073263
! 			while (buf->b_ml.ml_mfp == NULL)
073263
! 			{
073263
! 			    if (buf->b_prev == NULL)
073263
! 				break;
073263
! 			    buf = buf->b_prev;
073263
! 			}
073263
! 			lnum = buf->b_fnum;
073263
! 			break;
073263
! 		    case ADDR_BUFFERS:
073263
  			lnum = lastbuf->b_fnum;
073263
  			break;
073263
  		    case ADDR_TABS:
073263
***************
073263
*** 4477,4483 ****
073263
  			lnum = curwin->w_arg_idx + 1;
073263
  			break;
073263
  		    case ADDR_LOADED_BUFFERS:
073263
! 		    case ADDR_UNLOADED_BUFFERS:
073263
  			lnum = curbuf->b_fnum;
073263
  			break;
073263
  		    case ADDR_TABS:
073263
--- 4548,4554 ----
073263
  			lnum = curwin->w_arg_idx + 1;
073263
  			break;
073263
  		    case ADDR_LOADED_BUFFERS:
073263
! 		    case ADDR_BUFFERS:
073263
  			lnum = curbuf->b_fnum;
073263
  			break;
073263
  		    case ADDR_TABS:
073263
***************
073263
*** 4495,4501 ****
073263
  	    else
073263
  		n = getdigits(&cmd);
073263
  	    if (addr_type == ADDR_LOADED_BUFFERS
073263
! 		    || addr_type == ADDR_UNLOADED_BUFFERS)
073263
  		lnum = compute_buffer_local_count(addr_type, lnum, (i == '-') ? -1 * n : n);
073263
  	    else if (i == '-')
073263
  		lnum -= n;
073263
--- 4566,4572 ----
073263
  	    else
073263
  		n = getdigits(&cmd);
073263
  	    if (addr_type == ADDR_LOADED_BUFFERS
073263
! 		    || addr_type == ADDR_BUFFERS)
073263
  		lnum = compute_buffer_local_count(addr_type, lnum, (i == '-') ? -1 * n : n);
073263
  	    else if (i == '-')
073263
  		lnum -= n;
073263
***************
073263
*** 4531,4537 ****
073263
  			lnum = LAST_WIN_NR;
073263
  		    break;
073263
  		case ADDR_LOADED_BUFFERS:
073263
! 		case ADDR_UNLOADED_BUFFERS:
073263
  		    if (lnum < firstbuf->b_fnum)
073263
  		    {
073263
  			lnum = firstbuf->b_fnum;
073263
--- 4602,4608 ----
073263
  			lnum = LAST_WIN_NR;
073263
  		    break;
073263
  		case ADDR_LOADED_BUFFERS:
073263
! 		case ADDR_BUFFERS:
073263
  		    if (lnum < firstbuf->b_fnum)
073263
  		    {
073263
  			lnum = firstbuf->b_fnum;
073263
***************
073263
*** 5585,5598 ****
073263
  #endif
073263
  
073263
  #if defined(FEAT_USR_CMDS) || defined(PROTO)
073263
! static int	uc_add_command __ARGS((char_u *name, size_t name_len, char_u *rep, long argt, long def, int flags, int compl, char_u *compl_arg, int force));
073263
  static void	uc_list __ARGS((char_u *name, size_t name_len));
073263
! static int	uc_scan_attr __ARGS((char_u *attr, size_t len, long *argt, long *def, int *flags, int *compl, char_u **compl_arg));
073263
  static char_u	*uc_split_args __ARGS((char_u *arg, size_t *lenp));
073263
  static size_t	uc_check_code __ARGS((char_u *code, size_t len, char_u *buf, ucmd_T *cmd, exarg_T *eap, char_u **split_buf, size_t *split_len));
073263
  
073263
      static int
073263
! uc_add_command(name, name_len, rep, argt, def, flags, compl, compl_arg, force)
073263
      char_u	*name;
073263
      size_t	name_len;
073263
      char_u	*rep;
073263
--- 5656,5669 ----
073263
  #endif
073263
  
073263
  #if defined(FEAT_USR_CMDS) || defined(PROTO)
073263
! static int	uc_add_command __ARGS((char_u *name, size_t name_len, char_u *rep, long argt, long def, int flags, int compl, char_u *compl_arg, int addr_type, int force));
073263
  static void	uc_list __ARGS((char_u *name, size_t name_len));
073263
! static int	uc_scan_attr __ARGS((char_u *attr, size_t len, long *argt, long *def, int *flags, int *compl, char_u **compl_arg, int* attr_type_arg));
073263
  static char_u	*uc_split_args __ARGS((char_u *arg, size_t *lenp));
073263
  static size_t	uc_check_code __ARGS((char_u *code, size_t len, char_u *buf, ucmd_T *cmd, exarg_T *eap, char_u **split_buf, size_t *split_len));
073263
  
073263
      static int
073263
! uc_add_command(name, name_len, rep, argt, def, flags, compl, compl_arg, addr_type, force)
073263
      char_u	*name;
073263
      size_t	name_len;
073263
      char_u	*rep;
073263
***************
073263
*** 5601,5606 ****
073263
--- 5672,5678 ----
073263
      int		flags;
073263
      int		compl;
073263
      char_u	*compl_arg;
073263
+     int		addr_type;
073263
      int		force;
073263
  {
073263
      ucmd_T	*cmd = NULL;
073263
***************
073263
*** 5695,5700 ****
073263
--- 5767,5773 ----
073263
      cmd->uc_compl_arg = compl_arg;
073263
  # endif
073263
  #endif
073263
+     cmd->uc_addr_type = addr_type;
073263
  
073263
      return OK;
073263
  
073263
***************
073263
*** 5707,5712 ****
073263
--- 5780,5802 ----
073263
  }
073263
  #endif
073263
  
073263
+ #if defined(FEAT_USR_CMDS)
073263
+ static struct
073263
+ {
073263
+     int	    expand;
073263
+     char    *name;
073263
+ } addr_type_complete[] =
073263
+ {
073263
+     {ADDR_ARGUMENTS, "arguments"},
073263
+     {ADDR_LINES, "lines"},
073263
+     {ADDR_LOADED_BUFFERS, "loaded_buffers"},
073263
+     {ADDR_TABS, "tabs"},
073263
+     {ADDR_BUFFERS, "buffers"},
073263
+     {ADDR_WINDOWS, "windows"},
073263
+     {-1, NULL}
073263
+ };
073263
+ #endif
073263
+ 
073263
  #if defined(FEAT_USR_CMDS) || defined(FEAT_EVAL) || defined(PROTO)
073263
  /*
073263
   * List of names for completion for ":command" with the EXPAND_ flag.
073263
***************
073263
*** 5794,5800 ****
073263
  
073263
  	    /* Put out the title first time */
073263
  	    if (!found)
073263
! 		MSG_PUTS_TITLE(_("\n    Name        Args Range Complete  Definition"));
073263
  	    found = TRUE;
073263
  	    msg_putchar('\n');
073263
  	    if (got_int)
073263
--- 5884,5890 ----
073263
  
073263
  	    /* Put out the title first time */
073263
  	    if (!found)
073263
! 		MSG_PUTS_TITLE(_("\n    Name        Args       Address   Complete  Definition"));
073263
  	    found = TRUE;
073263
  	    msg_putchar('\n');
073263
  	    if (got_int)
073263
***************
073263
*** 5855,5860 ****
073263
--- 5945,5964 ----
073263
  		IObuff[len++] = ' ';
073263
  	    } while (len < 11);
073263
  
073263
+ 	    /* Address Type */
073263
+ 	    for (j = 0; addr_type_complete[j].expand != -1; ++j)
073263
+ 		if (addr_type_complete[j].expand != ADDR_LINES
073263
+ 			&& addr_type_complete[j].expand == cmd->uc_addr_type)
073263
+ 		{
073263
+ 		    STRCPY(IObuff + len, addr_type_complete[j].name);
073263
+ 		    len += (int)STRLEN(IObuff + len);
073263
+ 		    break;
073263
+ 		}
073263
+ 
073263
+ 	    do {
073263
+ 		IObuff[len++] = ' ';
073263
+ 	    } while (len < 21);
073263
+ 
073263
  	    /* Completion */
073263
  	    for (j = 0; command_complete[j].expand != 0; ++j)
073263
  		if (command_complete[j].expand == cmd->uc_compl)
073263
***************
073263
*** 5866,5872 ****
073263
  
073263
  	    do {
073263
  		IObuff[len++] = ' ';
073263
! 	    } while (len < 21);
073263
  
073263
  	    IObuff[len] = '\0';
073263
  	    msg_outtrans(IObuff);
073263
--- 5970,5976 ----
073263
  
073263
  	    do {
073263
  		IObuff[len++] = ' ';
073263
! 	    } while (len < 35);
073263
  
073263
  	    IObuff[len] = '\0';
073263
  	    msg_outtrans(IObuff);
073263
***************
073263
*** 5906,5912 ****
073263
  }
073263
  
073263
      static int
073263
! uc_scan_attr(attr, len, argt, def, flags, compl, compl_arg)
073263
      char_u	*attr;
073263
      size_t	len;
073263
      long	*argt;
073263
--- 6010,6016 ----
073263
  }
073263
  
073263
      static int
073263
! uc_scan_attr(attr, len, argt, def, flags, compl, compl_arg, addr_type_arg)
073263
      char_u	*attr;
073263
      size_t	len;
073263
      long	*argt;
073263
***************
073263
*** 5914,5919 ****
073263
--- 6018,6024 ----
073263
      int		*flags;
073263
      int		*compl;
073263
      char_u	**compl_arg;
073263
+     int		*addr_type_arg;
073263
  {
073263
      char_u	*p;
073263
  
073263
***************
073263
*** 6032,6037 ****
073263
--- 6137,6156 ----
073263
  								      == FAIL)
073263
  		return FAIL;
073263
  	}
073263
+ 	else if (STRNICMP(attr, "addr", attrlen) == 0)
073263
+ 	{
073263
+ 	    *argt |= RANGE;
073263
+ 	    if (val == NULL)
073263
+ 	    {
073263
+ 		EMSG(_("E179: argument required for -addr"));
073263
+ 		return FAIL;
073263
+ 	    }
073263
+ 	    if (parse_addr_type_arg(val, (int)vallen, argt, addr_type_arg)
073263
+ 								      == FAIL)
073263
+ 		return FAIL;
073263
+ 	    if (addr_type_arg != ADDR_LINES)
073263
+ 		*argt |= (ZEROR | NOTADR) ;
073263
+ 	}
073263
  	else
073263
  	{
073263
  	    char_u ch = attr[len];
073263
***************
073263
*** 6060,6065 ****
073263
--- 6179,6185 ----
073263
      int	    flags = 0;
073263
      int	    compl = EXPAND_NOTHING;
073263
      char_u  *compl_arg = NULL;
073263
+     int	    addr_type_arg = ADDR_LINES;
073263
      int	    has_attr = (eap->arg[0] == '-');
073263
      int	    name_len;
073263
  
073263
***************
073263
*** 6070,6076 ****
073263
      {
073263
  	++p;
073263
  	end = skiptowhite(p);
073263
! 	if (uc_scan_attr(p, end - p, &argt, &def, &flags, &compl, &compl_arg)
073263
  		== FAIL)
073263
  	    return;
073263
  	p = skipwhite(end);
073263
--- 6190,6196 ----
073263
      {
073263
  	++p;
073263
  	end = skiptowhite(p);
073263
! 	if (uc_scan_attr(p, end - p, &argt, &def, &flags, &compl, &compl_arg, &addr_type_arg)
073263
  		== FAIL)
073263
  	    return;
073263
  	p = skipwhite(end);
073263
***************
073263
*** 6111,6117 ****
073263
      }
073263
      else
073263
  	uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
073263
! 								eap->forceit);
073263
  }
073263
  
073263
  /*
073263
--- 6231,6237 ----
073263
      }
073263
      else
073263
  	uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
073263
! 								addr_type_arg, eap->forceit);
073263
  }
073263
  
073263
  /*
073263
***************
073263
*** 6652,6657 ****
073263
--- 6772,6788 ----
073263
  }
073263
  
073263
  /*
073263
+  * Function given to ExpandGeneric() to obtain the list of user address type names.
073263
+  */
073263
+     char_u *
073263
+ get_user_cmd_addr_type(xp, idx)
073263
+     expand_T	*xp UNUSED;
073263
+     int		idx;
073263
+ {
073263
+     return (char_u *)addr_type_complete[idx].name;
073263
+ }
073263
+ 
073263
+ /*
073263
   * Function given to ExpandGeneric() to obtain the list of user command
073263
   * attributes.
073263
   */
073263
***************
073263
*** 6661,6668 ****
073263
      int		idx;
073263
  {
073263
      static char *user_cmd_flags[] =
073263
! 	{"bang", "bar", "buffer", "complete", "count",
073263
! 	    "nargs", "range", "register"};
073263
  
073263
      if (idx >= (int)(sizeof(user_cmd_flags) / sizeof(user_cmd_flags[0])))
073263
  	return NULL;
073263
--- 6792,6799 ----
073263
      int		idx;
073263
  {
073263
      static char *user_cmd_flags[] =
073263
! 	{"addr", "bang", "bar", "buffer", "complete",
073263
! 	    "count", "nargs", "range", "register"};
073263
  
073263
      if (idx >= (int)(sizeof(user_cmd_flags) / sizeof(user_cmd_flags[0])))
073263
  	return NULL;
073263
***************
073263
*** 6696,6701 ****
073263
--- 6827,6869 ----
073263
  }
073263
  # endif /* FEAT_CMDL_COMPL */
073263
  
073263
+ /*
073263
+  * Parse address type argument
073263
+  */
073263
+     int
073263
+ parse_addr_type_arg(value, vallen, argt, addr_type_arg)
073263
+     char_u	*value;
073263
+     int		vallen;
073263
+     long	*argt;
073263
+     int		*addr_type_arg;
073263
+ {
073263
+     int	    i, a, b;
073263
+     for (i = 0; addr_type_complete[i].expand != -1; ++i)
073263
+     {
073263
+ 	a = (int)STRLEN(addr_type_complete[i].name) == vallen;
073263
+ 	b = STRNCMP(value, addr_type_complete[i].name, vallen) == 0;
073263
+ 	if (a && b)
073263
+ 	{
073263
+ 	    *addr_type_arg = addr_type_complete[i].expand;
073263
+ 	    break;
073263
+ 	}
073263
+     }
073263
+ 
073263
+     if (addr_type_complete[i].expand == -1)
073263
+     {
073263
+ 	char_u	*err = value;
073263
+ 	for (i=0; err[i] == NUL || !vim_iswhite(err[i]); i++);
073263
+ 	err[i] = NUL;
073263
+ 	EMSG2(_("E180: Invalid address type value: %s"), err);
073263
+ 	return FAIL;
073263
+     }
073263
+ 
073263
+     if (*addr_type_arg != ADDR_LINES)
073263
+ 	*argt |= NOTADR;
073263
+ 
073263
+     return OK;
073263
+ }
073263
+ 
073263
  #endif	/* FEAT_USR_CMDS */
073263
  
073263
  #if defined(FEAT_USR_CMDS) || defined(FEAT_EVAL) || defined(PROTO)
073263
*** ../vim-7.4.541/src/ex_getln.c	2014-09-09 18:45:45.884551705 +0200
073263
--- src/ex_getln.c	2014-12-08 03:30:59.286867854 +0100
073263
***************
073263
*** 4697,4702 ****
073263
--- 4697,4703 ----
073263
  #endif
073263
  #ifdef FEAT_USR_CMDS
073263
  	    {EXPAND_USER_COMMANDS, get_user_commands, FALSE, TRUE},
073263
+ 	    {EXPAND_USER_ADDR_TYPE, get_user_cmd_addr_type, FALSE, TRUE},
073263
  	    {EXPAND_USER_CMD_FLAGS, get_user_cmd_flags, FALSE, TRUE},
073263
  	    {EXPAND_USER_NARGS, get_user_cmd_nargs, FALSE, TRUE},
073263
  	    {EXPAND_USER_COMPLETE, get_user_cmd_complete, FALSE, TRUE},
073263
*** ../vim-7.4.541/src/proto/ex_docmd.pro	2014-04-01 17:49:40.140891378 +0200
073263
--- src/proto/ex_docmd.pro	2014-12-08 03:55:53.314888997 +0100
073263
***************
073263
*** 19,27 ****
073263
--- 19,29 ----
073263
  void ex_comclear __ARGS((exarg_T *eap));
073263
  void uc_clear __ARGS((garray_T *gap));
073263
  char_u *get_user_commands __ARGS((expand_T *xp, int idx));
073263
+ char_u *get_user_cmd_addr_type __ARGS((expand_T *xp, int idx));
073263
  char_u *get_user_cmd_flags __ARGS((expand_T *xp, int idx));
073263
  char_u *get_user_cmd_nargs __ARGS((expand_T *xp, int idx));
073263
  char_u *get_user_cmd_complete __ARGS((expand_T *xp, int idx));
073263
+ int parse_addr_type_arg __ARGS((char_u *value, int vallen, long *argt, int *addr_type_arg));
073263
  int parse_compl_arg __ARGS((char_u *value, int vallen, int *complp, long *argt, char_u **compl_arg));
073263
  void not_exiting __ARGS((void));
073263
  void tabpage_close __ARGS((int forceit));
073263
***************
073263
*** 43,48 ****
073263
--- 45,51 ----
073263
  void post_chdir __ARGS((int local));
073263
  void ex_cd __ARGS((exarg_T *eap));
073263
  void do_sleep __ARGS((long msec));
073263
+ void ex_may_print __ARGS((exarg_T *eap));
073263
  int vim_mkdir_emsg __ARGS((char_u *name, int prot));
073263
  FILE *open_exfile __ARGS((char_u *fname, int forceit, char *mode));
073263
  void update_topline_cursor __ARGS((void));
073263
***************
073263
*** 54,58 ****
073263
  int put_line __ARGS((FILE *fd, char *s));
073263
  void dialog_msg __ARGS((char_u *buff, char *format, char_u *fname));
073263
  char_u *get_behave_arg __ARGS((expand_T *xp, int idx));
073263
- void ex_may_print __ARGS((exarg_T *eap));
073263
  /* vim: set ft=c : */
073263
--- 57,60 ----
073263
*** ../vim-7.4.541/src/vim.h	2014-11-27 19:14:45.080940970 +0100
073263
--- src/vim.h	2014-12-08 03:30:59.290867811 +0100
073263
***************
073263
*** 798,803 ****
073263
--- 798,804 ----
073263
  #define EXPAND_HISTORY		41
073263
  #define EXPAND_USER		42
073263
  #define EXPAND_SYNTIME		43
073263
+ #define EXPAND_USER_ADDR_TYPE	44
073263
  
073263
  /* Values for exmode_active (0 is no exmode) */
073263
  #define EXMODE_NORMAL		1
073263
*** ../vim-7.4.541/src/version.c	2014-12-07 00:18:27.528202992 +0100
073263
--- src/version.c	2014-12-08 03:32:08.402128425 +0100
073263
***************
073263
*** 743,744 ****
073263
--- 743,746 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     542,
073263
  /**/
073263
073263
-- 
073263
CRONE:  Who sent you?
073263
ARTHUR: The Knights Who Say GNU!
073263
CRONE:  Aaaagh!  (she looks around in rear) No!  We have no licenses here.
073263
           "Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///