changeset 133:bcb347a8f934

updated for version 7.0044
author vimboss
date Tue, 25 Jan 2005 22:12:55 +0000
parents d6009de12681
children 9322cb10d72e
files runtime/doc/eval.txt runtime/doc/pattern.txt runtime/doc/starting.txt runtime/filetype.vim src/edit.c src/gui_gtk.c src/option.c src/option.h src/structs.h
diffstat 9 files changed, 187 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt*      For Vim version 7.0aa.  Last change: 2005 Jan 20
+*eval.txt*      For Vim version 7.0aa.  Last change: 2005 Jan 25
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -992,6 +992,12 @@ specified by what is prepended:
 |function-argument|  a:	  Function argument (only inside a function).
 |vim-variable|       v:	  Global, predefined by Vim.
 
+The scope name by itself can be used as a Dictionary.  For example, to delete
+all script-local variables: >
+	:for k in keys(s:)
+	:    unlet s:[k]
+	:endfor
+<
 						*buffer-variable* *b:var*
 A variable name that is preceded with "b:" is local to the current buffer.
 Thus you can have several "b:foo" variables, one for each buffer.
@@ -1507,7 +1513,8 @@ simplify( {filename})		String	simplify f
 sort( {list} [, {func}])	List	sort {list}, using {func} to compare
 split( {expr} [, {pat}])	List	make List from {pat} separated {expr}
 strftime( {format}[, {time}])	String	time in specified format
-stridx( {haystack}, {needle})	Number	first index of {needle} in {haystack}
+stridx( {haystack}, {needle}[, {start}])
+				Number	index of {needle} in {haystack}
 string( {expr})			String	String representation of {expr} value
 strlen( {expr})			Number	length of the String {expr}
 strpart( {src}, {start}[, {len}])
@@ -3507,12 +3514,14 @@ strftime({format} [, {time}])				*strfti
 <		Not available on all systems.  To check use: >
 			:if exists("*strftime")
 
-stridx({haystack}, {needle})				*stridx()*
-		The result is a Number, which gives the index in {haystack} of
-		the first occurrence of the String {needle} in the String
-		{haystack}. The search is done case-sensitive. For advanced
-		searches use |match()|.
-		If the {needle} does not occur in {haystack} it returns -1.
+stridx({haystack}, {needle} [, {start}])		*stridx()*
+		The result is a Number, which gives the byte index in
+		{haystack} of the first occurrence of the String {needle}.
+		If {start} is specified, the String {needle} is searched from
+		the byte index {start} in the String {haystack}.
+		The search is done case-sensitive.
+		For pattern searches use |match()|. 
+		-1 is returned if the {needle} does not occur in {haystack}.
 		See also |strridx()|. Examples: >
 		  :echo stridx("An Example", "Example")	     3
 		  :echo stridx("Starting point", "Start")    0
@@ -3558,10 +3567,10 @@ strpart({src}, {start}[, {len}])			*strp
 <
 strridx({haystack}, {needle})				*strridx()*
 		The result is a Number, which gives the index in {haystack} of
-		the last occurrence of the String {needle} in the String
-		{haystack}. The search is done case-sensitive. For advanced
-		searches use |match()|.
-		If the {needle} does not occur in {haystack} it returns -1.
+		the last occurrence of the String {needle}.
+		The search is done case-sensitive.
+		For pattern searches use |match()|.
+		-1 is returned if the {needle} does not occur in {haystack}.
 		If the {needle} is empty the length of {haystack} is returned.
 		See also |stridx()|. Examples: >
 		  :echo strridx("an angry armadillo", "an")	     3
@@ -4069,30 +4078,14 @@ instead of "s:" when the mapping is expa
 			result is a |Funcref| to a numbered function.  The
 			function can only be used with a |Funcref| and will be
 			deleted if there are no more references to it.
