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