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