jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone
073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.312
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.312
073263
Problem:    Cannot figure out what argument list is being used for a window.
073263
Solution:   Add the arglistid() function. (Marcin Szamotulski)
073263
Files:	    runtime/doc/eval.txt, runtime/doc/usr_41.txt, src/eval.c,
073263
	    src/ex_docmd.c, src/globals.h, src/structs.h, src/main.c
073263
073263
073263
*** ../vim-7.4.311/runtime/doc/eval.txt	2014-05-28 16:47:11.396174926 +0200
073263
--- runtime/doc/eval.txt	2014-05-28 18:00:06.248213223 +0200
073263
***************
073263
*** 1716,1721 ****
073263
--- 1716,1723 ----
073263
  append( {lnum}, {list})		Number	append lines {list} below line {lnum}
073263
  argc()				Number	number of files in the argument list
073263
  argidx()			Number	current index in the argument list
073263
+ arglistid( [{winnr}, [ {tabnr}]])
073263
+ 				Number	argument list id
073263
  argv( {nr})			String	{nr} entry of the argument list
073263
  argv( )				List	the argument list
073263
  asin( {expr})			Float	arc sine of {expr}
073263
***************
073263
*** 2103,2108 ****
073263
--- 2105,2122 ----
073263
  argidx()	The result is the current index in the argument list.  0 is
073263
  		the first file.  argc() - 1 is the last one.  See |arglist|.
073263
  
073263
+ 							*arglistid()*
073263
+ arglistid([{winnr}, [ {tabnr} ]])
073263
+ 		Return the argument list ID.  This is a number which
073263
+ 		identifies the argument list being used.  Zero is used for the
073263
+ 		global argument list.
073263
+ 		Return zero if the arguments are invalid.
073263
+ 
073263
+ 		Without arguments use the current window.
073263
+ 		With {winnr} only use this window in the current tab page.
073263
+ 		With {winnr} and {tabnr} use the window in the specified tab
073263
+ 		page.
073263
+ 
073263
  							*argv()*
073263
  argv([{nr}])	The result is the {nr}th file in the argument list of the
073263
  		current window.  See |arglist|.  "argv(0)" is the first one.
073263
*** ../vim-7.4.311/runtime/doc/usr_41.txt	2014-03-25 18:23:27.054087691 +0100
073263
--- runtime/doc/usr_41.txt	2014-05-28 18:07:43.096217222 +0200
073263
***************
073263
*** 770,775 ****
073263
--- 772,778 ----
073263
  Buffers, windows and the argument list:
073263
  	argc()			number of entries in the argument list
073263
  	argidx()		current position in the argument list
073263
+ 	arglistid()		get id of the argument list
073263
  	argv()			get one entry from the argument list
073263
  	bufexists()		check if a buffer exists
073263
  	buflisted()		check if a buffer exists and is listed
073263
*** ../vim-7.4.311/src/eval.c	2014-05-28 16:47:11.392174926 +0200
073263
--- src/eval.c	2014-05-28 18:11:10.264219035 +0200
073263
***************
073263
*** 463,468 ****
073263
--- 463,469 ----
073263
  static void f_append __ARGS((typval_T *argvars, typval_T *rettv));
073263
  static void f_argc __ARGS((typval_T *argvars, typval_T *rettv));
073263
  static void f_argidx __ARGS((typval_T *argvars, typval_T *rettv));
073263
+ static void f_arglistid __ARGS((typval_T *argvars, typval_T *rettv));
073263
  static void f_argv __ARGS((typval_T *argvars, typval_T *rettv));
073263
  #ifdef FEAT_FLOAT
073263
  static void f_asin __ARGS((typval_T *argvars, typval_T *rettv));
073263
***************
073263
*** 7875,7880 ****
073263
--- 7876,7882 ----
073263
      {"append",		2, 2, f_append},
073263
      {"argc",		0, 0, f_argc},
073263
      {"argidx",		0, 0, f_argidx},
073263
+     {"arglistid",	0, 2, f_arglistid},
073263
      {"argv",		0, 1, f_argv},
073263
  #ifdef FEAT_FLOAT
073263
      {"asin",		1, 1, f_asin},	/* WJMc */
