patch 7.4.1042
Problem: g-CTRL-G shows the word count, but there is no way to get the word
count in a script.
Solution: Add the wordcount() function. (Christian Brabandt)
diff --git a/src/eval.c b/src/eval.c
index 743c743..feaa71c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -780,6 +780,7 @@
static void f_winsaveview __ARGS((typval_T *argvars, typval_T *rettv));
static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv));
static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
+static void f_wordcount __ARGS((typval_T *argvars, typval_T *rettv));
static void f_xor __ARGS((typval_T *argvars, typval_T *rettv));
static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp));
@@ -8387,6 +8388,7 @@
{"winrestview", 1, 1, f_winrestview},
{"winsaveview", 0, 0, f_winsaveview},
{"winwidth", 1, 1, f_winwidth},
+ {"wordcount", 0, 0, f_wordcount},
{"writefile", 2, 3, f_writefile},
{"xor", 2, 2, f_xor},
};
@@ -20220,6 +20222,19 @@
}
/*
+ * "wordcount()" function
+ */
+ static void
+f_wordcount(argvars, rettv)
+ typval_T *argvars UNUSED;
+ typval_T *rettv;
+{
+ if (rettv_dict_alloc(rettv) == FAIL)
+ return;
+ cursor_pos_info(rettv->vval.v_dict);
+}
+
+/*
* Write list of strings to file
*/
static int