-						*function-argument* *a:var*
-			An argument can be defined by giving its name.  In the
-			function this can then be used as "a:name" ("a:" for
-			argument).
-			Up to 20 arguments can be given, separated by commas.
-			Finally, an argument "..." can be specified, which
-			means that more arguments may be following.  In the
-			function they can be used as "a:1", "a:2", etc.  "a:0"
-			is set to the number of extra arguments (which can be
-			0).
-			When not using "...", the number of arguments in a
-			function call must be equal to the number of named
-			arguments.  When using "...", the number of arguments
-			may be larger.
-			It is also possible to define a function without any
-			arguments.  You must still supply the () then.
-			The body of the function follows in the next lines,
-			until the matching |:endfunction|.  It is allowed to
-			define another function inside a function body.
 								*E127* *E122*
 			When a function by this name already exists and [!] is
 			not used an error message is given.  When [!] is used,
 			an existing function is silently replaced.  Unless it
 			is currently being executed, that is an error.
+
+			For the {arguments} see |function-argument|.
+
 						*a:firstline* *a:lastline*
 			When the [range] argument is added, the function is
 			expected to take care of a range itself.  The range is
@@ -4139,7 +4132,26 @@ instead of "s:" when the mapping is expa
 			nested ":try"s inside the function.  The function
 			returns at the outermost ":endtry".
 
-
+						*function-argument* *a:var*
+An argument can be defined by giving its name.  In the function this can then
+be used as "a:name" ("a:" for argument).
+						*a:0* *a:1* *a:000* *E740*
+Up to 20 arguments can be given, separated by commas.  After the named
+arguments an argument "..." can be specified, which means that more arguments
+may optionally be following.  In the function the extra arguments can be used
+as "a:1", "a:2", etc.  "a:0" is set to the number of extra arguments (which
+can be 0).  "a:000" is set to a List that contains these arguments.
+
+When not using "...", the number of arguments in a function call must be equal
+to the number of named arguments.  When using "...", the number of arguments
+may be larger.
+
+It is also possible to define a function without any arguments.  You must
+still supply the () then.  The body of the function follows in the next lines,
+until the matching |:endfunction|.  It is allowed to define another function
+inside a function body.
+
+							*local-variables*
 Inside a function variables can be used.  These are local variables, which
 will disappear when the function returns.  Global variables need to be
 accessed with "g:".
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -1,4 +1,4 @@
-*pattern.txt*   For Vim version 7.0aa.  Last change: 2004 Dec 18
+*pattern.txt*   For Vim version 7.0aa.  Last change: 2005 Jan 24
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -217,7 +217,7 @@ To clear the last used search pattern: >
 This will not set the pattern to an empty string, because that would match
 everywhere.  The pattern is really cleared, like when starting Vim.
 
-The search usual skips matches that don't move the cursor.  Whether the next
+The search usually skips matches that don't move the cursor.  Whether the next
 match is found at the next character or after the skipped match depends on the
 'c' flag in 'cpoptions'.  See |cpo-c|.
 	   with 'c' flag:   "/..." advances 1 to 3 characters
@@ -225,6 +225,10 @@ match is found at the next character or 
 The unpredictability with the 'c' flag is caused by starting the search in the
 first column, skipping matches until one is found past the cursor position.
 
+When searching backwards, searching starts at the start of the line, using the
+'c' flag in 'cpoptions' as described above.  Then the last match before the
+cursor position is used.
+
 In Vi the ":tag" command sets the last search pattern when the tag is searched
 for.  In Vim this is not done, the previous search pattern is still remembered,
 unless the 't' flag is present in 'cpoptions'.  The search pattern is always
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -1,4 +1,4 @@
-*starting.txt*  For Vim version 7.0aa.  Last change: 2005 Jan 20
+*starting.txt*  For Vim version 7.0aa.  Last change: 2005 Jan 25
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1193,7 +1193,7 @@ This saves the current Session, and star
 			When [file] is omitted or is a number from 1 to 9, a
 			name is generated and 'viewdir' prepended.  When last
 			directory name in 'viewdir' does not exist, this
-			directory is created.			*E738*
+			directory is created.			*E739*
 			An existing file is always overwritten then.  Use
 			|:loadview| to load this view again.
 			When [file] is the name of a file ('viewdir' is not
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
 " Vim support file to detect file types
 "
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
-" Last Change:	2004 Dec 31
+" Last Change:	2005 Jan 24
 
 " Listen very carefully, I will say this only once
 if exists("did_load_filetypes")
@@ -595,8 +595,8 @@ au BufNewFile,BufRead *.hex,*.h32		setf 
 " Tilde (must be before HTML)
 au BufNewFile,BufRead *.t.html			setf tilde
 
-" HTML (.shtml and .stm for server side)
-au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call <SID>FTCheck_html()
+" HTML (.shtml and .stm for server side, .rhtml for Ruby html)
+au BufNewFile,BufRead *.html,*.htm,*.shtml,*.rhtml,*.stm  call <SID>FTCheck_html()
 
 " Distinguish between HTML and XHTML
 fun! <SID>FTCheck_html()
--- a/src/edit.c
+++ b/src/edit.c
@@ -3383,7 +3383,7 @@ ins_complete(c)
 		    temp = complete_col - temp;
 		}
 		if (p_ic)
