]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.312 v7.4.312
authorBram Moolenaar <Bram@vim.org>
Wed, 28 May 2014 16:22:57 +0000 (18:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 28 May 2014 16:22:57 +0000 (18:22 +0200)
Problem:    Cannot figure out what argument list is being used for a window.
Solution:   Add the arglistid() function. (Marcin Szamotulski)

runtime/doc/eval.txt
runtime/doc/usr_41.txt
src/eval.c
src/ex_docmd.c
src/globals.h
src/main.c
src/structs.h
src/version.c

index 09a081703576c3d307383735a10b264740be9abb..b51770bfaa4356fde2df3c8c002c6fc3bb736820 100644 (file)
@@ -1716,6 +1716,8 @@ append( {lnum}, {string}) Number  append {string} below line {lnum}
 append( {lnum}, {list})                Number  append lines {list} below line {lnum}
 argc()                         Number  number of files in the argument list
 argidx()                       Number  current index in the argument list
+arglistid( [{winnr}, [ {tabnr}]])
+                               Number  argument list id
 argv( {nr})                    String  {nr} entry of the argument list
 argv( )                                List    the argument list
 asin( {expr})                  Float   arc sine of {expr}
@@ -2103,6 +2105,18 @@ argc()           The result is the number of files in the argument list of the
 argidx()       The result is the current index in the argument list.  0 is
                the first file.  argc() - 1 is the last one.  See |arglist|.
 
+                                                       *arglistid()*
+arglistid([{winnr}, [ {tabnr} ]])
+               Return the argument list ID.  This is a number which
+               identifies the argument list being used.  Zero is used for the
+               global argument list.
+               Return zero if the arguments are invalid.
+
+               Without arguments use the current window.
+               With {winnr} only use this window in the current tab page.
+               With {winnr} and {tabnr} use the window in the specified tab
+               page.
+
                                                        *argv()*
 argv([{nr}])   The result is the {nr}th file in the argument list of the
                current window.  See |arglist|.  "argv(0)" is the first one.
index 670c8fdc7c7d057e8b0422389e515ced945db55e..ee62cac70888f244f6de3d76cfff79e4994126da 100644 (file)
@@ -772,6 +772,7 @@ Date and Time:                              *date-functions* *time-functions*
 Buffers, windows and the argument list:
        argc()                  number of entries in the argument list
        argidx()                current position in the argument list
+       arglistid()             get id of the argument list
        argv()                  get one entry from the argument list
        bufexists()             check if a buffer exists
        buflisted()             check if a buffer exists and is listed
index d313c5d03067fcb23020c2786fece3761e7c957e..0e9ec9ed0ae7df7655601eeabc42870a3b3c693d 100644 (file)
@@ -463,6 +463,7 @@ static void f_and __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_append __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_argc __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_argidx __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_arglistid __ARGS((typval_T *argvars, typval_T *rettv));
 static void f_argv __ARGS((typval_T *argvars, typval_T *rettv));
 #ifdef FEAT_FLOAT
 static void f_asin __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7875,6 +7876,7 @@ static struct fst
     {"append",         2, 2, f_append},
     {"argc",           0, 0, f_argc},
     {"argidx",         0, 0, f_argidx},
+    {"arglistid",      0, 2, f_arglistid},
     {"argv",           0, 1, f_argv},
 #ifdef FEAT_FLOAT
     {"asin",           1, 1, f_asin},  /* WJMc */
@@ -8858,6 +8860,41 @@ f_argidx(argvars, rettv)
     rettv->vval.v_number = curwin->w_arg_idx;
 }
 
+/*
+ * "arglistid()" function
+ */
+    static void
+f_arglistid(argvars, rettv)
+    typval_T   *argvars UNUSED;
+    typval_T   *rettv;
+{
+    win_T      *wp;
+    tabpage_T  *tp = NULL;
+    long       n;
+
+    rettv->vval.v_number = -1;
+    if (argvars[0].v_type != VAR_UNKNOWN)
+    {
+       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)
+       {
+           wp = find_win_by_nr(&argvars[0], tp);
+           if (wp != NULL)
+               rettv->vval.v_number = wp->w_alist->id;
+       }
+    }
+    else
+       rettv->vval.v_number = curwin->w_alist->id;
+}
+
 /*
  * "argv(nr)" function
  */
index a7df2c31aaa601791e4113f0b7f4d93357c915cf..04c9a61cfa1f1ef5560919d6179ccf91936270d4 100644 (file)
@@ -7211,6 +7211,7 @@ alist_new()
     else
     {
        curwin->w_alist->al_refcount = 1;
+       curwin->w_alist->id = ++max_alist_id;
        alist_init(curwin->w_alist);
     }
 }
index 058341b11799808f8eb373c8a06576f2952fe4bb..d831db9f82d7d77f8d55b8e4678f5954394ccd78 100644 (file)
@@ -601,6 +601,7 @@ EXTERN int  mf_dont_release INIT(= FALSE);  /* don't release blocks */
  * to this when the window is using the global argument list.
  */
 EXTERN alist_T global_alist;   /* global argument list */
+EXTERN int     max_alist_id INIT(= 0);     /* the previous argument list id */
 EXTERN int     arg_had_last INIT(= FALSE); /* accessed last file in
                                               global_alist */
 
index c29d6be2350ce34d45a28d2dce40df82a869af14..9c92f7a844fa6d76911188c0ef678e198d10ba82 100644 (file)
@@ -322,6 +322,7 @@ main
     init_yank();               /* init yank buffers */
 
     alist_init(&global_alist); /* Init the argument list to empty. */
+    global_alist.id = 0;
 
     /*
      * Set the default values for the options.
index 16a20716a4c1afedcef13be8e64cfb1d23f49a29..6f953002d20ddfc3a13a8a3484e8018643f89bbb 100644 (file)
@@ -675,6 +675,7 @@ typedef struct arglist
 {
     garray_T   al_ga;          /* growarray with the array of file names */
     int                al_refcount;    /* number of windows using this arglist */
+    int                id;             /* id of this arglist */
 } alist_T;
 
 /*
index 85ab6800a99aa39ccf6d1c2eac963b03d2742272..b3ec0d31867578788d3cfd2df1d93842a028281a 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    312,
 /**/
     311,
 /**/