Dear Bram,

I wrote a patch to reuse an argument list from different window.
I think it is useful to have a way of setting an argument list from
a different window [tab page].  One scenario where it is useful is when
a window has global argument list and one makes a ':split|argl' and
after a while one would like to reuse the new local argument list somewhere
else.  With the attached patch one can:

:call usearglist({winnr} [, {tabnr}])

to use the argument list from window number {winnr} (in tab page
{tabnr}) in the current window.

The function returns 0 on success and -1 on error (window or tab page not
found).

Thanks for reviewing the patch,
Marcin Szamotulski
diff -r cf43c4c44e7a runtime/doc/eval.txt
--- a/runtime/doc/eval.txt	Tue Jul 29 10:15:21 2014 +0100
+++ b/runtime/doc/eval.txt	Tue Jul 29 12:27:19 2014 +0100
@@ -6362,6 +6362,11 @@
 <		The default compare function uses the string representation of
 		each item.  For the use of {func} and {dict} see |sort()|.
 
+usearglist({winnr} [, {tabnr}])				*usearglist()*
+		Use the argument list of window number {winnr} in the current
+		window.  If {tabnr} is given use the {winnr} from the given
+		tabpage.
+
 values({dict})						*values()*
 		Return a |List| with all the values of {dict}.	The |List| is
 		in arbitrary order.
diff -r cf43c4c44e7a src/eval.c
--- a/src/eval.c	Tue Jul 29 10:15:21 2014 +0100
+++ b/src/eval.c	Tue Jul 29 12:27:19 2014 +0100
@@ -754,6 +754,7 @@
 static void f_undofile __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_undotree __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_uniq __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_usearglist __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_values __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_virtcol __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_visualmode __ARGS((typval_T *argvars, typval_T *rettv));
@@ -8187,6 +8188,7 @@
     {"undofile",	1, 1, f_undofile},
     {"undotree",	0, 0, f_undotree},
     {"uniq",		1, 3, f_uniq},
+    {"usearglist",	1, 2, f_usearglist},
     {"values",		1, 1, f_values},
     {"virtcol",		1, 1, f_virtcol},
     {"visualmode",	0, 1, f_visualmode},
@@ -17629,6 +17631,42 @@
 }
 
 /*
+ * "usearglist(winnr [, tabnr])" function
+ */
+    static void
+f_usearglist(argvars, rettv)
+    typval_T	*argvars;
+    typval_T	*rettv;
+{
+    win_T	*wp;
+    tabpage_T	*tp = NULL;
+    long	n;
+
+    if (argvars[1].v_type != VAR_UNKNOWN) {
+	n = get_tv_number(&argvars[1]);
+	if (n >= 0)
+	    tp = find_tabpage(n);
+    }
+    else
+	tp = curtab;
+
+    if (tp == NULL) {
+	rettv->vval.v_number = -1;
+	return;
+    }
+
+    wp = find_win_by_nr(&argvars[0], tp);
+    if (wp == NULL) {
+	rettv->vval.v_number = -1;
+	return;
+    }
+    alist_unlink(ALIST(curwin));
+    curwin->w_alist = wp->w_alist;
+    ++curwin->w_alist->al_refcount;
+    rettv->vval.v_number = 0;
+}
+
+/*
  * "soundfold({word})" function
  */
     static void

Attachment: signature.asc
Description: Digital signature

Raspunde prin e-mail lui