-		    complete_pat = str_foldcase(tmp_ptr, temp);
+		    complete_pat = str_foldcase(tmp_ptr, temp, NULL, 0);
 		else
 		    complete_pat = vim_strnsave(tmp_ptr, temp);
 		if (complete_pat == NULL)
@@ -3482,7 +3482,7 @@ ins_complete(c)
 	    if (temp < 0)	/* cursor in indent: empty pattern */
 		temp = 0;
 	    if (p_ic)
-		complete_pat = str_foldcase(tmp_ptr, temp);
+		complete_pat = str_foldcase(tmp_ptr, temp, NULL, 0);
 	    else
 		complete_pat = vim_strnsave(tmp_ptr, temp);
 	    if (complete_pat == NULL)
@@ -6111,15 +6111,15 @@ ins_reg()
     ++no_u_sync;
     if (regname == '=')
     {
-#ifdef USE_IM_CONTROL
+# ifdef USE_IM_CONTROL
 	int	im_on = im_get_status();
-#endif
+# endif
 	regname = get_expr_register();
-#ifdef USE_IM_CONTROL
+# ifdef USE_IM_CONTROL
 	/* Restore the Input Method. */
 	if (im_on)
 	    im_set_active(TRUE);
-#endif
+# endif
     }
     if (regname == NUL)
 	need_redraw = TRUE;	/* remove the '"' */
@@ -6141,6 +6141,12 @@ ins_reg()
 	    vim_beep();
 	    need_redraw = TRUE;	/* remove the '"' */
 	}
+	else if (stop_insert_mode)
+	    /* When the '=' register was used and a function was invoked that
+	     * did ":stopinsert" then stuff_empty() returns FALSE but we won't
+	     * insert anything, need to remove the '"' */
+	    need_redraw = TRUE;
+
 #ifdef FEAT_EVAL
     }
     --no_u_sync;
--- a/src/gui_gtk.c
+++ b/src/gui_gtk.c
@@ -867,7 +867,8 @@ gui_gtk_set_mnemonics(int enable)
 	gtk_label_set_text_with_mnemonic(GTK_LABEL(menu->label),
 					 (const char *)name);
 	vim_free(name);
-# elif defined(GTK_USE_ACCEL)
+# else
+#  if defined(GTK_USE_ACCEL)
 	name = translate_mnemonic_tag(menu->name, TRUE);
 	if (name != NULL)
 	{
@@ -889,6 +890,7 @@ gui_gtk_set_mnemonics(int enable)
 	    gtk_label_parse_uline(GTK_LABEL(menu->label), (const char *)name);
 	    vim_free(name);
 	}
+#  endif
 # endif
     }
 }