073263
***************
073263
*** 8859,8864 ****
073263
--- 8861,8901 ----
073263
  }
073263
  
073263
  /*
073263
+  * "arglistid()" function
073263
+  */
073263
+     static void
073263
+ f_arglistid(argvars, rettv)
073263
+     typval_T	*argvars UNUSED;
073263
+     typval_T	*rettv;
073263
+ {
073263
+     win_T	*wp;
073263
+     tabpage_T	*tp = NULL;
073263
+     long	n;
073263
+ 
073263
+     rettv->vval.v_number = -1;
073263
+     if (argvars[0].v_type != VAR_UNKNOWN)
073263
+     {
073263
+ 	if (argvars[1].v_type != VAR_UNKNOWN)
073263
+ 	{
073263
+ 	    n = get_tv_number(&argvars[1]);
073263
+ 	    if (n >= 0)
073263
+ 		tp = find_tabpage(n);
073263
+ 	}
073263
+ 	else
073263
+ 	    tp = curtab;
073263
+ 
073263
+ 	if (tp != NULL)
073263
+ 	{
073263
+ 	    wp = find_win_by_nr(&argvars[0], tp);
073263
+ 	    if (wp != NULL)
073263
+ 		rettv->vval.v_number = wp->w_alist->id;
073263
+ 	}
073263
+     }
073263
+     else
073263
+ 	rettv->vval.v_number = curwin->w_alist->id;
073263
+ }
073263
+ 
073263
+ /*
073263
   * "argv(nr)" function
073263
   */
073263
      static void
073263
*** ../vim-7.4.311/src/ex_docmd.c	2014-05-07 21:14:42.913299714 +0200
073263
--- src/ex_docmd.c	2014-05-28 18:10:01.696218435 +0200
073263
***************
073263
*** 7211,7216 ****
073263
--- 7211,7217 ----
073263
      else
073263
      {
073263
  	curwin->w_alist->al_refcount = 1;
073263
+ 	curwin->w_alist->id = ++max_alist_id;
073263
  	alist_init(curwin->w_alist);
073263
      }
073263
  }
073263
*** ../vim-7.4.311/src/globals.h	2014-05-22 18:14:27.570224664 +0200
073263
--- src/globals.h	2014-05-28 17:56:53.392211534 +0200
073263
***************
073263
*** 601,606 ****
073263
--- 601,607 ----
073263
   * to this when the window is using the global argument list.
073263
   */
073263
  EXTERN alist_T	global_alist;	/* global argument list */
073263
+ EXTERN int	max_alist_id INIT(= 0);	    /* the previous argument list id */
073263
  EXTERN int	arg_had_last INIT(= FALSE); /* accessed last file in
073263
  					       global_alist */
073263
  
073263
*** ../vim-7.4.311/src/structs.h	2014-05-13 20:19:53.573808877 +0200
073263
--- src/structs.h	2014-05-28 17:54:18.312210177 +0200
073263
***************
073263
*** 675,680 ****
073263
--- 675,681 ----
073263
  {
073263
      garray_T	al_ga;		/* growarray with the array of file names */
073263
      int		al_refcount;	/* number of windows using this arglist */
073263
+     int		id;		/* id of this arglist */
073263
  } alist_T;
073263
  
073263
  /*
073263
*** ../vim-7.4.311/src/main.c	2014-04-01 19:55:46.252787300 +0200
073263
--- src/main.c	2014-05-28 18:09:32.040218175 +0200
073263
***************
073263
*** 322,327 ****
073263
--- 322,328 ----
073263
      init_yank();		/* init yank buffers */
073263
  
073263
      alist_init(&global_alist);	/* Init the argument list to empty. */
073263
+     global_alist.id = 0;
073263
  
073263
      /*
073263
       * Set the default values for the options.
073263
*** ../vim-7.4.311/src/version.c	2014-05-28 16:47:11.396174926 +0200
073263
--- src/version.c	2014-05-28 17:25:32.644195071 +0200
073263
***************
073263
*** 736,737 ****
073263
--- 736,739 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     312,
073263
  /**/
073263
073263
-- 
073263
hundred-and-one symptoms of being an internet addict:
073263
222. You send more than 20 personal e-mails a day.
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    ///