@@ -1880,7 +1882,7 @@ gui_mch_dialog(	int	type,		/* type of di
 		    "clicked",
 		    accel_group,
 		    accel_key, 0,
-		    0);
+		    (GtkAccelFlags)0);
 	}
 # else
 	(void)gtk_label_parse_uline(GTK_LABEL(label), (const gchar *)p);
--- a/src/option.c
+++ b/src/option.c
@@ -5245,7 +5245,8 @@ did_set_string_option(opt_idx, varp, new
 		{
 		    if (errbuf != NULL)
 		    {
-			sprintf((char *)errbuf, _("E526: Missing number after <%s>"),
+			sprintf((char *)errbuf,
+					 _("E526: Missing number after <%s>"),
 						    transchar_byte(*(s - 1)));
 			errmsg = errbuf;
 		    }
@@ -9382,7 +9383,7 @@ compatible_set()
 
 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
    /* Borland C++ screws up loop optimisation here (negri) */
-#  pragma option -O-l
+  #pragma option -O-l
 # endif
 
 /*
@@ -9403,7 +9404,7 @@ fill_breakat_flags()
 }
 
 # if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
-#  pragma option -O.l
+  #pragma option -O.l
 # endif
 
 #endif
--- a/src/option.h
+++ b/src/option.h
@@ -28,10 +28,10 @@
 # define DFLT_EFM	"%f>%l:%c:%t:%n:%m,%f:%l: %t%*\\D%n: %m,%f %l %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f:%l:%m,%f|%l| %m"
 #else
 # if defined(MSDOS) || defined(WIN3264)
-#  define DFLT_EFM	"%f(%l) : %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) : %m,%*[^ ] %f %l: %m,%f:%l:%m,%f|%l| %m"
+#  define DFLT_EFM	"%f(%l) : %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) : %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%f|%l| %m"
 # else
 #  if defined(__EMX__)	/* put most common here (i.e. gcc format) at front */
-#   define DFLT_EFM	"%f:%l:%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f(%l:%c) : %m,%f|%l| %m"
+#   define DFLT_EFM	"%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f(%l:%c) : %m,%f|%l| %m"
 #  else
 #   if defined(__QNX__)
 #    define DFLT_EFM	"%f(%l):%*[^WE]%t%*\\D%n:%m,%f|%l| %m"
@@ -40,9 +40,9 @@
 #     define DFLT_EFM	"%A%p^,%C%%CC-%t-%m,%Cat line number %l in file %f,%f|%l| %m"
 #    else /* Unix, probably */
 #     ifdef EBCDIC
-#define DFLT_EFM	"%*[^ ] %*[^ ] %f:%l%*[ ]%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m"
+#define DFLT_EFM	"%*[^ ] %*[^ ] %f:%l%*[ ]%m,%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m"
 #     else
-#define DFLT_EFM	"%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m"
+#define DFLT_EFM	"%*[^\"]\"%f\"%*\\D%l: %m,\"%f\"%*\\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,\"%f\"\\, line %l%*\\D%c%*[^ ] %m,%D%*\\a[%*\\d]: Entering directory `%f',%X%*\\a[%*\\d]: Leaving directory `%f',%DMaking %*\\a in %f,%f|%l| %m"
 #     endif
 #    endif
 #   endif
--- a/src/structs.h
+++ b/src/structs.h
@@ -712,7 +712,7 @@ typedef struct keyentry keyentry_T;
 
 struct keyentry
 {
-    keyentry_T	*next;		/* next keyword in the hash list */
+    keyentry_T	*ke_next;	/* next entry with identical "keyword[]" */
     struct sp_syn k_syn;	/* struct passed to in_id_list() */
     short	*next_list;	/* ID list for next match (if non-zero) */
     short	flags;		/* see syntax.c */
@@ -921,7 +921,7 @@ typedef struct hashitem_S
 {
     long_u	hi_hash;	/* cached hash number of hi_key */
     char_u	*hi_key;
-} hashitem;
+} hashitem_T;
 
 /* The address of "hash_removed" is used as a magic number for hi_key to
  * indicate a removed item. */
@@ -941,10 +941,107 @@ typedef struct hashtable_S
     int		ht_locked;	/* counter for hash_lock() */
     int		ht_error;	/* when set growing failed, can't add more
 				   items before growing works */
-    hashitem	*ht_array;	/* points to the array, allocated when it's
+    hashitem_T	*ht_array;	/* points to the array, allocated when it's
 				   not "ht_smallarray" */
-    hashitem	ht_smallarray[HT_INIT_SIZE];   /* initial array */
-} hashtable;
+    hashitem_T	ht_smallarray[HT_INIT_SIZE];   /* initial array */
+} hashtab_T;
+
+typedef long_u hash_T;		/* Type for hi_hash */
+
+
+#if SIZEOF_INT <= 3		/* use long if int is smaller than 32 bits */
+typedef long	varnumber_T;
+#else
+typedef int	varnumber_T;
+#endif
+
+typedef struct listvar_S list_T;
+typedef struct dictvar_S dict_T;
+
+/*
+ * Structure to hold an internal variable without a name.
+ */
+typedef struct
+{
+    char	v_type;	/* see below: VAR_NUMBER, VAR_STRING, etc. */
+    union
+    {
+	varnumber_T	v_number;	/* number value */
+	char_u		*v_string;	/* string value (can be NULL!) */
+	list_T		*v_list;	/* list value (can be NULL!) */
+	dict_T		*v_dict;	/* dict value (can be NULL!) */
+    }		vval;
+} typval_T;
+
+/* Values for "v_type". */
+#define VAR_UNKNOWN 0
+#define VAR_NUMBER  1	/* "v_number" is used */
+#define VAR_STRING  2	/* "v_string" is used */
+#define VAR_FUNC    3	/* "v_string" is function name */
+#define VAR_LIST    4	/* "v_list" is used */
+#define VAR_DICT    5	/* "v_dict" is used */
+
+/*
+ * Structure to hold an item of a list: an internal variable without a name.
+ */
+typedef struct listitem_S listitem_T;
+
+struct listitem_S
+{
+    listitem_T	*li_next;	/* next item in list */
+    listitem_T	*li_prev;	/* previous item in list */
+    typval_T	li_tv;		/* type and value of the variable */
+};
+
+/*
+ * Struct used by those that are using an item in a list.
+ */
+typedef struct listwatch_S listwatch_T;
+
+struct listwatch_S
+{
+    listitem_T		*lw_item;	/* item being watched */
+    listwatch_T		*lw_next;	/* next watcher */
+};
+
+/*
+ * Structure to hold info about a list.
+ */
+struct listvar_S
+{
+    int		lv_refcount;	/* reference count */
+    listitem_T	*lv_first;	/* first item, NULL if none */
+    listitem_T	*lv_last;	/* last item, NULL if none */
+    listwatch_T	*lv_watch;	/* first watcher, NULL if none */
+};
+
+/*
+ * Structure to hold an item of a Dictionary.
+ * Also used for a variable.
+ * The key is copied into "di_key" to avoid an extra alloc/free for it.
+ */
+struct dictitem_S
+{
+    typval_T	di_tv;		/* type and value of the variable */
+    char_u	di_flags;	/* flags (only used for variable) */
+    char_u	di_key[1];	/* key (actually longer!) */
+};
+
+typedef struct dictitem_S dictitem_T;
+
+#define DI_FLAGS_RO	1 /* "di_flags" value: read-only variable */
+#define DI_FLAGS_RO_SBX 2 /* "di_flags" value: read-only in the sandbox */
+#define DI_FLAGS_FIX	4 /* "di_flags" value: fixed variable, not allocated */
+
+/*
+ * Structure to hold info about a Dictionary.
+ */
+struct dictvar_S
+{
+    int		dv_refcount;	/* reference count */
+    hashtab_T	dv_hashtab;	/* hashtab that refers to the items */
+};
+
 
 /*
  * buffer: structure that holds information about one file
@@ -1259,7 +1356,8 @@ struct file_buffer
 #endif
 
 #ifdef FEAT_EVAL
-    hashtable	b_vars;		/* internal variables, local to buffer */
+    dictitem_T	b_bufvar;	/* variable for "b:" Dictionary */
+    dict_T	b_vars;		/* internal variables, local to buffer */
 #endif
 
     /* When a buffer is created, it starts without a swap file.  b_may_swap is
@@ -1297,8 +1395,8 @@ struct file_buffer
 #endif
 
 #ifdef FEAT_SYN_HL
-    keyentry_T	**b_keywtab;		/* syntax keywords hash table */
-    keyentry_T	**b_keywtab_ic;		/* idem, ignore case */
+    hashtab_T	b_keywtab;		/* syntax keywords hash table */
+    hashtab_T	b_keywtab_ic;		/* idem, ignore case */
     int		b_syn_ic;		/* ignore case for :syn cmds */
     garray_T	b_syn_patterns;		/* table for syntax patterns */
     garray_T	b_syn_clusters;		/* table for syntax clusters */
@@ -1603,7 +1701,8 @@ struct window
 #endif
 
 #ifdef FEAT_EVAL
-    hashtable	w_vars;		/* internal variables, local to window */
+    dictitem_T	w_winvar;	/* variable for "w:" Dictionary */
+    dict_T	w_vars;		/* internal variables, local to window */
 #endif
 
 #if defined(FEAT_RIGHTLEFT) && defined(FEAT_FKMAP)