changeset 20:4ac1dce8dd5e v7.0012

updated for version 7.0012
author vimboss
date Mon, 26 Jul 2004 12:53:41 +0000
parents a81bc802c17c
children db5102f7e29f
files Filelist runtime/doc/diff.txt runtime/doc/eval.txt runtime/doc/if_cscop.txt runtime/doc/if_pyth.txt runtime/doc/message.txt runtime/doc/motion.txt runtime/doc/options.txt runtime/doc/pattern.txt runtime/doc/tags runtime/doc/tagsrch.txt runtime/doc/todo.txt runtime/doc/version7.txt runtime/ftplugin/lprolog.vim runtime/ftplugin/ocaml.vim runtime/indent/ocaml.vim runtime/indent/python.vim runtime/syntax/dot.vim runtime/syntax/idl.vim runtime/syntax/lilo.vim runtime/syntax/lprolog.vim runtime/syntax/ocaml.vim runtime/syntax/sml.vim src/Makefile src/buffer.c src/edit.c src/eval.c src/ex_cmds2.c src/gui_kde.cc src/gui_kde_wid.cc src/gui_kde_wid.h src/gui_kde_widget.cc src/gui_kde_widget.h src/gui_kde_x11.cc src/if_python.c src/main.aap src/memline.c src/misc2.c src/ops.c src/os_mac.h src/os_mac_conv.c src/po/ru.cp1251.po src/po/ru.po src/search.c
diffstat 44 files changed, 2913 insertions(+), 2199 deletions(-) [+]
line wrap: on
line diff
--- a/Filelist
+++ b/Filelist
@@ -148,8 +148,8 @@ SRC_UNIX =	\
 		src/gui_gtk_f.h \
 		src/gui_gtk_x11.c \
 		src/gui_kde.cc \
-		src/gui_kde_widget.cc \
-		src/gui_kde_widget.h \
+		src/gui_kde_wid.cc \
+		src/gui_kde_wid.h \
 		src/gui_kde_x11.cc \
 		src/kvim_iface.h \
 		src/gui_motif.c \
@@ -365,7 +365,7 @@ SRC_MAC =	\
 		src/os_mac.sit.hqx \
 		src/os_mac_conv.c \
 		src/os_macosx.c \
-		src/os_mac.pbproj/project.pbxproj
+		src/os_mac.pbproj/project.pbxproj \
 		src/proto/gui_mac.pro \
 		src/proto/os_mac.pro \
 
--- a/runtime/doc/diff.txt
+++ b/runtime/doc/diff.txt
@@ -1,4 +1,4 @@
-*diff.txt*      For Vim version 7.0aa.  Last change: 2004 Jul 11
+*diff.txt*      For Vim version 7.0aa.  Last change: 2004 Jul 20
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -344,6 +344,10 @@ get an error message.  Possible causes:
 If it's not clear what the problem is set the 'verbose' option to see more
 messages.
 
+The self-installing Vim includes a diff program.  If you don't have it you
+might want to download a diff.exe.  For example from
+http://jlb.twu.net/code/unixkit.php.
+
 
 USING PATCHES					*diff-patchexpr*
 
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt*      For Vim version 7.0aa.  Last change: 2004 Jul 19
+*eval.txt*      For Vim version 7.0aa.  Last change: 2004 Jul 25
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -846,8 +846,10 @@ getbufvar( {expr}, {varname})		variable 
 getcmdline()			String	return the current command-line
 getcmdpos()			Number	return cursor position in command-line
 getcwd()			String	the current working directory
-getfsize( {fname})		Number	size in bytes of file
+getfperm( {fname})		String	file permissions of file {fname}
+getfsize( {fname})		Number	size in bytes of file {fname}
 getftime( {fname})		Number	last modification time of file
+getftype( {fname})		String	description of type of file {fname}
 getline( {lnum})		String	line {lnum} from current buffer
 getreg( [{regname}])		String  contents of register
 getregtype( [{regname}])	String  type of register
@@ -1580,6 +1582,20 @@ getfsize({fname})					*getfsize()*
 		If {fname} is a directory, 0 is returned.
 		If the file {fname} can't be found, -1 is returned.
 
+getfperm({fname})					*getfperm()*
+		The result is a String, which is the read, write, and execute
+		permissions of the given file {fname}.
+		If {fname} does not exist or its directory cannot be read, an
+		empty string is returned.
+		The result is of the form "rwxrwxrwx", where each group of
+		"rwx" flags represent, in turn, the permissions of the owner
+		of the file, the group the file belongs to, and other users.
+		If a user does not have a given permission the flag for this
+		is replaced with the string "-".  Example: >
+			:echo getfperm("/etc/passwd")
+<		This will hopefully (from a security point of view) display
+		the string "rw-r--r--" or even "rw-------".
+  
 getftime({fname})					*getftime()*
 		The result is a Number, which is the last modification time of
 		the given file {fname}.  The value is measured as seconds
@@ -1587,6 +1603,26 @@ getftime({fname})					*getftime()*
 		|localtime()| and |strftime()|.
 		If the file {fname} can't be found -1 is returned.
 
+getftype({fname})					*getftype()*
+		The result is a String, which is a description of the kind of
+		file of the given file {fname}.
+		If {fname} does not exist an empty string is returned.
+		Here is a table over different kinds of files and their
+		results:
+			Normal file		"file"
+			Directory		"dir"
+			Symbolic link		"link"
+			Block device		"bdev"
+			Character device	"cdev"
+			Socket			"socket"
+			FIFO			"fifo"
+			All other		"other"
+		Example: >
+			getftype("/home")
+<		Note that a type such as "link" will only be returned on
+		systems that support it.  On some systems only "dir" and
+		"file" are returned.
+
 							*getline()*
 getline({lnum}) The result is a String, which is line {lnum} from the current
 		buffer.  Example: >
@@ -2246,14 +2282,16 @@ search({pattern} [, {flags}])				*search
 		cursor position.
 		{flags} is a String, which can contain these character flags:
 		'b'	search backward instead of forward
+		'n'	do Not move the cursor
 		'w'	wrap around the end of the file
 		'W'	don't wrap around the end of the file
 		If neither 'w' or 'W' is given, the 'wrapscan' option applies.
 
-		When a match has been found its line number is returned, and
-		the cursor will be positioned at the match.  If there is no
-		match a 0 is returned and the cursor doesn't move.  No error
-		message is given.
+		When a match has been found its line number is returned.
+		The cursor will be positioned at the match, unless the 'n'
+		flag is used).
+		If there is no match a 0 is returned and the cursor doesn't
+		move.  No error message is given.
 
 		Example (goes over all files in the argument list): >
 		    :let n = 1
@@ -2747,9 +2785,15 @@ winline()	The result is a Number, which 
 		the window.  The first line is one.
 
 							*winnr()*
-winnr()		The result is a Number, which is the number of the current
-		window.  The top window has number 1.  The number can be used
-		with |CTRL-W_w| and ":wincmd w" |:wincmd|.
+winnr([{arg}])	The result is a Number, which is the number of the current
+		window.  The top window has number 1.
+		When the optional argument is "$", the number of the
+		last window is returnd (the window count).
+		When the optional argument is "#", the number of the last
+		accessed window is returned (where |CTRL-W_p| goes to).
+		If there is no previous window 0 is returned.
+		The number can be used with |CTRL-W_w| and ":wincmd w"
+		|:wincmd|.
 
 							*winrestcmd()*
 winrestcmd()	Returns a sequence of |:resize| commands that should restore
--- a/runtime/doc/if_cscop.txt
+++ b/runtime/doc/if_cscop.txt
@@ -1,4 +1,4 @@
-*if_cscop.txt*  For Vim version 7.0aa.  Last change: 2004 Jan 17
+*if_cscop.txt*  For Vim version 7.0aa.  Last change: 2004 Jul 23
 
 
 		  VIM REFERENCE MANUAL    by Andy Kahn
@@ -335,6 +335,9 @@ cscope version for Win32 see:
 
 	http://iamphet.nm.ru/cscope/index.html
 
+The DJGPP-built version from http://cscope.sourceforge.net is known to not
+work with Vim.
+
 There are a couple of hard-coded limitations:
 
     1. The maximum number of cscope connections allowed is 8.  Do you
--- a/runtime/doc/if_pyth.txt
+++ b/runtime/doc/if_pyth.txt
@@ -1,4 +1,4 @@
-*if_pyth.txt*   For Vim version 7.0aa.  Last change: 2004 Feb 28
+*if_pyth.txt*   For Vim version 7.0aa.  Last change: 2004 Jul 25
 
 
 		  VIM REFERENCE MANUAL    by Paul Moore
@@ -91,23 +91,23 @@ module before using it: >
 	:python import vim
 
 Overview >
-	print "Hello"			# displays a message
-	vim.command(cmd)		# execute an ex command
-	w = vim.windows[n]		# gets window "n"
-	cw = vim.current.window		# gets the current window
-	b = vim.buffers[n]		# gets buffer "n"
-	cb = vim.current.buffer		# gets the current buffer
-	w.height = lines		# sets the window height
-	w.cursor = (row, col)		# sets the window cursor position
-	pos = w.cursor			# gets a tuple (row, col)
-	name = b.name			# gets the buffer file name
-	line = b[n]			# gets a line from the buffer
-	lines = b[n:m]			# gets a list of lines
-	num = len(b)			# gets the number of lines
-	b[n] = str			# sets a line in the buffer
-	b[n:m] = [str1, str2, str3]	# sets a number of lines at once
-	del b[n]			# deletes a line
-	del b[n:m]			# deletes a number of lines
+	:py print "Hello"		# displays a message
+	:py vim.command(cmd)		# execute an ex command
+	:py w = vim.windows[n]		# gets window "n"
+	:py cw = vim.current.window	# gets the current window
+	:py b = vim.buffers[n]		# gets buffer "n"
+	:py cb = vim.current.buffer	# gets the current buffer
+	:py w.height = lines		# sets the window height
+	:py w.cursor = (row, col)	# sets the window cursor position
+	:py pos = w.cursor		# gets a tuple (row, col)
+	:py name = b.name		# gets the buffer file name
+	:py line = b[n]			# gets a line from the buffer
+	:py lines = b[n:m]		# gets a list of lines
+	:py num = len(b)		# gets the number of lines
+	:py b[n] = str			# sets a line in the buffer
+	:py b[n:m] = [str1, str2, str3]	# sets a number of lines at once
+	:py del b[n]			# deletes a line
+	:py del b[n:m]			# deletes a number of lines
 
 
 Methods of the "vim" module
@@ -115,8 +115,8 @@ Methods of the "vim" module
 vim.command(str)					*python-command*
 	Executes the vim (ex-mode) command str. Returns None.
 	Examples: >
-		vim.command("set tw=72")
-		vim.command("%s/aaa/bbb/g")
+	    :py vim.command("set tw=72")
+	    :py vim.command("%s/aaa/bbb/g")
 <	The following definition executes Normal mode commands: >
 		def normal(str):
 			vim.command("normal "+str)
@@ -126,15 +126,15 @@ vim.command(str)					*python-command*
 <								*E659*
 	The ":python" command cannot be used recursively with Python 2.2 and
 	older.  This only works with Python 2.3 and later: >
-		:python vim.command("python print 'Hello again Python'")
+	    :py vim.command("python print 'Hello again Python'")
 
 vim.eval(str)						*python-eval*
 	Evaluates the expression str using the vim internal expression
 	evaluator (see |expression|). Returns the expression result as a
 	string.
 	Examples: >
-		text_width = vim.eval("&tw")
-		str = vim.eval("12+12")		# NB result is a string! Use
+	    :py text_width = vim.eval("&tw")
+	    :py str = vim.eval("12+12")		# NB result is a string! Use
 						# string.atoi() to convert to
 						# a number.
 
@@ -158,18 +158,18 @@ Constants of the "vim" module
 vim.buffers						*python-buffers*
 	A sequence object providing access to the list of vim buffers. The
 	object supports the following operations: >
-		b = vim.buffers[i]	# Indexing (read-only)
-		b in vim.buffers	# Membership test
-		n = len(vim.buffers)	# Number of elements
-		for b in vim.buffers:	# Sequential access
+	    :py b = vim.buffers[i]	# Indexing (read-only)
+	    :py b in vim.buffers	# Membership test
+	    :py n = len(vim.buffers)	# Number of elements
+	    :py for b in vim.buffers:	# Sequential access
 <
 vim.windows						*python-windows*
 	A sequence object providing access to the list of vim windows. The
 	object supports the following operations: >
-		w = vim.windows[i]	# Indexing (read-only)
-		w in vim.windows	# Membership test
-		n = len(vim.windows)	# Number of elements
-		for w in vim.windows:	# Sequential access
+	    :py w = vim.windows[i]	# Indexing (read-only)
+	    :py w in vim.windows	# Membership test
+	    :py n = len(vim.windows)	# Number of elements
+	    :py for w in vim.windows:	# Sequential access
 <
 vim.current						*python-current*
 	An object providing access (via specific attributes) to various
@@ -236,17 +236,21 @@ The buffer object methods are:
 			represents the part of the given buffer between line
 			numbers s and e |inclusive|.
 
+Note that when adding a line it must not contain a line break character '\n'.
+A trailing '\n' is allowed and ignored, so that you can do: >
+	:py b.append(f.readlines())
+
 Examples (assume b is the current buffer) >
-	print b.name		# write the buffer file name
-	b[0] = "hello!!!"	# replace the top line
-	b[:] = None		# delete the whole buffer
-	del b[:]		# delete the whole buffer (same as above)
-	b[0:0] = [ "a line" ]	# add a line at the top
-	del b[2]		# delete a line (the third)
-	b.append("bottom")	# add a line at the bottom
-	n = len(b)		# number of lines
-	(row,col) = b.mark('a') # named mark
-	r = b.range(1,5)	# a sub-range of the buffer
+	:py print b.name		# write the buffer file name
+	:py b[0] = "hello!!!"		# replace the top line
+	:py b[:] = None			# delete the whole buffer
+	:py del b[:]			# delete the whole buffer
+	:py b[0:0] = [ "a line" ]	# add a line at the top
+	:py del b[2]			# delete a line (the third)
+	:py b.append("bottom")		# add a line at the bottom
+	:py n = len(b)			# number of lines
+	:py (row,col) = b.mark('a')	# named mark
+	:py r = b.range(1,5)		# a sub-range of the buffer
 
 ==============================================================================
 4. Range objects					*python-range*
--- a/runtime/doc/message.txt
+++ b/runtime/doc/message.txt
@@ -1,4 +1,4 @@
-*message.txt*   For Vim version 7.0aa.  Last change: 2004 Jan 17
+*message.txt*   For Vim version 7.0aa.  Last change: 2004 Jul 23
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -643,6 +643,7 @@ and |+X11| features.
 A command line started with a backslash or the range of a command contained a
 backslash in a wrong place.  This is often caused by command-line continuation
 being disabled.  Remove the 'C' flag from the 'cpoptions' option to enable it.
+Or use ":set nocp".
 
 							*E471*  >
   Argument required
--- a/runtime/doc/motion.txt
+++ b/runtime/doc/motion.txt
@@ -1,4 +1,4 @@
-*motion.txt*    For Vim version 7.0aa.  Last change: 2004 Jul 02
+*motion.txt*    For Vim version 7.0aa.  Last change: 2004 Jul 25
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -83,6 +83,7 @@ 1. If the motion is exclusive and the en
    end of the motion is moved to the end of the previous line and the motion
    becomes inclusive.  Example: "}" moves to the first line after a paragraph,
    but "d}" will not include that line.
+						*exclusive-linewise*
 2. If the motion is exclusive, the end of the motion is in column 1 and the
    start of the motion was at or before the first non-blank in the line, the
    motion becomes linewise.  Example: If a paragraph begins with some blanks
@@ -424,20 +425,24 @@ 5. Text object motions					*object-motio
 
 							*]]*
 ]]			[count] sections forward or to the next '{' in the
-			first column.  When used after an operator, then the
-			'}' in the first column.  |linewise|
+			first column.  When used after an operator, then also
+			stops below a '}' in the first column.  |exclusive|
+			Note that |exclusive-linewise| often applies.
 
 							*][*
 ][			[count] sections forward or to the next '}' in the
-			first column.  |linewise|
+			first column.  |exclusive|
+			Note that |exclusive-linewise| often applies.
 
 							*[[*
 [[			[count] sections backward or to the previous '{' in
-			the first column.  |linewise|
+			the first column.  |exclusive|
+			Note that |exclusive-linewise| often applies.
 
 							*[]*
 []			[count] sections backward or to the previous '}' in
-			the first column.  |linewise|
+			the first column.  |exclusive|
+			Note that |exclusive-linewise| often applies.
 
 These commands move over three kinds of text objects.
 
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*	For Vim version 7.0aa.  Last change: 2004 Jul 15
+*options.txt*	For Vim version 7.0aa.  Last change: 2004 Jul 24
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -3924,7 +3924,7 @@ A jump table for the options with a shor
 	NOTE: To avoid portability problems with using patterns, always keep
 	this option at the default "on".  Only switch it off when working with
 	old Vi scripts.  In any other situation write patterns that work when
-	'magic' is on.
+	'magic' is on.  Include "\M" when you want to |/\M|.
 
 						*'makeef'* *'mef'*
 'makeef' 'mef'		string	(default: "")
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -1,4 +1,4 @@
-*pattern.txt*   For Vim version 7.0aa.  Last change: 2004 May 09
+*pattern.txt*   For Vim version 7.0aa.  Last change: 2004 Jul 24
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -382,7 +382,7 @@ More explanation and examples below, fol
 |/\%c|	\%23c	\%23c	in column 23 |/zero-width|
 |/\%v|	\%23v	\%23v	in virtual column 23 |/zero-width|
 
-Character classes {not in Vi}:
+Character classes {not in Vi}:				*/character-classes*
 |/\i|	\i	\i	identifier character (see 'isident' option)
 |/\I|	\I	\I	like "\i", but excluding digits
 |/\k|	\k	\k	keyword character (see 'iskeyword' option)
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -1337,6 +1337,7 @@
 /atom	pattern.txt	/*\/atom*
 /bar	pattern.txt	/*\/bar*
 /branch	pattern.txt	/*\/branch*
+/character-classes	pattern.txt	/*\/character-classes*
 /collection	pattern.txt	/*\/collection*
 /concat	pattern.txt	/*\/concat*
 /dyn	various.txt	/*\/dyn*
@@ -3570,6 +3571,7 @@ EncodingChanged	autocmd.txt	/*EncodingCh
 Eterm	syntax.txt	/*Eterm*
 Ex	intro.txt	/*Ex*
 Ex-mode	intro.txt	/*Ex-mode*
+Exuberant_ctags	tagsrch.txt	/*Exuberant_ctags*
 F	motion.txt	/*F*
 FAQ	intro.txt	/*FAQ*
 Farsi	farsi.txt	/*Farsi*
@@ -4518,6 +4520,7 @@ except-syntax-error	eval.txt	/*except-sy
 exception-handling	eval.txt	/*exception-handling*
 exception-variable	eval.txt	/*exception-variable*
 exclusive	motion.txt	/*exclusive*
+exclusive-linewise	motion.txt	/*exclusive-linewise*
 executable()	eval.txt	/*executable()*
 execute-menus	gui.txt	/*execute-menus*
 exim	starting.txt	/*exim*
@@ -4625,6 +4628,7 @@ filewritable()	eval.txt	/*filewritable()
 filter	change.txt	/*filter*
 find-manpage	usr_12.txt	/*find-manpage*
 find-replace	usr_10.txt	/*find-replace*
+finddir()	eval.txt	/*finddir()*
 findfile()	eval.txt	/*findfile()*
 fixed-5.1	version5.txt	/*fixed-5.1*
 fixed-5.2	version5.txt	/*fixed-5.2*
@@ -4773,8 +4777,10 @@ getcharmod()	eval.txt	/*getcharmod()*
 getcmdline()	eval.txt	/*getcmdline()*
 getcmdpos()	eval.txt	/*getcmdpos()*
 getcwd()	eval.txt	/*getcwd()*
+getfperm()	eval.txt	/*getfperm()*
 getfsize()	eval.txt	/*getfsize()*
 getftime()	eval.txt	/*getftime()*
+getftype()	eval.txt	/*getftype()*
 getline()	eval.txt	/*getline()*
 getreg()	eval.txt	/*getreg()*
 getregtype()	eval.txt	/*getregtype()*
--- a/runtime/doc/tagsrch.txt
+++ b/runtime/doc/tagsrch.txt
@@ -1,4 +1,4 @@
-*tagsrch.txt*   For Vim version 7.0aa.  Last change: 2004 Apr 29
+*tagsrch.txt*   For Vim version 7.0aa.  Last change: 2004 Jul 23
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -468,6 +468,7 @@ a tag for each "#defined" macro, typedef
 Some programs that generate tags files:
 ctags			As found on most Unix systems.  Only supports C.  Only
 			does the basic work.
+							*Exuberant_ctags*
 exuberant ctags		This a very good one.  It works for C, C++, Java,
 			Fortran, Eiffel and others.  It can generate tags for
 			many items.  See http://ctags.sourceforge.net.
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt*      For Vim version 7.0aa.  Last change: 2004 Jul 19
+*todo.txt*      For Vim version 7.0aa.  Last change: 2004 Jul 26
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -30,27 +30,18 @@ be worked on, but only if you sponsor Vi
 							*known-bugs*
 -------------------- Known bugs and current work -----------------------
 
-Add fix for zh_cn to Vim 6.3?  (Liang)
+Aborting at the ATTENTION prompt causes trouble:
+    buffer remains active, nwindows isn't closed (fixed in buffer.c)
+    alternate buffer gets "read error" flag.
+    ":sbuf" and ":ball" leave an empty window behind.
+Change in handle_swap_exists() also in 6.3?
 
 
 For version 7.0:
 -   Include many PATCHES:
     8   Add functions:
-	realname()		Get user name (first, last, full)
-				user_fullname() patch by Nikolai Weibull, Nov
-				3 2002)
-	getfperm()		file permissions, in form "rwxrwxrwx"
-				(patch from Nikolai Weibull 2003 Jan 13)
-	getftype()		"file", "dir", "link", "other"?
-				(patch from Nikolai Weibull 2003 Jan 13)
 	setbufline()		set line in any buffer (patch from Yegappan
 				Lakshmanan, 2003 Jan 21)
-	winnr("$")		Get number of windows.  (patch from Nikolai
-				Weibull 2003 Jan 13) (another patch from
-				Yegappan Lakshmanan, 2004 Jul 11)
-	search()		Add optional offset argument.
-				Add 'n' flag.  (patch from Nikolai Weibull
-				2003 Jan 13)
 	filter()		Patch from Yegappan Lakshmanan, 2004 Jul 11
     8   Make it possible to delete marks.  Charles Campbell has a patch that
 	does this with the markclear() function (2004 Jan 9).
@@ -63,6 +54,7 @@ For version 7.0:
 	When "filename" has no wildcards and there is no matching buffer, add
 	the buffer (unlisted).
     Patch for \xnn (Ciaran McCreesh)  2004 Jul 10
+	http://dev.gentoo.org/~ciaranm/patches/vim/vim-7.00a-regexp-numbered-characters-r5.patch
     7   Add 'taglistfiles' option, show file name and type when listing matching
 	tags name with CTRL-D completion.  Patch from Yegappan Lakshmanan.
 	2004 Jul 11
@@ -72,6 +64,15 @@ For version 7.0:
     8   Make 'statusline' local, so that each window can have a different
 	value.  But should it also be local to a buffer? (Yegappan Lakshmanan
 	has a patch, 2004 Jul 11)
+    8   Add buffer-local autocommands?  Reduces overhead for autocommands that
+	trigger often (inserting a character, switching mode).
+	    :au Event <buffer> do-something
+	E.g.:
+	    :au BufEnter <buffer> menu enable ...
+	    :au BufLeave <buffer> menu disable ...
+	Patch from Yakov Lerner, including test (2004 Jan 7).
+	VimResized	    - When the Vim window has been resized (SIGWINCH)
+	  patch from Yakov Lerner, 2003 July 24.
     --- awaiting updated patch ---
     7   Add patch from Wall for this one ( ~/Mail/oldmail/wall/in.00019 ):
 	'flipcase' variable: upper/lowercase pairs.
@@ -84,18 +85,7 @@ For version 7.0:
     8   Add ":n" to fnamemodify(): normalize path, remove "../" when possible.
 	Aric Blumer has a patch for this.
 	He will update the patch for 6.3.
-    8   Add buffer-local autocommands?  Reduces overhead for autocommands that
-	trigger often (inserting a character, switching mode).
-	    :au Event <buffer> do-something
-	E.g.:
-	    :au BufEnter <buffer> menu enable ...
-	    :au BufLeave <buffer> menu disable ...
-	Patch from Yakov Lerner, including test (2004 Jan 7).
-        He'll send updated patch.
     Autocommands:
-	VimResized	    - When the Vim window has been resized (SIGWINCH)
-	  patch from Yakov Lerner, 2003 July 24.
-	  He'll write documentation and send updated patch.
     7   Completion of network shares, patch by Yasuhiro Matsumoto.
 	Update 2004 Jun 17.
 	How does this work?  Missing comments.
@@ -1458,6 +1448,14 @@ 7   Add "n" flag to search() function, j
 7   Add argument to winwidth() to subtract the space taken by 'foldcolumn',
     signs and/or 'number'.
 8   Add functions:
+	search()		Add optional offset argument.
+	realname()		Get user name (first, last, full)
+				user_fullname() patch by Nikolai Weibull, Nov
+				3 2002
+				Only add this when also implemented for
+				non-Unix systems, otherwise a shell cmd could
+				be used.
+				get_user_name() gets login name.
 	menuprop({name}, {idx}, {what})
 				Get menu property of menu {name} item {idx}.
 				menuprop("", 1, "name") returns "File".
@@ -3196,6 +3194,7 @@ 8   Add commands to push and pop all or 
     column number.  Can use the code of ":helpgrep".
     Also support using "**" in filename, so that a directory tree can be
     searched.
+    Also see the "minigrep.vim" script on www.vim.org.
 -   Change ":fixdel" into option 'fixdel', t_del will be adjusted each time
     t_bs is set? (Webb)
 -   "gc": goto character, move absolute character positions forward, also
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -1,4 +1,4 @@
-*version7.txt*  For Vim version 7.0aa.  Last change: 2004 Jul 19
+*version7.txt*  For Vim version 7.0aa.  Last change: 2004 Jul 25
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -127,6 +127,9 @@ byteidx(expr, nr)	|byteidx()| 	Index of 
 finddir(name)		|finddir()|	Find a directory in 'path'.
 findfile(name)		|findfile()|	Find a file in 'path'. (Johannes
 					Zellner)
+getfperm(fname)		|getfperm()|	Get file permission string. (Nikolai
+					Weibull)
+getftype(fname)		|getftype()|	Get type of file. (Nikolai Weibull)
 repeat(expr, count)	|repeat()| 	Repeat "expr" "count" times.
 					(Christophe Poucet)
 tr(expr, from, to)	|tr()|		Translate characters. (Ron Aaron)
@@ -187,6 +190,11 @@ For lisp indenting and matching parenthe
 
 Added the "count" argument to match(), matchend() and matchstr(). (Ilya Sher)
 
+winnr() takes an optional "$" and "#" arguments.  (Nikolai Weibull, Yegappan
+Lakshmanan)
+
+Added 'n' flag to search(): don't move the cursor. (Nikolai Weibull)
+
 ==============================================================================
 COMPILE TIME CHANGES					*compile-changes-7*
 
@@ -272,4 +280,13 @@ items.
 The default for 'helplang' was "zh" for both "zh_cn" and "zh_tw".  Now use
 "cn" or "tw" as intended.
 
+When 'bin' is set and 'eol' is not set then line2byte() added the line break
+after the last line while it's not there.
+
+Using foldlevel() in a WinEnter autocommand may not work.  Noticed when
+resizing the GUI shell upon startup.
+
+Python: Using buffer.append(f.readlines()) didn't work.  Allow appending a
+string with a trailing newline.  The newline is ignored.
+
  vim:tw=78:ts=8:ft=help:norl:
--- a/runtime/ftplugin/lprolog.vim
+++ b/runtime/ftplugin/lprolog.vim
@@ -1,10 +1,10 @@
 " Vim settings file
 " Language:     LambdaProlog (Teyjus)
 " Maintainer:   Markus Mottl  <markus@oefai.at>
-" URL:		http://www.ai.univie.ac.at/~markus/vim/ftplugin/lprolog.vim
-" Last Change:	2003 May 11
-"		2001 Sep 16 - fixed 'no_mail_maps'-bug (MM)
-"		2001 Sep 02 - initial release  (MM)
+" URL:          http://www.oefai.at/~markus/vim/ftplugin/lprolog.vim
+" Last Change:  2001 Oct 02 - fixed uncommenting bug (MM)
+"               2001 Sep 16 - fixed 'no_mail_maps'-bug (MM)
+"               2001 Sep 02 - initial release  (MM)
 
 " Only do these settings when not done yet for this buffer
 if exists("b:did_ftplugin")
--- a/runtime/ftplugin/ocaml.vim
+++ b/runtime/ftplugin/ocaml.vim
@@ -1,12 +1,14 @@
 " Vim settings file
 " Language:     OCaml
-" Maintainers:  Mike Leary    <leary@nwlink.com>
-"		Markus Mottl  <markus@oefai.at>
-" URL:		http://www.ai.univie.ac.at/~markus/vim/ftplugin/ocaml.vim
-" Last Change:	2003 May 11
-"		2001 Nov 01 - added local bindings for inserting
-"			      type holes using 'assert false' (MM)
-"		2001 Oct 02 - insert spaces in line comments (MM)
+" Maintainers:  Mike Leary          <leary@nwlink.com>
+"               Markus Mottl        <markus@oefai.at>
+"               Stefano Zacchiroli  <zack@bononia.it>
+" URL:          http://www.oefai.at/~markus/vim/ftplugin/ocaml.vim
+" Last Change:  2004 Apr 12 - better .ml/.mli-switching without Python (SZ)
+"               2003 Nov 21 - match_words-patterns and .ml/.mli-switching (MM)
+"               2003 Oct 16 - re-entered variable 'did_ocaml_dtypes' (MM)
+"               2003 Oct 15 - added Stefano Zacchirolis (SZ) Python-code for
+"                             displaying type annotations (MM)
 
 " Only do these settings when not done yet for this buffer
 if exists("b:did_ftplugin")
@@ -47,3 +49,253 @@ if !exists("no_plugin_maps") && !exists(
     iabbrev <buffer> ASS (assert false)
   endif
 endif
+
+" Let % jump between structure elements (due to Issac Trotts)
+let b:mw='\<let\>:\<and\>:\(\<in\>\|;;\),'
+let b:mw=b:mw . '\<if\>:\<then\>:\<else\>,\<do\>:\<done\>,'
+let b:mw=b:mw . '\<\(object\|sig\|struct\|begin\)\>:\<end\>'
+let b:match_words=b:mw
+
+" switching between interfaces (.mli) and implementations (.ml)
+if !exists("g:did_ocaml_switch")
+  let g:did_ocaml_switch = 1
+  map ,s :call OCaml_switch(0)<CR>
+  map ,S :call OCaml_switch(1)<CR>
+  fun OCaml_switch(newwin)
+    if (match(bufname(""), "\\.mli$") >= 0)
+      let fname = substitute(bufname(""), "\\.mli$", ".ml", "")
+      if (a:newwin == 1)
+	exec "new " . fname
+      else
+	exec "arge " . fname
+      endif
+    elseif (match(bufname(""), "\\.ml$") >= 0)
+      let fname = bufname("") . "i"
+      if (a:newwin == 1)
+	exec "new " . fname
+      else
+	exec "arge " . fname
+      endif
+    endif
+  endfun
+endif
+
+" Vim support for OCaml 3.07 .annot files (requires Vim with python support)
+"
+" Executing OCamlPrintType(<mode>) function will display in the Vim bottom
+" line(s) the type of an ocaml value getting it from the corresponding .annot
+" file (if any).  If Vim is in visual mode, <mode> should be "visual" and the
+" selected ocaml value correspond to the highlighted text, otherwise (<mode>
+" can be anything else) it corresponds to the literal found at the current
+" cursor position.
+"
+" .annot files are parsed lazily the first time OCamlPrintType is invoked; is
+" also possible to force the parsing using the OCamlParseAnnot() function.
+"
+" Hitting the <F3> key will cause OCamlPrintType function to be invoked with
+" the right argument depending on the current mode (visual or not).
+"
+" Copyright (C) <2003> Stefano Zacchiroli <zack@bononia.it>
+"
+" Created:        Wed, 01 Oct 2003 18:16:22 +0200 zack
+" LastModified:   Mon, 06 Oct 2003 11:05:39 +0200 zack
+"
+" This program is free software; you can redistribute it and/or modify
+" it under the terms of the GNU General Public License as published by
+" the Free Software Foundation; either version 2 of the License, or
+" (at your option) any later version.
+"
+" This program is distributed in the hope that it will be useful,
+" but WITHOUT ANY WARRANTY; without even the implied warranty of
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+" GNU General Public License for more details.
+"
+" You should have received a copy of the GNU General Public License
+" along with this program; if not, write to the Free Software
+" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+"
+
+if !has("python")
+  echo "Python support not found: OCaml .annot support disabled"
+  finish
+endif
+
+if !exists("g:did_ocaml_dtypes")
+  let g:did_ocaml_dtypes = 1
+else
+  finish
+endif
+
+python << EOF
+
+import re
+import os
+import string
+import time
+import vim
+
+debug = False
+
+class AnnExc(Exception):
+    def __init__(self, reason):
+        self.reason = reason
+
+no_annotations = AnnExc("No type annotations (.annot) file found")
+annotation_not_found = AnnExc("No type annotation found for the given text")
+def malformed_annotations(lineno):
+    return AnnExc("Malformed .annot file (line = %d)" % lineno)
+
+class Annotations:
+    """
+      .annot ocaml file representation
+
+      File format (copied verbatim from caml-types.el)
+
+      file ::= block *
+      block ::= position <SP> position <LF> annotation *
+      position ::= filename <SP> num <SP> num <SP> num
+      annotation ::= keyword open-paren <LF> <SP> <SP> data <LF> close-paren
+
+      <SP> is a space character (ASCII 0x20)
+      <LF> is a line-feed character (ASCII 0x0A)
+      num is a sequence of decimal digits
+      filename is a string with the lexical conventions of O'Caml
+      open-paren is an open parenthesis (ASCII 0x28)
+      close-paren is a closed parenthesis (ASCII 0x29)
+      data is any sequence of characters where <LF> is always followed by
+           at least two space characters.
+
+      - in each block, the two positions are respectively the start and the
+      - end of the range described by the block.
+      - in a position, the filename is the name of the file, the first num
+        is the line number, the second num is the offset of the beginning
+        of the line, the third num is the offset of the position itself.
+      - the char number within the line is the difference between the third
+        and second nums.
+
+      For the moment, the only possible keyword is \"type\"."
+    """
+
+    def __init__(self):
+        self.__filename = None  # last .annot parsed file
+        self.__ml_filename = None # as above but s/.annot/.ml/
+        self.__timestamp = None # last parse action timestamp
+        self.__annot = {}
+        self.__re = re.compile(
+          '^"[^"]+"\s+(\d+)\s+(\d+)\s+(\d+)\s+"[^"]+"\s+(\d+)\s+(\d+)\s+(\d+)$')
+
+    def __parse(self, fname):
+        try:
+            f = open(fname)
+            line = f.readline() # position line
+            lineno = 1
+            while (line != ""):
+                m = self.__re.search(line)
+                if (not m):
+                    raise malformed_annotations(lineno)
+                line1 = int(m.group(1))
+                col1 = int(m.group(3)) - int(m.group(2))
+                line2 = int(m.group(4))
+                col2 = int(m.group(6)) - int(m.group(5))
+                line = f.readline() # "type(" string
+                lineno += 1
+                if (line == ""): raise malformed_annotations(lineno)
+                type = []
+                line = f.readline() # type description
+                lineno += 1
+                if (line == ""): raise malformed_annotations(lineno)
+                while line != ")\n":
+                    type.append(string.strip(line))
+                    line = f.readline()
+                    lineno += 1
+                    if (line == ""): raise malformed_annotations(lineno)
+                type = string.join(type, "\n")
+                self.__annot[(line1, col1), (line2, col2)] = type
+                line = f.readline() # position line
+            f.close()
+            self.__filename = fname
+            self.__ml_filename = re.sub("\.annot$", ".ml", fname)
+            self.__timestamp = int(time.time())
+        except IOError:
+            raise no_annotations
+
+    def parse(self):
+        annot_file = re.sub("\.ml$", ".annot", vim.current.buffer.name)
+        self.__parse(annot_file)
+
+    def get_type(self, (line1, col1), (line2, col2)):
+        if debug:
+            print line1, col1, line2, col2
+        if vim.current.buffer.name == None:
+            raise no_annotations
+        if vim.current.buffer.name != self.__ml_filename or  \
+          os.stat(self.__filename).st_mtime > self.__timestamp:
+            self.parse()
+        try:
+            return self.__annot[(line1, col1), (line2, col2)]
+        except KeyError:
+            raise annotation_not_found
+
+word_char_RE = re.compile("^[\w.]$")
+
+  # TODO this function should recognize ocaml literals, actually it's just an
+  # hack that recognize continuous sequences of word_char_RE above
+def findBoundaries(line, col):
+    """ given a cursor position (as returned by vim.current.window.cursor)
+    return two integers identify the beggining and end column of the word at
+    cursor position, if any. If no word is at the cursor position return the
+    column cursor position twice """
+    left, right = col, col
+    line = line - 1 # mismatch vim/python line indexes
+    (begin_col, end_col) = (0, len(vim.current.buffer[line]) - 1)
+    try:
+        while word_char_RE.search(vim.current.buffer[line][left - 1]):
+            left = left - 1
+    except IndexError:
+        pass
+    try:
+        while word_char_RE.search(vim.current.buffer[line][right + 1]):
+            right = right + 1
+    except IndexError:
+        pass
+    return (left, right)
+
+annot = Annotations() # global annotation object
+
+def printOCamlType(mode):
+    try:
+        if mode == "visual":  # visual mode: lookup highlighted text
+            (line1, col1) = vim.current.buffer.mark("<")
+            (line2, col2) = vim.current.buffer.mark(">")
+        else: # any other mode: lookup word at cursor position
+            (line, col) = vim.current.window.cursor
+            (col1, col2) = findBoundaries(line, col)
+            (line1, line2) = (line, line)
+        begin_mark = (line1, col1)
+        end_mark = (line2, col2 + 1)
+        print annot.get_type(begin_mark, end_mark)
+    except AnnExc, exc:
+        print exc.reason
+
+def parseOCamlAnnot():
+    try:
+        annot.parse()
+    except AnnExc, exc:
+        print exc.reason
+
+EOF
+
+fun OCamlPrintType(current_mode)
+  if (a:current_mode == "visual")
+    python printOCamlType("visual")
+  else
+    python printOCamlType("normal")
+  endif
+endfun
+
+fun OCamlParseAnnot()
+  python parseOCamlAnnot()
+endfun
+
+map <F3> :call OCamlPrintType("normal")<RETURN>
+vmap <F3> :call OCamlPrintType("visual")<RETURN>
--- a/runtime/indent/ocaml.vim
+++ b/runtime/indent/ocaml.vim
@@ -1,12 +1,12 @@
 " Vim indent file
-" Language:	OCaml
-" Maintainers:	Jean-Francois Yuen  <jfyuen@ifrance.com>
-"		Mike Leary	    <leary@nwlink.com>
-"		Markus Mottl	    <markus@oefai.at>
-" URL:		http://www.oefai.at/~markus/vim/indent/ocaml.vim
-" Last Change:	2003 Apr 14
-"		2003 Mar 05 - Added '{<' and some fixes (JY)
-"		2002 Nov 06 - Some fixes (JY)
+" Language:     OCaml
+" Maintainers:  Jean-Francois Yuen  <jfyuen@happycoders.org>
+"               Mike Leary          <leary@nwlink.com>
+"               Markus Mottl        <markus@oefai.at>
+" URL:          http://www.oefai.at/~markus/vim/indent/ocaml.vim
+" Last Change:  2004 Apr 11 - Added indent for 'class' (JY)
+"               2003 Sep 16 - Added 'private' as keyword (JY)
+"               2003 Mar 29 - Fixed bug with 'if' and 'else' (JY)
 
 " Only load this indent file when no other was loaded.
 if exists("b:did_indent")
@@ -16,7 +16,7 @@ let b:did_indent = 1
 
 setlocal expandtab
 setlocal indentexpr=GetOCamlIndent()
-setlocal indentkeys+=0=and,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=initializer,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0=;;,0=>\],0=\|\],0=\|,0=*),0=>},0},0\],0)
+setlocal indentkeys+=0=and,0=class,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=initializer,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0;;,0>\],0\|\],0>},0\|,0},0\],0)
 setlocal nolisp
 setlocal nosmartindent
 setlocal textwidth=80
@@ -33,14 +33,13 @@ if exists("*GetOCamlIndent")
 endif
 
 " Define some patterns:
-let s:beflet = '^\s*\(initializer\|method\|try\)\|\(\<\(begin\|do\|else\|in\|then\|try\)\|->\|;\|(\)\s*$'
+let s:beflet = '^\s*\(initializer\|method\|try\)\|\(\<\(begin\|do\|else\|in\|then\|try\)\|->\|<-\|=\|;\|(\)\s*$'
 let s:letpat = '^\s*\(let\|type\|module\|class\|open\|exception\|val\|include\|external\)\>'
 let s:letlim = '\(\<\(sig\|struct\)\|;;\)\s*$'
 let s:lim = '^\s*\(exception\|external\|include\|let\|module\|open\|type\|val\)\>'
 let s:module = '\<\%(begin\|sig\|struct\|object\)\>'
 let s:obj = '^\s*\(constraint\|inherit\|initializer\|method\|val\)\>\|\<\(object\|object\s*(.*)\)\s*$'
-let s:type = '^\s*\%(let\|type\)\>.*='
-let s:val = '^\s*\(val\|external\)\>.*:'
+let s:type = '^\s*\%(class\|let\|type\)\>.*='
 
 " Skipping pattern, for comments
 function s:SkipPattern(lnum, pat)
@@ -75,7 +74,7 @@ endfunction
 " Indent 'let'
 function s:FindLet(pstart, pmid, pend)
   call search(a:pend, 'bW')
-  return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "^\\s*let\\>.*=.*\\<in\\s*$" || getline(prevnonblank(".") - 1) =~ "^\\s*let\\>.*=\\s*$\\|" . s:beflet'))
+  return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "^\\s*let\\>.*=.*\\<in\\s*$" || getline(prevnonblank(".") - 1) =~ s:beflet'))
 endfunction
 
 function GetOCamlIndent()
@@ -97,8 +96,7 @@ function GetOCamlIndent()
 
   let line = getline(v:lnum)
 
-  " Indent if current line begins with 'end'
-  " for 'sig', 'struct', 'object' and 'begin':
+  " Indent if current line begins with 'end':
   if line =~ '^\s*end\>'
     return s:FindPair(s:module, '','\<end\>')
 
@@ -118,27 +116,25 @@ function GetOCamlIndent()
   elseif line =~ '^\s*)'
     return s:FindPair('(', '',')')
 
-  " Indent if current line begins with 'let'
-  " and last line does not begin with 'let' or end with 'in' or ';;':
+  " Indent if current line begins with 'let':
   elseif line =~ '^\s*let\>'
     if lline !~ s:lim . '\|' . s:letlim . '\|' . s:beflet
       return s:FindLet(s:type, '','\<let\s*$')
     else return ind
     endif
 
-  " Indent if current line begins with 'type'
-  " and last line does not end with 'and' or ';;':
-  elseif line =~ '^\s*type\>'
+  " Indent if current line begins with 'class' or 'type':
+  elseif line =~ '^\s*\(class\|type\)\>'
     if lline !~ s:lim . '\|\<and\s*$\|' . s:letlim
-      return s:FindLet(s:type, '','\<type\s*$')
+      return s:FindLet(s:type, '','\<\(class\|type\)\s*$')
     else return ind
     endif
 
   " Indent for pattern matching:
   elseif line =~ '^\s*|'
-    if lline !~ '^\s*\(|\|\(match\|with\|type\)\>\)\|\<\(function\|parser\|with\)\s*$'
+    if lline !~ '^\s*\(|[^\]]\|\(match\|type\|with\)\>\)\|\<\(function\|parser\|private\|with\)\s*$'
       call search('|', 'bW')
-      return indent(searchpair('^\s*\(type\|match\)\>\|\<\(with\|function\|parser\)\s*$', '', '|', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "\\[|\\||\\]" && getline(".") !~ "^\\s*|.*->"'))
+      return indent(searchpair('^\s*\(match\|type\)\>\|\<\(function\|parser\|private\|with\)\s*$', '', '^\s*|', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") !~ "^\\s*|.*->"'))
     else return ind
     endif
 
@@ -149,41 +145,35 @@ function GetOCamlIndent()
     else return ind
     endif
 
-  " Indent if current line begins with 'in' and previous
-  " line does not start with 'let' or 'and':
+  " Indent if current line begins with 'in':
   elseif line =~ '^\s*in\>'
     if lline !~ '^\s*\(let\|and\)\>'
       return s:FindPair('\<let\>', '', '\<in\>')
     else return ind
     endif
 
-  " Indent if current line begins with 'else'
-  " and previous line does not start with 'if', 'then' or 'else':
+  " Indent if current line begins with 'else':
   elseif line =~ '^\s*else\>'
-    if lline !~ '^\s*\(if\|else\|then\)\>'
+    if lline !~ '^\s*\(if\|then\)\>'
       return s:FindPair('\<if\>', '', '\<else\>')
     else return ind
     endif
 
-  " Indent if current line begins with 'then'
-  " and previous line does not start with 'if', 'then' or 'else':
+  " Indent if current line begins with 'then':
   elseif line =~ '^\s*then\>'
-    if lline !~ '^\s*\(if\|else\|then\)\>'
+    if lline !~ '^\s*\(if\|else\)\>'
       return s:FindPair('\<if\>', '', '\<then\>')
     else return ind
     endif
 
-  " Subtract a 'shiftwidth' if current line begins with 'and' and previous
-  " line does not start with 'let', 'and' or 'type' or end with 'end'
-  " (for classes):
+  " Indent if current line begins with 'and':
   elseif line =~ '^\s*and\>'
     if lline !~ '^\s*\(and\|let\|type\)\>\|\<end\s*$'
       return ind - &sw
     else return ind
     endif
 
-  " Indent if current line begins with 'with'
-  " and previous line does not start with 'match' or 'try':
+  " Indent if current line begins with 'with':
   elseif line =~ '^\s*with\>'
     if lline !~ '^\s*\(match\|try\)\>'
       return s:FindPair('\<\%(match\|try\)\>', '','\<with\>')
@@ -193,35 +183,35 @@ function GetOCamlIndent()
   " Indent if current line begins with 'exception':
   elseif line =~ '^\s*exception\>'
     if lline !~ s:lim . '\|' . s:letlim
-      return indent(search(s:val . '\|^\s*\(external\|include\|open\|type\)\>', 'bW'))
+      return indent(search('^\s*\(\(external\|include\|open\|type\)\>\|val\>.*:\)', 'bW'))
     else return ind
     endif
 
   " Indent if current line begins with 'external':
   elseif line =~ '^\s*external\>'
     if lline !~ s:lim . '\|' . s:letlim
-      return indent(search(s:val . '\|^\s*\(exception\|include\|open\|type\)\>', 'bW'))
+      return indent(search('^\s*\(\(exception\|external\|include\|open\|type\)\>\|val\>.*:\)', 'bW'))
     else return ind
     endif
 
   " Indent if current line begins with 'include':
   elseif line =~ '^\s*include\>'
     if lline !~ s:lim . '\|' . s:letlim
-      return indent(search(s:val . '\|^\s*\(exception\|external\|open\|type\)\>', 'bW'))
+      return indent(search('^\s*\(\(exception\|external\|open\|type\)\>\|val\>.*:\)', 'bW'))
     else return ind
     endif
 
   " Indent if current line begins with 'open':
   elseif line =~ '^\s*open\>'
     if lline !~ s:lim . '\|' . s:letlim
-      return indent(search(s:val . '\|^\s*\(exception\|external\|include\|type\)\>', 'bW'))
+      return indent(search('^\s*\(\(exception\|external\|include\|type\)\>\|val\>.*:\)', 'bW'))
     else return ind
     endif
 
   " Indent if current line begins with 'val':
   elseif line =~ '^\s*val\>'
     if lline !~ '^\s*\(exception\|external\|include\|open\)\>\|' . s:obj . '\|' . s:letlim
-      return indent(search(s:val . '\|^\s*\(exception\|include\|initializer\|method\|open\|type\)\>', 'bW'))
+      return indent(search('^\s*\(\(exception\|include\|initializer\|method\|open\|type\|val\)\>\|external\>.*:\)', 'bW'))
     else return ind
     endif
 
@@ -253,15 +243,10 @@ function GetOCamlIndent()
     else return ind
     endif
 
-  " Indent back to normal after comments:
-  elseif line =~ '^\s*\*)'
-    call search('\*)', 'bW')
-    return indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"'))
-
   endif
 
   " Add a 'shiftwidth' after lines ending with:
-  if lline =~ '\(:\|=\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|struct\|sig\|functor\|initializer\|object\|try\|do\|if\|then\|else\|fun\|function\|parser\)\|\<object\s*(.*)\)\s*$'
+  if lline =~ '\(:\|=\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|do\|else\|fun\|function\|functor\|if\|initializer\|object\|parser\|private\|sig\|struct\|then\|try\)\|\<object\s*(.*)\)\s*$'
     let ind = ind + &sw
 
   " Back to normal indent after lines ending with ';;':
--- a/runtime/indent/python.vim
+++ b/runtime/indent/python.vim
@@ -2,7 +2,7 @@
 " Language:	Python
 " Maintainer:	Bram Moolenaar <Bram@vim.org>
 " Original Author:	David Bustos <bustos@caltech.edu>
-" Last Change:	2004 Jun 15
+" Last Change:	2004 Jul 25
 
 " Only load this indent file when no other was loaded.
 if exists("b:did_indent")
@@ -99,15 +99,36 @@ function GetPythonIndent(lnum)
   " Use syntax highlighting attributes when possible.
   let pline = getline(plnum)
   let pline_len = strlen(pline)
-  let col = 0
-  while col < pline_len
-    if pline[col] == '#' && (!has('syntax_items')
-	    \ || synIDattr(synID(plnum, col + 1, 1), "name") =~ "Comment$")
-      let pline = strpart(pline, 0, col)
-      break
+  if has('syntax_items')
+    " If the last character in the line is a comment, do a binary search for
+    " the start of the comment.  synID() is slow, a linear search would take
+    " too long on a long line.
+    if synIDattr(synID(plnum, pline_len, 1), "name") =~ "Comment$"
+      let min = 1
+      let max = pline_len
+      while min < max
+	let col = (min + max) / 2
+	if synIDattr(synID(plnum, col, 1), "name") =~ "Comment$"
+	  let max = col
+	else
+	  let min = col + 1
+	endif
+      endwhile
+      echomsg min
+      let pline = strpart(pline, 0, min - 1)
+      echomsg pline  
+      sleep 1
     endif
-    let col = col + 1
-  endwhile
+  else
+    let col = 0
+    while col < pline_len
+      if pline[col] == '#'
+	let pline = strpart(pline, 0, col)
+	break
+      endif
+      let col = col + 1
+    endwhile
+  endif
 
   " If the previous line ended with a colon, indent this line
   if pline =~ ':\s*$'
--- a/runtime/syntax/dot.vim
+++ b/runtime/syntax/dot.vim
@@ -2,9 +2,9 @@
 " Language:     Dot
 " Filenames:    *.dot
 " Maintainer:   Markus Mottl  <markus@oefai.at>
-" URL:		http://www.ai.univie.ac.at/~markus/vim/syntax/dot.vim
-" Last Change:	2003 May 11
-"		2001 May 04 - initial version
+" URL:          http://www.oefai.at/~markus/vim/syntax/dot.vim
+" Last Change:  2004 Jul 26
+"               2001 May 04 - initial version
 
 " For version 5.x: Clear all syntax items
 " For version 6.x: Quit when a syntax file was already loaded
--- a/runtime/syntax/idl.vim
+++ b/runtime/syntax/idl.vim
@@ -1,203 +1,314 @@
 " Vim syntax file
-" Language:	IDL (Interface Description Language)
-" Maintainer:	Jody Goldberg <jgoldberg@home.com> or <jody@gnome.org>
-" Last Change:	2004 Jul 12
+" Language:    IDL (Interface Description Language)
+" Created By:  Jody Goldberg <jody@gnome.org>
+" Maintainer:  Michael Geddes <michaelrgeddes@optushome.com.au>
+" Last Change:  2004 Jul 20
 
 " This is an experiment.  IDL's structure is simple enough to permit a full
 " grammar based approach to rather than using a few heuristics.  The result
 " is large and somewhat repetative but seems to work.
 
-" For version 5.x: Clear all syntax items
-" For version 6.x: Quit when a syntax file was already loaded
-if version < 600
-  syntax clear
-elseif exists("b:current_syntax")
+" There are some Microsoft extensions to idl files that are here.  Some of
+" them are disabled by defining idl_no_ms_extensions.
+"
+" The more complex of the extensions are disabled by defining idl_no_extensions.
+"
+
+if exists("b:current_syntax")
   finish
 endif
 
+if exists("idlsyntax_showerror")
+  syn match idlError +\S+ skipwhite skipempty nextgroup=idlError
+endif
+
+syn region idlCppQuote start='\<cpp_quote\s*(' end=')' contains=idlString
+
 " Misc basic
-syn match	idlId		contained "[a-zA-Z][a-zA-Z0-9_]*"
-syn match	idlSemiColon	contained ";"
-syn match	idlCommaArg	contained ","			skipempty skipwhite nextgroup=idlSimpDecl
-syn region	idlArraySize1	contained start=:\[: end=:\]:	skipempty skipwhite nextgroup=idlArraySize1,idlSemiColon,idlCommaArg contains=idlArraySize1,idlLiteral
-syn match   idlSimpDecl	 contained "[a-zA-Z][a-zA-Z0-9_]*"	skipempty skipwhite nextgroup=idlSemiColon,idlCommaArg,idlArraySize1
-syn region  idlSting	 contained start=+"+  skip=+\\\(\\\\\)*"+  end=+"+
-syn match   idlLiteral	 contained "[1-9]\d*\(\.\d*\)\="
-syn match   idlLiteral	 contained "\.\d\+"
-syn keyword idlLiteral	 contained TRUE FALSE
+syn match   idlId          contained "[a-zA-Z][a-zA-Z0-9_]*" skipwhite skipempty nextgroup=idlEnumComma,idlEnumNumber
+syn match   idlEnumComma   contained ","
+syn match   idlEnumNumber  contained "=" skipwhite skipempty nextgroup=idlString,idlLiteral
+syn match   idlSemiColon   contained ";"
+syn match   idlCommaArg    contained ","                      skipempty skipwhite nextgroup=idlSimpDecl
+syn region  idlArraySize1  contained start=:\[: end=:\]:      skipempty skipwhite nextgroup=idlArraySize1,idlError,idlSemiColon,idlCommaArg contains=idlArraySize1,idlLiteral
+syn match   idlSimpDecl    contained "[a-zA-Z][a-zA-Z0-9_]*"  skipempty skipwhite nextgroup=idlError,idlSemiColon,idlCommaArg,idlArraySize1
+syn region  idlString      contained start=+"+  skip=+\\\(\\\\\)*"+  end=+"+
+syn match   idlLiteral     contained "[1-9]\d*\(\.\d*\)\="
+syn match   idlLiteral     contained "0"
+syn match   idlLiteral     contained "\.\d\+"
+syn match   idlLiteral     contained "0x[0-9A-Fa-f]\+"
+syn match   idlLiteral     contained "0[0-7]\+"
+syn keyword idlLiteral     contained TRUE FALSE
 
 " Comments
-syn keyword idlTodo contained	TODO FIXME XXX
-syn region idlComment		start="/\*"  end="\*/" contains=idlTodo
-syn match  idlComment		"//.*" contains=idlTodo
-syn match  idlCommentError	"\*/"
+syn keyword idlTodo        contained TODO FIXME XXX
+syn region idlComment      start="/\*"  end="\*/" contains=idlTodo
+syn match  idlComment      "//.*" contains=idlTodo
+syn match  idlCommentError "\*/"
 
 " C style Preprocessor
-syn region idlIncluded contained start=+"+  skip=+\\\(\\\\\)*"+  end=+"+
-syn match  idlIncluded contained "<[^>]*>"
-syn match  idlInclude		"^[ \t]*#[ \t]*include\>[ \t]*["<]" contains=idlIncluded,idlString
-syn region idlPreCondit	start="^[ \t]*#[ \t]*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)"  skip="\\$"  end="$" contains=idlComment,idlCommentError
-syn region idlDefine	start="^[ \t]*#[ \t]*\(define\>\|undef\>\)" skip="\\$" end="$" contains=idlLiteral, idlString
+syn region idlIncluded    contained start=+"+  skip=+\\\(\\\\\)*"+  end=+"+
+syn match  idlIncluded    contained "<[^>]*>"
+syn match  idlInclude     "^[ \t]*#[ \t]*include\>[ \t]*["<]" contains=idlIncluded,idlString
+syn region idlPreCondit   start="^[ \t]*#[ \t]*\(if\>\|ifdef\>\|ifndef\>\|elif\>\|else\>\|endif\>\)"  skip="\\$"  end="$" contains=idlComment,idlCommentError
+syn region idlDefine      start="^[ \t]*#[ \t]*\(define\>\|undef\>\)" skip="\\$" end="$" contains=idlLiteral,idlString
 
 " Constants
-syn keyword idlConst	const	skipempty skipwhite nextgroup=idlBaseType,idlBaseTypeInt
+syn keyword idlConst    const                             skipempty skipwhite nextgroup=idlBaseType,idlBaseTypeInt
 
 " Attribute
-syn keyword idlROAttr	readonly	skipempty skipwhite nextgroup=idlAttr
-syn keyword idlAttr	attribute	skipempty skipwhite nextgroup=idlBaseTypeInt,idlBaseType
+syn keyword idlROAttr   readonly                          skipempty skipwhite nextgroup=idlAttr
+syn keyword idlAttr     attribute                         skipempty skipwhite nextgroup=idlBaseTypeInt,idlBaseType
 
 " Types
-syn region  idlD4	contained start="<" end=">"	skipempty skipwhite nextgroup=idlSimpDecl	contains=idlSeqType,idlBaseTypeInt,idlBaseType,idlLiteral
-syn keyword idlSeqType	contained sequence		skipempty skipwhite nextgroup=idlD4
-syn keyword idlBaseType		contained	float double char boolean octet any	skipempty skipwhite nextgroup=idlSimpDecl
-syn keyword idlBaseTypeInt	contained	short long		skipempty skipwhite nextgroup=idlSimpDecl
-syn keyword idlBaseType		contained	unsigned		skipempty skipwhite nextgroup=idlBaseTypeInt
-syn region  idlD1		contained	start="<" end=">"	skipempty skipwhite nextgroup=idlSimpDecl	contains=idlString,idlLiteral
-syn keyword idlBaseType		contained	string	skipempty skipwhite nextgroup=idlD1,idlSimpDecl
-syn match   idlBaseType		contained	"[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*"	skipempty skipwhite nextgroup=idlSimpDecl
+syn region  idlD4          contained start="<" end=">"    skipempty skipwhite nextgroup=idlSimpDecl contains=idlSeqType,idlBaseTypeInt,idlBaseType,idlLiteral
+syn keyword idlSeqType     contained sequence             skipempty skipwhite nextgroup=idlD4
+syn keyword idlBaseType    contained float double char boolean octet any skipempty skipwhite nextgroup=idlSimpDecl
+syn keyword idlBaseTypeInt contained short long           skipempty skipwhite nextgroup=idlSimpDecl
+syn keyword idlBaseType    contained unsigned             skipempty skipwhite nextgroup=idlBaseTypeInt
+syn region  idlD1          contained start="<" end=">"    skipempty skipwhite nextgroup=idlSimpDecl contains=idlString,idlLiteral
+syn keyword idlBaseType    contained string               skipempty skipwhite nextgroup=idlD1,idlSimpDecl
+syn match   idlBaseType    contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*"  skipempty skipwhite nextgroup=idlSimpDecl
 
 " Modules
-syn region  idlModuleContent contained start="{" end="}"	skipempty skipwhite nextgroup=idlSemiColon contains=idlUnion,idlStruct,idlEnum,idlInterface,idlComment,idlTypedef,idlConst,idlException,idlModule
-syn match   idlModuleName contained	"[a-zA-Z0-9_]\+"	skipempty skipwhite nextgroup=idlModuleContent,idlSemiColon
-syn keyword idlModule			module			skipempty skipwhite nextgroup=idlModuleName
+syn region  idlModuleContent contained start="{" end="}"  skipempty skipwhite nextgroup=idlError,idlSemiColon contains=idlUnion,idlStruct,idlEnum,idlInterface,idlComment,idlTypedef,idlConst,idlException,idlModule
+syn match   idlModuleName  contained "[a-zA-Z0-9_]\+"     skipempty skipwhite nextgroup=idlModuleContent,idlError,idlSemiColon
+syn keyword idlModule      module                         skipempty skipwhite nextgroup=idlModuleName
 
 " Interfaces
-syn region  idlInterfaceContent contained start="{" end="}"	skipempty skipwhite nextgroup=idlSemiColon contains=idlUnion,idlStruct,idlEnum,idlComment,idlROAttr,idlAttr,idlOp,idlOneWayOp,idlException,idlConst,idlTypedef
-syn match   idlInheritFrom2 contained "," skipempty skipwhite nextgroup=idlInheritFrom
-syn match idlInheritFrom contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlInheritFrom2,idlInterfaceContent
-syn match idlInherit contained	":"		skipempty skipwhite nextgroup=idlInheritFrom
-syn match   idlInterfaceName contained	"[a-zA-Z0-9_]\+"	skipempty skipwhite nextgroup=idlInterfaceContent,idlInherit,idlSemiColon
-syn keyword idlInterface		interface		skipempty skipwhite nextgroup=idlInterfaceName
+syn cluster idlCommentable contains=idlComment
+syn cluster idlContentCluster contains=idlUnion,idlStruct,idlEnum,idlROAttr,idlAttr,idlOp,idlOneWayOp,idlException,idlConst,idlTypedef,idlAttributes,idlErrorSquareBracket,idlErrorBracket,idlInterfaceSections
+
+syn region  idlInterfaceContent contained start="{" end="}"   skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlContentCluster,@idlCommentable
+syn match   idlInheritFrom2 contained ","                     skipempty skipwhite nextgroup=idlInheritFrom
+syn match   idlInheritFrom contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlInheritFrom2,idlInterfaceContent
+syn match   idlInherit contained ":"                            skipempty skipwhite nextgroup=idlInheritFrom
+syn match   idlInterfaceName contained "[a-zA-Z0-9_]\+"       skipempty skipwhite nextgroup=idlInterfaceContent,idlInherit,idlError,idlSemiColon
+syn keyword idlInterface     interface dispinterface          skipempty skipwhite nextgroup=idlInterfaceName
+syn keyword idlInterfaceSections contained properties methods skipempty skipwhite nextgroup=idlSectionColon,idlError
+syn match   idlSectionColon contained ":"
 
 
+syn match   idlLibraryName  contained  "[a-zA-Z0-9_]\+"       skipempty skipwhite nextgroup=idlLibraryContent,idlError,idlSemiColon
+syn keyword idlLibrary      library                           skipempty skipwhite nextgroup=idlLibraryName
+syn region  idlLibraryContent contained start="{" end="}"     skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlCommentable,idlAttributes,idlErrorSquareBracket,idlErrorBracket,idlImportlib,idlCoclass,idlTypedef,idlInterface
+
+syn keyword idlImportlib contained importlib                  skipempty skipwhite nextgroup=idlStringArg
+syn region idlStringArg contained start="(" end=")"           contains=idlString nextgroup=idlError,idlSemiColon,idlErrorBrace,idlErrorSquareBracket
+
+syn keyword idlCoclass coclass contained                      skipempty skipwhite nextgroup=idlCoclassName
+syn match   idlCoclassName "[a-zA-Z0-9_]\+" contained         skipempty skipwhite nextgroup=idlCoclassDefinition,idlError,idlSemiColon
+
+syn region idlCoclassDefinition contained start="{" end="}"   contains=idlCoclassAttributes,idlInterface,idlErrorBracket,idlErrorSquareBracket skipempty skipwhite nextgroup=idlError,idlSemiColon
+syn region idlCoclassAttributes contained start=+\[+ end=+]+  skipempty skipwhite nextgroup=idlInterface contains=idlErrorBracket,idlErrorBrace,idlCoclassAttribute
+syn keyword idlCoclassAttribute contained default source
+"syn keyword idlInterface       interface                      skipempty skipwhite nextgroup=idlInterfaceStubName
+
+syn match idlImportString       +"\f\+"+                      skipempty skipwhite nextgroup=idlError,idlSemiColon
+syn keyword idlImport           import                        skipempty skipwhite nextgroup=idlImportString
+
+syn region  idlAttributes start="\[" end="\]"                 contains=idlAttribute,idlAttributeParam,idlErrorBracket,idlErrorBrace,idlComment
+syn keyword idlAttribute contained propput propget propputref id helpstring object uuid pointer_default
+if !exists('idl_no_ms_extensions')
+syn keyword idlAttribute contained nonextensible dual version aggregatable restricted hidden noncreatable oleautomation
+endif
+syn region idlAttributeParam contained start="(" end=")"      contains=idlString,idlUuid,idlLiteral,idlErrorBrace,idlErrorSquareBracket
+" skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral
+syn match idlErrorBrace contained "}"
+syn match idlErrorBracket contained ")"
+syn match idlErrorSquareBracket contained "\]"
+
+syn match idlUuid         contained +[0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}+
+
 " Raises
-syn keyword idlRaises	contained raises	skipempty skipwhite nextgroup=idlRaises,idlContext,idlSemiColon
+syn keyword idlRaises     contained raises               skipempty skipwhite nextgroup=idlRaises,idlContext,idlError,idlSemiColon
 
 " Context
-syn keyword idlContext	contained context	skipempty skipwhite nextgroup=idlRaises,idlContext,idlSemiColon
+syn keyword idlContext    contained context              skipempty skipwhite nextgroup=idlRaises,idlContext,idlError,idlSemiColon
 
 " Operation
-syn match   idlParmList	contained "," skipempty skipwhite nextgroup=idlOpParms
-syn region  idlArraySize contained start="\[" end="\]"	skipempty skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral
-syn match   idlParmName contained "[a-zA-Z0-9_]\+"	skipempty skipwhite nextgroup=idlParmList,idlArraySize
-syn keyword idlParmInt	contained short long		skipempty skipwhite nextgroup=idlParmName
-syn keyword idlParmType	contained unsigned		skipempty skipwhite nextgroup=idlParmInt
-syn region  idlD3	contained start="<" end=">"	skipempty skipwhite nextgroup=idlParmName	contains=idlString,idlLiteral
-syn keyword idlParmType	contained string		skipempty skipwhite nextgroup=idlD3,idlParmName
-syn keyword idlParmType	contained void float double char boolean octet any	  skipempty skipwhite nextgroup=idlParmName
-syn match   idlParmType	contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlParmName
-syn keyword idlOpParms	contained in out inout		skipempty skipwhite nextgroup=idlParmType
+syn match   idlParmList   contained ","                  skipempty skipwhite nextgroup=idlOpParms
+syn region  idlArraySize  contained start="\[" end="\]"  skipempty skipwhite nextgroup=idlArraySize,idlParmList contains=idlArraySize,idlLiteral
+syn match   idlParmName   contained "[a-zA-Z0-9_]\+"     skipempty skipwhite nextgroup=idlParmList,idlArraySize
+syn keyword idlParmInt    contained short long           skipempty skipwhite nextgroup=idlParmName
+syn keyword idlParmType   contained unsigned             skipempty skipwhite nextgroup=idlParmInt
+syn region  idlD3         contained start="<" end=">"    skipempty skipwhite nextgroup=idlParmName contains=idlString,idlLiteral
+syn keyword idlParmType   contained string               skipempty skipwhite nextgroup=idlD3,idlParmName
+syn keyword idlParmType   contained void float double char boolean octet any    skipempty skipwhite nextgroup=idlParmName
+syn match   idlParmType   contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlParmName
+syn keyword idlOpParms    contained in out inout         skipempty skipwhite nextgroup=idlParmType
+
+if !exists('idl_no_ms_extensions')
+syn keyword idlOpParms    contained retval optional      skipempty skipwhite nextgroup=idlParmType
+  syn match idlOpParms contained +\<\(iid_is\|defaultvalue\)\s*([^)]*)+ skipempty skipwhite nextgroup=idlParamType
 
-syn region idlOpContents contained start="(" end=")"	skipempty skipwhite nextgroup=idlRaises,idlContext,idlSemiColon contains=idlOpParms
-syn match   idlOpName   contained "[a-zA-Z0-9_]\+"	skipempty skipwhite nextgroup=idlOpContents
-syn keyword idlOpInt	contained short long		skipempty skipwhite nextgroup=idlOpName
-syn region  idlD2	contained start="<" end=">"	skipempty skipwhite nextgroup=idlOpName	contains=idlString,idlLiteral
-syn keyword idlOp	contained unsigned		skipempty skipwhite nextgroup=idlOpInt
-syn keyword idlOp	contained string		skipempty skipwhite nextgroup=idlD2,idlOpName
-syn keyword idlOp	contained void float double char boolean octet any		skipempty skipwhite nextgroup=idlOpName
-syn match   idlOp	contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*"	skipempty skipwhite nextgroup=idlOpName
-syn keyword idlOp	contained void			skipempty skipwhite nextgroup=idlOpName
-syn keyword idlOneWayOp	contained oneway		skipempty skipwhite nextgroup=idOp
+  syn keyword idlVariantType  contained BSTR VARIANT VARIANT_BOOL long short unsigned double CURRENCY DATE
+  syn region idlSafeArray contained matchgroup=idlVariantType start=+SAFEARRAY(\s*+ end=+)+ contains=idlVariantType
+endif
+
+syn region  idlOpContents contained start="(" end=")"    skipempty skipwhite nextgroup=idlRaises,idlContext,idlError,idlSemiColon contains=idlOpParms,idlSafeArray,idlVariantType,@idlCommentable
+syn match   idlOpName   contained "[a-zA-Z0-9_]\+"       skipempty skipwhite nextgroup=idlOpContents
+syn keyword idlOpInt    contained short long             skipempty skipwhite nextgroup=idlOpName
+syn region  idlD2       contained start="<" end=">"      skipempty skipwhite nextgroup=idlOpName contains=idlString,idlLiteral
+syn keyword idlOp       contained unsigned               skipempty skipwhite nextgroup=idlOpInt
+syn keyword idlOp       contained string                 skipempty skipwhite nextgroup=idlD2,idlOpName
+syn keyword idlOp       contained void float double char boolean octet any  skipempty skipwhite nextgroup=idlOpName
+syn match   idlOp       contained "[a-zA-Z0-9_]\+[ \t]*\(::[ \t]*[a-zA-Z0-9_]\+\)*" skipempty skipwhite nextgroup=idlOpName
+syn keyword idlOp       contained void                   skipempty skipwhite nextgroup=idlOpName
+syn keyword idlOneWayOp contained oneway                 skipempty skipwhite nextgroup=idOp
 
 " Enum
-syn region  idlEnumContents contained start="{" end="}"		skipempty skipwhite nextgroup=idlSemiColon, idlSimpDecl contains=idlId,idlComment
-syn match   idlEnumName contained	"[a-zA-Z0-9_]\+"	skipempty skipwhite nextgroup=idlEnumContents
-syn keyword idlEnum			enum			skipempty skipwhite nextgroup=idlEnumName
+syn region  idlEnumContents contained start="{" end="}"  skipempty skipwhite nextgroup=idlError,idlSemiColon,idlSimpDecl contains=idlId,idlAttributes,@idlCommentable
+syn match   idlEnumName contained "[a-zA-Z0-9_]\+"       skipempty skipwhite nextgroup=idlEnumContents
+syn keyword idlEnum     enum                             skipempty skipwhite nextgroup=idlEnumName,idlEnumContents
 
 " Typedef
-syn keyword idlTypedef			typedef			skipempty skipwhite nextgroup=idlBaseType, idlBaseTypeInt, idlSeqType
+syn keyword idlTypedef typedef                          skipempty skipwhite nextgroup=idlTypedefOtherTypeQualifier,idlDefBaseType,idlDefBaseTypeInt,idlDefSeqType,idlDefv1Enum,idlDefEnum,idlDefOtherType,idlDefAttributes,idlError
+
+if !exists('idl_no_extensions')
+  syn keyword idlTypedefOtherTypeQualifier contained struct enum interface nextgroup=idlDefBaseType,idlDefBaseTypeInt,idlDefSeqType,idlDefv1Enum,idlDefEnum,idlDefOtherType,idlDefAttributes,idlError skipwhite
+
+  syn region  idlDefAttributes        contained start="\[" end="\]" contains=idlAttribute,idlAttributeParam,idlErrorBracket,idlErrorBrace skipempty skipwhite nextgroup=idlDefBaseType,idlDefBaseTypeInt,idlDefSeqType,idlDefv1Enum,idlDefEnum,idlDefOtherType,idlError
+
+  syn keyword idlDefBaseType      contained float double char boolean octet any  skipempty skipwhite nextgroup=idlTypedefDecl,idlError
+  syn keyword idlDefBaseTypeInt   contained short long                           skipempty skipwhite nextgroup=idlTypedefDecl,idlError
+  syn match idlDefOtherType       contained +\<\k\+\>+ skipempty                 nextgroup=idlTypedefDecl,idlError
+  " syn keyword idlDefSeqType     contained sequence                             skipempty skipwhite nextgroup=idlD4
+
+  " Enum typedef
+  syn keyword idlDefEnum          contained enum skipempty                       skipwhite nextgroup=idlDefEnumName,idlDefEnumContents
+  syn match   idlDefEnumName      contained "[a-zA-Z0-9_]\+"                     skipempty skipwhite nextgroup=idlDefEnumContents,idlTypedefDecl
+  syn region  idlDefEnumContents  contained start="{" end="}"                    skipempty skipwhite nextgroup=idlError,idlTypedefDecl contains=idlId,idlAttributes
+
+  syn match   idlTypedefDecl      contained "[a-zA-Z0-9_]\+"                     skipempty skipwhite nextgroup=idlError,idlSemiColon
+endif
 
 " Struct
-syn region  idlStructContent contained start="{" end="}" skipempty skipwhite nextgroup=idlSemiColon, idlSimpDecl	contains=idlBaseType, idlBaseTypeInt, idlSeqType,idlComment, idlEnum, idlUnion
-syn match   idlStructName contained	"[a-zA-Z0-9_]\+" skipempty skipwhite nextgroup=idlStructContent
-syn keyword idlStruct			struct		 skipempty skipwhite nextgroup=idlStructName
+syn region  idlStructContent   contained start="{" end="}"   skipempty skipwhite nextgroup=idlError,idlSemiColon,idlSimpDecl contains=idlBaseType,idlBaseTypeInt,idlSeqType,@idlCommentable,idlEnum,idlUnion
+syn match   idlStructName      contained "[a-zA-Z0-9_]\+"    skipempty skipwhite nextgroup=idlStructContent
+syn keyword idlStruct          struct                        skipempty skipwhite nextgroup=idlStructName
 
 " Exception
-syn keyword idlException exception skipempty skipwhite nextgroup=idlStructName
+syn keyword idlException       exception                     skipempty skipwhite nextgroup=idlStructName
 
 " Union
-syn match   idlColon contained ":"	skipempty skipwhite nextgroup=idlCase,idlSeqType,idlBaseType,idlBaseTypeInt
-syn region  idlCaseLabel contained start="" skip="::" end=":"me=e-1	skipempty skipwhite nextgroup=idlColon contains=idlLiteral,idlString
-syn keyword idlCase		contained case				skipempty skipwhite nextgroup=idlCaseLabel
-syn keyword idlCase		contained default			skipempty skipwhite nextgroup=idlColon
-syn region  idlUnionContent	contained start="{" end="}"		skipempty skipwhite nextgroup=idlSemiColon,idlSimpDecl	contains=idlCase
-syn region  idlSwitchType	contained start="(" end=")"		skipempty skipwhite nextgroup=idlUnionContent
-syn keyword idlUnionSwitch	contained switch			skipempty skipwhite nextgroup=idlSwitchType
-syn match   idlUnionName	contained "[a-zA-Z0-9_]\+"		skipempty skipwhite nextgroup=idlUnionSwitch
-syn keyword idlUnion		union				skipempty skipwhite nextgroup=idlUnionName
+syn match   idlColon            contained ":"                skipempty skipwhite nextgroup=idlCase,idlSeqType,idlBaseType,idlBaseTypeInt
+syn region  idlCaseLabel        contained start="" skip="::" end=":"me=e-1 skipempty skipwhite nextgroup=idlColon contains=idlLiteral,idlString
+syn keyword idlCase             contained case               skipempty skipwhite nextgroup=idlCaseLabel
+syn keyword idlCase             contained default            skipempty skipwhite nextgroup=idlColon
+syn region  idlUnionContent     contained start="{" end="}"  skipempty skipwhite nextgroup=idlError,idlSemiColon,idlSimpDecl contains=idlCase
+syn region  idlSwitchType       contained start="(" end=")"  skipempty skipwhite nextgroup=idlUnionContent
+syn keyword idlUnionSwitch      contained switch             skipempty skipwhite nextgroup=idlSwitchType
+syn match   idlUnionName        contained "[a-zA-Z0-9_]\+"   skipempty skipwhite nextgroup=idlUnionSwitch
+syn keyword idlUnion            union                        skipempty skipwhite nextgroup=idlUnionName
 
-syn sync lines=200
+if !exists('idl_no_extensions')
+  syn sync match  idlInterfaceSync grouphere idlInterfaceContent "\<\(disp\)\=interface\>\s\+\k\+\s*:\s*\k\+\_s*{" skipempty skipwhite nextgroup=idlError,idlSemiColon contains=@idlContentCluster,@idlCommentable
+  syn sync maxlines=1000 minlines=100
+else
+  syn sync lines=200
+endif
+" syn sync fromstart
+
+if !exists("did_idl_syntax_inits")
+  let did_idl_syntax_inits = 1
+  " The default methods for highlighting.  Can be overridden later
+  command -nargs=+ HiLink hi def link <args>
 
-" Define the default highlighting.
-" For version 5.7 and earlier: only when not done already
-" For version 5.8 and later: only when an item doesn't have highlighting yet
-if version >= 508 || !exists("did_idl_syntax_inits")
-  if version < 508
-    let did_idl_syntax_inits = 1
-    command -nargs=+ HiLink hi link <args>
-  else
-    command -nargs=+ HiLink hi def link <args>
-  endif
+  HiLink idlInclude             Include
+  HiLink idlPreProc             PreProc
+  HiLink idlPreCondit           PreCondit
+  HiLink idlDefine              Macro
+  HiLink idlIncluded            String
+  HiLink idlString              String
+  HiLink idlComment             Comment
+  HiLink idlTodo                Todo
+  HiLink idlLiteral             Number
+  HiLink idlUuid                Number
+  HiLink idlType                Type
+  HiLink idlVariantType         idlType
 
-  HiLink idlInclude		Include
-  HiLink idlPreProc		PreProc
-  HiLink idlPreCondit		PreCondit
-  HiLink idlDefine		Macro
-  HiLink idlIncluded		String
-  HiLink idlString		String
-  HiLink idlComment		Comment
-  HiLink idlTodo		Todo
-  HiLink idlLiteral		Number
+  HiLink idlModule              Keyword
+  HiLink idlInterface           Keyword
+  HiLink idlEnum                Keyword
+  HiLink idlStruct              Keyword
+  HiLink idlUnion               Keyword
+  HiLink idlTypedef             Keyword
+  HiLink idlException           Keyword
+  HiLink idlTypedefOtherTypeQualifier keyword
+
+  HiLink idlModuleName          Typedef
+  HiLink idlInterfaceName       Typedef
+  HiLink idlEnumName            Typedef
+  HiLink idlStructName          Typedef
+  HiLink idlUnionName           Typedef
 
-  HiLink idlModule		Keyword
-  HiLink idlInterface		Keyword
-  HiLink idlEnum		Keyword
-  HiLink idlStruct		Keyword
-  HiLink idlUnion		Keyword
-  HiLink idlTypedef		Keyword
-  HiLink idlException		Keyword
+  HiLink idlBaseTypeInt         idlType
+  HiLink idlBaseType            idlType
+  HiLink idlSeqType             idlType
+  HiLink idlD1                  Paren
+  HiLink idlD2                  Paren
+  HiLink idlD3                  Paren
+  HiLink idlD4                  Paren
+  "HiLink idlArraySize          Paren
+  "HiLink idlArraySize1         Paren
+  HiLink idlModuleContent       Paren
+  HiLink idlUnionContent        Paren
+  HiLink idlStructContent       Paren
+  HiLink idlEnumContents        Paren
+  HiLink idlInterfaceContent    Paren
 
-  HiLink idlModuleName		Typedef
-  HiLink idlInterfaceName	Typedef
-  HiLink idlEnumName		Typedef
-  HiLink idlStructName		Typedef
-  HiLink idlUnionName		Typedef
+  HiLink idlSimpDecl            Identifier
+  HiLink idlROAttr              StorageClass
+  HiLink idlAttr                Keyword
+  HiLink idlConst               StorageClass
+
+  HiLink idlOneWayOp            StorageClass
+  HiLink idlOp                  idlType
+  HiLink idlParmType            idlType
+  HiLink idlOpName              Function
+  HiLink idlOpParms             SpecialComment
+  HiLink idlParmName            Identifier
+  HiLink idlInheritFrom         Identifier
+  HiLink idlAttribute           SpecialComment
 
-  HiLink idlBaseTypeInt		idlType
-  HiLink idlBaseType		idlType
-  HiLink idlSeqType		idlType
-  HiLink idlD1			Paren
-  HiLink idlD2			Paren
-  HiLink idlD3			Paren
-  HiLink idlD4			Paren
-  "HiLink idlArraySize		Paren
-  "HiLink idlArraySize1		Paren
-  HiLink idlModuleContent	Paren
-  HiLink idlUnionContent	Paren
-  HiLink idlStructContent	Paren
-  HiLink idlEnumContents	Paren
-  HiLink idlInterfaceContent	Paren
+  HiLink idlId                  Constant
+  "HiLink idlCase               Keyword
+  HiLink idlCaseLabel           Constant
+
+  HiLink idlErrorBracket        Error
+  HiLink idlErrorBrace          Error
+  HiLink idlErrorSquareBracket  Error
 
-  HiLink idlSimpDecl		Identifier
-  HiLink idlROAttr		StorageClass
-  HiLink idlAttr		Keyword
-  HiLink idlConst		StorageClass
+  HiLink idlImport              Keyword
+  HiLink idlImportString        idlString
+  HiLink idlCoclassAttribute    StorageClass
+  HiLink idlLibrary             Keyword
+  HiLink idlImportlib           Keyword
+  HiLink idlCoclass             Keyword
+  HiLink idlLibraryName         Typedef
+  HiLink idlCoclassName         Typedef
+  " hi idlLibraryContent guifg=red
+  HiLink idlTypedefDecl         Typedef
+  HiLink idlDefEnum             Keyword
+  HiLink idlDefv1Enum           Keyword
+  HiLink idlDefEnumName         Typedef
+  HiLink idlDefEnumContents     Paren
+  HiLink idlDefBaseTypeInt      idlType
+  HiLink idlDefBaseType         idlType
+  HiLink idlDefSeqType          idlType
+  HiLink idlInterfaceSections   Label
 
-  HiLink idlOneWayOp		StorageClass
-  HiLink idlOp			idlType
-  HiLink idlParmType		idlType
-  HiLink idlOpName		Function
-  HiLink idlOpParms		StorageClass
-  HiLink idlParmName		Identifier
-  HiLink idlInheritFrom		Identifier
-
-  HiLink idlId			Constant
-  "HiLink idlCase		Keyword
-  HiLink idlCaseLabel		Constant
-
+  if exists("idlsyntax_showerror")
+    if exists("idlsyntax_showerror_soft")
+      hi default idlError guibg=#d0ffd0
+    else
+      HiLink idlError Error
+    endif
+  endif
   delcommand HiLink
 endif
 
 let b:current_syntax = "idl"
 
-" vim: ts=8
+" vim: sw=2 et
--- a/runtime/syntax/lilo.vim
+++ b/runtime/syntax/lilo.vim
@@ -2,22 +2,23 @@
 " This is a GENERATED FILE. Please always refer to source file at the URI below.
 " Language: lilo configuration (lilo.conf)
 " Maintainer: David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>
-" Last Change: 2003 May 04
+" Last Change: 2004-07-20
 " URL: http://trific.ath.cx/Ftp/vim/syntax/lilo.vim
 
+
 " Setup
 if version >= 600
-	if exists("b:current_syntax")
-		finish
-	endif
+  if exists("b:current_syntax")
+    finish
+  endif
 else
-	syntax clear
+  syntax clear
 endif
 
 if version >= 600
-	command -nargs=1 SetIsk setlocal iskeyword=<args>
+  command -nargs=1 SetIsk setlocal iskeyword=<args>
 else
-	command -nargs=1 SetIsk set iskeyword=<args>
+  command -nargs=1 SetIsk set iskeyword=<args>
 endif
 SetIsk @,48-57,.,-,_
 delcommand SetIsk
@@ -34,23 +35,23 @@ syn match liloHexNumber "0[xX]\x\+" cont
 syn match liloDecNumberP "\d\+p\=" contained
 syn match liloSpecial contained "\\\(\"\|\\\|$\)"
 syn region liloString start=+"+ skip=+\\\\\|\\"+ end=+"+ contained contains=liloSpecial,liloEnviron
-syn match liloLabel "\S\+" contained contains=liloSpecial,liloEnviron
+syn match liloLabel :[^ "]\+: contained contains=liloSpecial,liloEnviron
 syn region liloPath start=+[$/]+ skip=+\\\\\|\\ \|\\$"+ end=+ \|$+ contained contains=liloSpecial,liloEnviron
 syn match liloDecNumberList "\(\d\|,\)\+" contained contains=liloDecNumber
 syn match liloDecNumberPList "\(\d\|[,p]\)\+" contained contains=liloDecNumberP,liloDecNumber
 syn region liloAnything start=+[^[:space:]#]+ skip=+\\\\\|\\ \|\\$+ end=+ \|$+ contained contains=liloSpecial,liloEnviron,liloString
 
 " Path
-syn keyword liloOption backup bitmap boot disktab force-backup install keytable map message nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty
+syn keyword liloOption backup bitmap boot disktab force-backup keytable map message nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty
 syn keyword liloKernelOpt initrd root nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty
 syn keyword liloImageOpt path loader table nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty
 syn keyword liloDiskOpt partition nextgroup=liloEqPath,liloEqPathComment,liloError skipwhite skipempty
 
 " Other
-syn keyword liloOption menu-scheme raid-extra-boot serial nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty
-syn keyword liloOption default nextgroup=liloEqLabel,liloEqLabelComment,liloError skipwhite skipempty
+syn keyword liloOption menu-scheme raid-extra-boot serial install nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty
+syn keyword liloOption bios-passes-dl nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty
+syn keyword liloOption default label alias wmdefault nextgroup=liloEqLabelString,liloEqLabelStringComment,liloError skipwhite skipempty
 syn keyword liloKernelOpt ramdisk nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty
-syn keyword liloImageOpt alias label nextgroup=liloEqLabel,liloEqLabelComment,liloError skipwhite skipempty
 syn keyword liloImageOpt password range nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty
 syn keyword liloDiskOpt set type nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty
 
@@ -67,19 +68,21 @@ syn keyword liloKernelOpt append nextgro
 syn keyword liloImageOpt fallback literal nextgroup=liloEqString,liloEqStringComment,liloError skipwhite skipempty
 
 " Hex number
-syn keyword liloImageOpt map-drive to nextgroup=liloEqHexNumber,liloEqHexNumberComment,liloError skipwhite skipempty
+syn keyword liloImageOpt map-drive to boot-as nextgroup=liloEqHexNumber,liloEqHexNumberComment,liloError skipwhite skipempty
 syn keyword liloDiskOpt bios normal hidden nextgroup=liloEqNumber,liloEqNumberComment,liloError skipwhite skipempty
 
 " Number list
-syn keyword liloOption bmp-colors bmp-timer nextgroup=liloEqNumberList,liloEqNumberListComment,liloError skipwhite skipempty
+syn keyword liloOption bmp-colors nextgroup=liloEqNumberList,liloEqNumberListComment,liloError skipwhite skipempty
 
 " Number list, some of the numbers followed by p
-syn keyword liloOption bmp-table nextgroup=liloEqDecNumberPList,liloEqDecNumberPListComment,liloError skipwhite skipempty
+syn keyword liloOption bmp-table bmp-timer nextgroup=liloEqDecNumberPList,liloEqDecNumberPListComment,liloError skipwhite skipempty
 
 " Flag
 syn keyword liloOption compact fix-table geometric ignore-table lba32 linear mandatory nowarn prompt
+syn keyword liloOption bmp-retain el-torito-bootable-CD large-memory suppress-boot-time-BIOS-data
 syn keyword liloKernelOpt read-only read-write
 syn keyword liloImageOpt bypass lock mandatory optional restricted single-key unsafe
+syn keyword liloImageOpt master-boot wmwarn wmdisable
 syn keyword liloDiskOpt change activate deactivate inaccessible reset
 
 " Image
@@ -97,7 +100,7 @@ syn match liloEqNumberComment "#.*$" con
 syn match liloEqDecNumberComment "#.*$" contained nextgroup=liloEqDecNumber,liloEqDecNumberComment,liloError skipwhite skipempty
 syn match liloEqHexNumberComment "#.*$" contained nextgroup=liloEqHexNumber,liloEqHexNumberComment,liloError skipwhite skipempty
 syn match liloEqStringComment "#.*$" contained nextgroup=liloEqString,liloEqStringComment,liloError skipwhite skipempty
-syn match liloEqLabelComment "#.*$" contained nextgroup=liloEqLabel,liloEqLabelComment,liloError skipwhite skipempty
+syn match liloEqLabelStringComment "#.*$" contained nextgroup=liloEqLabelString,liloEqLabelStringComment,liloError skipwhite skipempty
 syn match liloEqNumberListComment "#.*$" contained nextgroup=liloEqNumberList,liloEqNumberListComment,liloError skipwhite skipempty
 syn match liloEqDecNumberPListComment "#.*$" contained nextgroup=liloEqDecNumberPList,liloEqDecNumberPListComment,liloError skipwhite skipempty
 syn match liloEqAnythingComment "#.*$" contained nextgroup=liloEqAnything,liloEqAnythingComment,liloError skipwhite skipempty
@@ -109,7 +112,7 @@ syn match liloEqNumber "=" contained nex
 syn match liloEqDecNumber "=" contained nextgroup=liloDecNumber,liloDecNumberComment,liloError skipwhite skipempty
 syn match liloEqHexNumber "=" contained nextgroup=liloHexNumber,liloHexNumberComment,liloError skipwhite skipempty
 syn match liloEqString "=" contained nextgroup=liloString,liloStringComment,liloError skipwhite skipempty
-syn match liloEqLabel "=" contained nextgroup=liloLabel,liloLabelComment,liloError skipwhite skipempty
+syn match liloEqLabelString "=" contained nextgroup=liloString,liloLabel,liloLabelStringComment,liloError skipwhite skipempty
 syn match liloEqNumberList "=" contained nextgroup=liloDecNumberList,liloDecNumberListComment,liloError skipwhite skipempty
 syn match liloEqDecNumberPList "=" contained nextgroup=liloDecNumberPList,liloDecNumberPListComment,liloError skipwhite skipempty
 syn match liloEqAnything "=" contained nextgroup=liloAnything,liloAnythingComment,liloError skipwhite skipempty
@@ -121,74 +124,71 @@ syn match liloNumberComment "#.*$" conta
 syn match liloDecNumberComment "#.*$" contained nextgroup=liloDecNumber,liloDecNumberComment,liloError skipwhite skipempty
 syn match liloHexNumberComment "#.*$" contained nextgroup=liloHexNumber,liloHexNumberComment,liloError skipwhite skipempty
 syn match liloStringComment "#.*$" contained nextgroup=liloString,liloStringComment,liloError skipwhite skipempty
-syn match liloLabelComment "#.*$" contained nextgroup=liloLabel,liloLabelComment,liloError skipwhite skipempty
+syn match liloLabelStringComment "#.*$" contained nextgroup=liloString,liloLabel,liloLabelStringComment,liloError skipwhite skipempty
 syn match liloDecNumberListComment "#.*$" contained nextgroup=liloDecNumberList,liloDecNumberListComment,liloError skipwhite skipempty
 syn match liloDecNumberPListComment "#.*$" contained nextgroup=liloDecNumberPList,liloDecNumberPListComment,liloError skipwhite skipempty
 syn match liloAnythingComment "#.*$" contained nextgroup=liloAnything,liloAnythingComment,liloError skipwhite skipempty
 
 " Define the default highlighting
 if version >= 508 || !exists("did_lilo_syntax_inits")
-	if version < 508
-		let did_lilo_syntax_inits = 1
-		command -nargs=+ HiLink hi link <args>
-	else
-		command -nargs=+ HiLink hi def link <args>
-	endif
+  if version < 508
+    let did_lilo_syntax_inits = 1
+    command -nargs=+ HiLink hi link <args>
+  else
+    command -nargs=+ HiLink hi def link <args>
+  endif
 
-	HiLink liloEqPath liloEquals
-	HiLink liloEqWord liloEquals
-	HiLink liloEqVga liloEquals
-	HiLink liloEqDecNumber liloEquals
-	HiLink liloEqHexNumber liloEquals
-	HiLink liloEqNumber liloEquals
-	HiLink liloEqString liloEquals
-	HiLink liloEqLabel liloEquals
-	HiLink liloEqAnything liloEquals
-	HiLink liloEquals Special
+  HiLink liloEqPath             liloEquals
+  HiLink liloEqWord             liloEquals
+  HiLink liloEqVga              liloEquals
+  HiLink liloEqDecNumber        liloEquals
+  HiLink liloEqHexNumber        liloEquals
+  HiLink liloEqNumber           liloEquals
+  HiLink liloEqString           liloEquals
+  HiLink liloEqAnything         liloEquals
+  HiLink liloEquals             Special
 
-	HiLink liloError Error
+  HiLink liloError              Error
 
-	HiLink liloEqPathComment liloComment
-	HiLink liloEqVgaComment liloComment
-	HiLink liloEqDecNumberComment liloComment
-	HiLink liloEqHexNumberComment liloComment
-	HiLink liloEqStringComment liloComment
-	HiLink liloEqLabelComment liloComment
-	HiLink liloEqAnythingComment liloComment
-	HiLink liloPathComment liloComment
-	HiLink liloVgaComment liloComment
-	HiLink liloDecNumberComment liloComment
-	HiLink liloHexNumberComment liloComment
-	HiLink liloNumberComment liloComment
-	HiLink liloStringComment liloComment
-	HiLink liloLabelComment liloComment
-	HiLink liloAnythingComment liloComment
-	HiLink liloComment Comment
+  HiLink liloEqPathComment      liloComment
+  HiLink liloEqVgaComment       liloComment
+  HiLink liloEqDecNumberComment liloComment
+  HiLink liloEqHexNumberComment liloComment
+  HiLink liloEqStringComment    liloComment
+  HiLink liloEqAnythingComment  liloComment
+  HiLink liloPathComment        liloComment
+  HiLink liloVgaComment         liloComment
+  HiLink liloDecNumberComment   liloComment
+  HiLink liloHexNumberComment   liloComment
+  HiLink liloNumberComment      liloComment
+  HiLink liloStringComment      liloComment
+  HiLink liloAnythingComment    liloComment
+  HiLink liloComment            Comment
+
+  HiLink liloDiskOpt            liloOption
+  HiLink liloKernelOpt          liloOption
+  HiLink liloImageOpt           liloOption
+  HiLink liloOption             Keyword
 
-	HiLink liloDiskOpt liloOption
-	HiLink liloKernelOpt liloOption
-	HiLink liloImageOpt liloOption
-	HiLink liloOption Keyword
-
-	HiLink liloDecNumber liloNumber
-	HiLink liloHexNumber liloNumber
-	HiLink liloDecNumberP liloNumber
-	HiLink liloNumber Number
-	HiLink liloString String
-	HiLink liloPath Constant
+  HiLink liloDecNumber          liloNumber
+  HiLink liloHexNumber          liloNumber
+  HiLink liloDecNumberP         liloNumber
+  HiLink liloNumber             Number
+  HiLink liloString             String
+  HiLink liloPath               Constant
 
-	HiLink liloSpecial Special
-	HiLink liloLabel Title
-	HiLink liloDecNumberList Special
-	HiLink liloDecNumberPList Special
-	HiLink liloAnything Normal
-	HiLink liloEnviron Identifier
-	HiLink liloVgaKeyword Identifier
-	HiLink liloImage Type
-	HiLink liloChRules Preproc
-	HiLink liloDisk Preproc
+  HiLink liloSpecial            Special
+  HiLink liloLabel              Title
+  HiLink liloDecNumberList      Special
+  HiLink liloDecNumberPList     Special
+  HiLink liloAnything           Normal
+  HiLink liloEnviron            Identifier
+  HiLink liloVgaKeyword         Identifier
+  HiLink liloImage              Type
+  HiLink liloChRules            Preproc
+  HiLink liloDisk               Preproc
 
-	delcommand HiLink
+  delcommand HiLink
 endif
 
 let b:current_syntax = "lilo"
--- a/runtime/syntax/lprolog.vim
+++ b/runtime/syntax/lprolog.vim
@@ -2,10 +2,10 @@
 " Language:     LambdaProlog (Teyjus)
 " Filenames:    *.mod *.sig
 " Maintainer:   Markus Mottl  <markus@oefai.at>
-" URL:		http://www.ai.univie.ac.at/~markus/vim/syntax/lprolog.vim
-" Last Change:	2003 May 11
-"		2001 Apr 26 - Upgraded for new Vim version
-"		2000 Jun  5 - Initial release
+" URL:          http://www.oefai.at/~markus/vim/syntax/lprolog.vim
+" Last Change:  2004 Jul 26
+"               2001 Apr 26 - Upgraded for new Vim version
+"               2000 Jun  5 - Initial release
 
 " For version 5.x: Clear all syntax items
 " For version 6.x: Quit when a syntax file was already loaded
--- a/runtime/syntax/ocaml.vim
+++ b/runtime/syntax/ocaml.vim
@@ -2,12 +2,12 @@
 " Language:     OCaml
 " Filenames:    *.ml *.mli *.mll *.mly
 " Maintainers:  Markus Mottl      <markus@oefai.at>
-"		Karl-Heinz Sylla  <Karl-Heinz.Sylla@gmd.de>
-"		Issac Trotts	  <<ijtrotts@ucdavis.edu>
-" URL:		http://www.oefai.at/~markus/vim/syntax/ocaml.vim
-" Last Change:	2003 May 04
-"		2002 Oct 24 - Small fix for "module type" (MM)
-"		2002 Jun 16 - Added "&&", "<" and ">" as operators (MM)
+"               Karl-Heinz Sylla  <Karl-Heinz.Sylla@gmd.de>
+"               Issac Trotts      <ijtrotts@ucdavis.edu>
+" URL:          http://www.oefai.at/~markus/vim/syntax/ocaml.vim
+" Last Change:  2004 Jul 26
+"               2003 Jan 19 - Added keyword "require" for scripting (MM)
+"               2002 Oct 30 - New variable "ocaml_revised" (MM)
 
 " For version 5.x: Clear all syntax items
 " For version 6.x: Quit when a syntax file was already loaded
@@ -24,7 +24,7 @@ syn case match
 syn match    ocamlComment   "^#!.*"
 
 " Scripting directives
-syn match    ocamlScript "^#\<\(quit\|labels\|warnings\|directory\|cd\|load\|use\|install_printer\|remove_printer\|trace\|untrace\|untrace_all\|print_depth\|print_length\)\>"
+syn match    ocamlScript "^#\<\(quit\|labels\|warnings\|directory\|cd\|load\|use\|install_printer\|remove_printer\|require\|trace\|untrace\|untrace_all\|print_depth\|print_length\)\>"
 
 " lowercase identifier - the standard way to match
 syn match    ocamlLCIdentifier /\<\(\l\|_\)\(\w\|'\)*\>/
@@ -163,7 +163,7 @@ else
   syn match    ocamlKeyChar  "!"
 endif
 
-syn keyword  ocamlType     array bool char exn float format int
+syn keyword  ocamlType     array bool char exn float format format4 int
 syn keyword  ocamlType     list option string unit
 
 syn keyword  ocamlOperator asr lor lsl lsr lxor mod not
--- a/runtime/syntax/sml.vim
+++ b/runtime/syntax/sml.vim
@@ -1,12 +1,12 @@
 " Vim syntax file
 " Language:     SML
 " Filenames:    *.sml *.sig
-" Maintainers:	Markus Mottl		<markus@oefai.at>
-"		Fabrizio Zeno Cornelli	<zeno@filibusta.crema.unimi.it>
-" URL:		http://www.ai.univie.ac.at/~markus/vim/syntax/sml.vim
-" Last Change:	2003 May 11
-"		2001 Nov 20 - Fixed small highlighting bug with modules (MM)
-"		2001 Aug 29 - Fixed small highlighting bug  (MM)
+" Maintainers:  Markus Mottl            <markus@oefai.at>
+"               Fabrizio Zeno Cornelli  <zeno@filibusta.crema.unimi.it>
+" URL:          http://www.oefai.at/~markus/vim/syntax/sml.vim
+" Last Change:  2004 Jul 26
+"               2001 Nov 20 - Fixed small highlighting bug with modules (MM)
+"               2001 Aug 29 - Fixed small highlighting bug  (MM)
 
 " For version 5.x: Clear all syntax items
 " For version 6.x: Quit when a syntax file was already loaded
--- a/src/Makefile
+++ b/src/Makefile
@@ -1055,9 +1055,9 @@ LINKIT = @echo >/dev/null
 NONE_INSTALL = install_normal
 
 ### KDE GUI interface.
-KDE_SRC		= gui.c pty.c gui_kde.cc gui_kde_x11.cc gui_kde_widget.cc gui_kde_widget_moc.cc kvim_iface_skel.cc
+KDE_SRC		= gui.c pty.c gui_kde.cc gui_kde_x11.cc gui_kde_wid.cc gui_kde_wid_moc.cc kvim_iface_skel.cc
 KDE_OBJ		= objects/gui.o objects/pty.o objects/gui_kde.o objects/gui_kde_x11.o \
-			objects/gui_kde_widget.o objects/gui_kde_widget_moc.o \
+			objects/gui_kde_wid.o objects/gui_kde_wid_moc.o \
 			objects/kvim_iface_skel.o
 KDE_DEFS	= -DFEAT_GUI_KDE $(NARROW_PROTO)
 KDE_IPATH	= $(GUI_INC_LOC)
@@ -1201,7 +1201,7 @@ CARBONGUI_BUNDLE = $(VIMNAME).app
 CARBONGUI_TESTARG = VIMPROG=../$(CARBONGUI_BUNDLE)/Contents/MacOS/$(VIMTARGET)
 
 # All GUI files
-ALL_GUI_SRC  = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_athena.c gui_gtk_x11.c gui_x11.c gui_at_sb.c gui_at_fs.c pty.c gui_kde.cc gui_kde_widget.cc gui_kde_x11.cc gui_kde_widget_moc.cc
+ALL_GUI_SRC  = gui.c gui_gtk.c gui_gtk_f.c gui_motif.c gui_athena.c gui_gtk_x11.c gui_x11.c gui_at_sb.c gui_at_fs.c pty.c gui_kde.cc gui_kde_wid.cc gui_kde_x11.cc gui_kde_wid_moc.cc
 ALL_GUI_PRO  = gui.pro gui_gtk.pro gui_motif.pro gui_athena.pro gui_gtk_x11.pro gui_x11.pro gui_w16.pro gui_w32.pro gui_amiga.pro gui_photon.pro gui_kde.pro gui_kde_x11.pro
 
 # }}}
@@ -2038,7 +2038,7 @@ clean celan: testclean
 	-rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c
 	-rm -f conftest* *~ auto/link.sed
 	-rm -rf $(GUI_BUNDLE)
-	-rm -f gui_kde_widget_moc.cc kvim_iface_skel.cc *.kidl
+	-rm -f gui_kde_wid_moc.cc kvim_iface_skel.cc *.kidl
 	if test -d $(PODIR); then \
 		cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) clean; \
 	fi
@@ -2393,17 +2393,17 @@ objects/gui_kde.o: gui_kde.cc
 objects/gui_kde_x11.o: gui_kde_x11.cc
 	$(CCC) -o $@ gui_kde_x11.cc
 
-objects/gui_kde_widget.o: gui_kde_widget.cc
-	$(MOC) -o gui_kde_widget_moc.cc gui_kde_widget.h
+objects/gui_kde_wid.o: gui_kde_wid.cc
+	$(MOC) -o gui_kde_wid_moc.cc gui_kde_wid.h
 	$(KDE_DIR)/bin/dcopidl kvim_iface.h > kvim_iface.kidl || ( rm -f kvim_iface.kidl ; /bin/false )
 	$(KDE_DIR)/bin/dcopidl2cpp --c++-suffix cc --no-stub kvim_iface.kidl
-	$(CCC) -o $@ gui_kde_widget.cc
-
-gui_kde_widget_moc.cc: objects/gui_kde_widget.o
-objects/gui_kde_widget_moc.o: gui_kde_widget_moc.cc
-	$(CCC) -o $@ gui_kde_widget_moc.cc
-
-kvim_iface_skel.cc: objects/gui_kde_widget.o
+	$(CCC) -o $@ gui_kde_wid.cc
+
+gui_kde_wid_moc.cc: objects/gui_kde_wid.o
+objects/gui_kde_wid_moc.o: gui_kde_wid_moc.cc
+	$(CCC) -o $@ gui_kde_wid_moc.cc
+
+kvim_iface_skel.cc: objects/gui_kde_wid.o
 objects/kvim_iface_skel.o: kvim_iface_skel.cc
 	$(CCC) -o $@ kvim_iface_skel.cc
 
@@ -2716,21 +2716,21 @@ objects/pty.o: pty.c vim.h auto/config.h
  ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h gui_beval.h \
  proto/gui_beval.pro option.h ex_cmds.h proto.h globals.h farsi.h \
  arabic.h
-objects/gui_kde.o: gui_kde.cc gui_kde_widget.h kvim_iface.h vim.h \
+objects/gui_kde.o: gui_kde.cc gui_kde_wid.h kvim_iface.h vim.h \
  auto/config.h feature.h os_unix.h auto/osdef.h ascii.h keymap.h \
  term.h macros.h structs.h regexp.h gui.h option.h ex_cmds.h proto.h \
  globals.h farsi.h
-objects/gui_kde_widget.o: gui_kde_widget.cc gui_kde_widget.h kvim_iface.h \
+objects/gui_kde_wid.o: gui_kde_wid.cc gui_kde_wid.h kvim_iface.h \
  vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h keymap.h \
  term.h macros.h structs.h regexp.h gui.h option.h ex_cmds.h proto.h \
  globals.h farsi.h proto/../../pixmaps/alert.xpm proto/../../pixmaps/error.xpm \
  proto/../../pixmaps/generic.xpm proto/../../pixmaps/info.xpm \
  proto/../../pixmaps/quest.xpm
-objects/gui_kde_x11.o: gui_kde_x11.cc gui_kde_widget.h kvim_iface.h vim.h \
+objects/gui_kde_x11.o: gui_kde_x11.cc gui_kde_wid.h kvim_iface.h vim.h \
  auto/config.h feature.h os_unix.h auto/osdef.h ascii.h keymap.h \
  term.h macros.h structs.h regexp.h gui.h option.h ex_cmds.h proto.h \
  globals.h farsi.h version.h ../runtime/vim32x32.xpm
-objects/gui_kde_widget_moc.o: gui_kde_widget_moc.cc gui_kde_widget.h \
+objects/gui_kde_wid_moc.o: gui_kde_wid_moc.cc gui_kde_wid.h \
  kvim_iface.h vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
  ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h option.h \
  ex_cmds.h proto.h globals.h
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -216,6 +216,12 @@ open_buffer(read_stdin, eap)
 #endif
 	curbuf->b_flags |= BF_READERR;
 
+#ifdef FEAT_FOLDING
+    /* Need to update automatic folding.  Do this before the autocommands,
+     * they may use the fold info. */
+    foldUpdateAll(curwin);
+#endif
+
 #ifdef FEAT_AUTOCMD
     /* need to set w_topline, unless some autocommand already did that. */
     if (!(curwin->w_valid & VALID_TOPLINE))
@@ -263,11 +269,6 @@ open_buffer(read_stdin, eap)
 #endif
     }
 
-#ifdef FEAT_FOLDING
-    /* Need to update automatic folding. */
-    foldUpdateAll(curwin);
-#endif
-
     return retval;
 }
 
@@ -408,8 +409,7 @@ close_buffer(win, buf, action)
     if (!buf_valid(buf))
 	return;
 # ifdef FEAT_EVAL
-    /* Autocommands may abort script processing. */
-    if (aborting())
+    if (aborting())	    /* autocmds may abort script processing */
 	return;
 # endif
 
@@ -538,7 +538,8 @@ buf_freeall(buf, del_buf, wipe_buf)
 	    return;
     }
 # ifdef FEAT_EVAL
-    if (aborting())	    /* autocmds may abort script processing */
+    /* autocmds may abort script processing */
+    if (aborting())
 	return;
 # endif
 
@@ -669,8 +670,16 @@ goto_buffer(eap, start, dir, count)
 		&& (defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG))
     if (swap_exists_action == SEA_QUIT && *eap->cmd == 's')
     {
-	/* Quitting means closing the split window, nothing else. */
+	int	old_got_int = got_int;
+
+	/* Quitting means closing the split window, nothing else.
+	 * Reset got_int here, because it causes aborting() to return TRUE
+	 * which breaks closing a window. */
+	got_int = FALSE;
+
 	win_close(curwin, TRUE);
+
+	got_int |= old_got_int;
 	swap_exists_action = SEA_NONE;
     }
     else
@@ -688,6 +697,12 @@ goto_buffer(eap, start, dir, count)
 handle_swap_exists(old_curbuf)
     buf_T	*old_curbuf;
 {
+    int		old_got_int = got_int;
+
+    /* Reset got_int here, because it causes aborting() to return TRUE which
+     * breaks closing a buffer. */
+    got_int = FALSE;
+
     if (swap_exists_action == SEA_QUIT)
     {
 	/* User selected Quit at ATTENTION prompt.  Go back to previous
@@ -712,6 +727,7 @@ handle_swap_exists(old_curbuf)
 	do_modelines();
     }
     swap_exists_action = SEA_NONE;
+    got_int |= old_got_int;
 }
 #endif
 
@@ -4226,26 +4242,28 @@ ex_buffer_all(eap)
 #endif
 	    set_curbuf(buf, DOBUF_GOTO);
 #ifdef FEAT_AUTOCMD
-# ifdef FEAT_EVAL
-	    /* Autocommands deleted the buffer or aborted script
-	     * processing!!! */
-	    if (!buf_valid(buf) || aborting())
-# else
 	    if (!buf_valid(buf))	/* autocommands deleted the buffer!!! */
+	    {
+# if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
+		swap_exists_action = SEA_NONE;
 # endif
-	    {
-#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
-		swap_exists_action = SEA_NONE;
-#endif
 		break;
 	    }
 #endif
 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
 	    if (swap_exists_action == SEA_QUIT)
 	    {
-		/* User selected Quit at ATTENTION prompt; close this window. */
+		int	old_got_int = got_int;
+
+		/* User selected Quit at ATTENTION prompt; close this window.
+		 * Reset got_int here, because it causes aborting() to return
+		 * TRUE which breaks closing a window. */
+		got_int = FALSE;
+
 		win_close(curwin, TRUE);
 		--open_wins;
+
+		got_int |= old_got_int;
 		swap_exists_action = SEA_NONE;
 	    }
 	    else
@@ -4259,6 +4277,11 @@ ex_buffer_all(eap)
 	    (void)vgetc();	/* only break the file loading, not the rest */
 	    break;
 	}
+#ifdef FEAT_EVAL
+	/* Autocommands deleted the buffer or aborted script processing!!! */
+	if (aborting())
+	    break;
+#endif
     }
 #ifdef FEAT_AUTOCMD
     --autocmd_no_enter;
--- a/src/edit.c
+++ b/src/edit.c
@@ -2641,7 +2641,7 @@ ins_compl_next_buf(buf, flag)
 
 #ifdef FEAT_COMPL_FUNC
 static char_u *call_completefunc __ARGS((char_u *line, char_u *base, int col, int preproc));
-static int expand_by_function __ARGS((int lnum, int col, char_u *base, char_u ***matches));
+static int expand_by_function __ARGS((linenr_T lnum, int col, char_u *base, char_u ***matches));
 
 /*
  * Execute user defined complete function 'completefunc'.
@@ -2665,7 +2665,7 @@ call_completefunc(line, base, col, prepr
     args[0] = line;
     args[1] = base;
     args[2] = colbuf;
-    args[3] = preproc ? "1" : "0";
+    args[3] = (char_u *)(preproc ? "1" : "0");
     return call_vim_function(curbuf->b_p_cfu, 4, args, FALSE);
 }
 
@@ -2676,7 +2676,7 @@ call_completefunc(line, base, col, prepr
  */
     static int
 expand_by_function(lnum, col, base, matches)
-    int		lnum;
+    linenr_T	lnum;
     int		col;
     char_u	*base;
     char_u	***matches;
@@ -3528,7 +3528,7 @@ ins_complete(c)
 	    lenstr = call_completefunc(line, NULL, complete_col, 1);
 	    if (lenstr == NULL)
 		return FAIL;
-	    keeplen = atoi(lenstr);
+	    keeplen = atoi((char *)lenstr);
 	    vim_free(lenstr);
 	    if (keeplen < 0)
 		return FAIL;
--- a/src/eval.c
+++ b/src/eval.c
@@ -295,8 +295,10 @@ static void f_getcharmod __ARGS((VAR arg
 static void f_getcmdline __ARGS((VAR argvars, VAR retvar));
 static void f_getcmdpos __ARGS((VAR argvars, VAR retvar));
 static void f_getcwd __ARGS((VAR argvars, VAR retvar));
+static void f_getfperm __ARGS((VAR argvars, VAR retvar));
 static void f_getfsize __ARGS((VAR argvars, VAR retvar));
 static void f_getftime __ARGS((VAR argvars, VAR retvar));
+static void f_getftype __ARGS((VAR argvars, VAR retvar));
 static void f_getline __ARGS((VAR argvars, VAR retvar));
 static void f_getreg __ARGS((VAR argvars, VAR retvar));
 static void f_getregtype __ARGS((VAR argvars, VAR retvar));
@@ -751,7 +753,7 @@ call_vim_function(func, argc, argv, safe
 	if (argv[i] == NULL || *argv[i] == NUL)
 	{
 	    argvars[i].var_type = VAR_STRING;
-	    argvars[i].var_val.var_string = "";
+	    argvars[i].var_val.var_string = (char_u *)"";
 	    continue;
 	}
 
@@ -2853,8 +2855,10 @@ static struct fst
     {"getcmdline",	0, 0, f_getcmdline},
     {"getcmdpos",	0, 0, f_getcmdpos},
     {"getcwd",		0, 0, f_getcwd},
+    {"getfperm",	1, 1, f_getfperm},
     {"getfsize",	1, 1, f_getfsize},
     {"getftime",	1, 1, f_getftime},
+    {"getftype",	1, 1, f_getftype},
     {"getline",		1, 1, f_getline},
     {"getreg",		0, 1, f_getreg},
     {"getregtype",	0, 1, f_getregtype},
@@ -2941,7 +2945,7 @@ static struct fst
     {"wincol",		0, 0, f_wincol},
     {"winheight",	1, 1, f_winheight},
     {"winline",		0, 0, f_winline},
-    {"winnr",		0, 0, f_winnr},
+    {"winnr",		0, 1, f_winnr},
     {"winrestcmd",	0, 0, f_winrestcmd},
     {"winwidth",	1, 1, f_winwidth},
 };
@@ -4578,6 +4582,38 @@ f_getcwd(argvars, retvar)
 }
 
 /*
+ * "getfperm({fname})" function
+ */
+    static void
+f_getfperm(argvars, retvar)
+    VAR		argvars;
+    VAR		retvar;
+{
+    char_u	*fname;
+    struct stat st;
+    char_u	*perm = NULL;
+    char_u	flags[] = "rwx";
+    int		i;
+
+    fname = get_var_string(&argvars[0]);
+
+    retvar->var_type = VAR_STRING;
+    if (mch_stat((char *)fname, &st) >= 0)
+    {
+	perm = vim_strsave((char_u *)"---------");
+	if (perm != NULL)
+	{
+	    for (i = 0; i < 9; i++)
+	    {
+		if (st.st_mode & (1 << (8 - i)))
+		    perm[i] = flags[i % 3];
+	    }
+	}
+    }
+    retvar->var_val.var_string = perm;
+}
+
+/*
  * "getfsize({fname})" function
  */
     static void
@@ -4623,6 +4659,86 @@ f_getftime(argvars, retvar)
 }
 
 /*
+ * "getftype({fname})" function
+ */
+    static void
+f_getftype(argvars, retvar)
+    VAR		argvars;
+    VAR		retvar;
+{
+    char_u	*fname;
+    struct stat st;
+    char_u	*type = NULL;
+    char	*t;
+
+    fname = get_var_string(&argvars[0]);
+
+    retvar->var_type = VAR_STRING;
+    if (mch_lstat((char *)fname, &st) >= 0)
+    {
+#ifdef S_ISREG
+	if (S_ISREG(st.st_mode))
+	    t = "file";
+	else if (S_ISDIR(st.st_mode))
+	    t = "dir";
+# ifdef S_ISLNK
+	else if (S_ISLNK(st.st_mode))
+	    t = "link";
+# endif
+# ifdef S_ISBLK
+	else if (S_ISBLK(st.st_mode))
+	    t = "bdev";
+# endif
+# ifdef S_ISCHR
+	else if (S_ISCHR(st.st_mode))
+	    t = "cdev";
+# endif
+# ifdef S_ISFIFO
+	else if (S_ISFIFO(st.st_mode))
+	    t = "fifo";
+# endif
+# ifdef S_ISSOCK
+	else if (S_ISSOCK(st.st_mode))
+	    t = "fifo";
+# endif
+	else
+	    t = "other";
+#else
+# ifdef S_IFMT
+	switch (st.st_mode & S_IFMT)
+	{
+	    case S_IFREG: t = "file"; break;
+	    case S_IFDIR: t = "dir"; break;
+#  ifdef S_IFLNK
+	    case S_IFLNK: t = "link"; break;
+#  endif
+#  ifdef S_IFBLK
+	    case S_IFBLK: t = "bdev"; break;
+#  endif
+#  ifdef S_IFCHR
+	    case S_IFCHR: t = "cdev"; break;
+#  endif
+#  ifdef S_IFIFO
+	    case S_IFIFO: t = "fifo"; break;
+#  endif
+#  ifdef S_IFSOCK
+	    case S_IFSOCK: t = "socket"; break;
+#  endif
+	    default: t = "other";
+	}
+# else
+	if (mch_isdir(fname))
+	    t = "dir";
+	else
+	    t = "file";
+# endif
+#endif
+	type = vim_strsave((char_u *)t);
+    }
+    retvar->var_val.var_string = type;
+}
+
+/*
  * "getreg()" function
  */
     static void
@@ -6305,6 +6421,10 @@ f_simplify(argvars, retvar)
     retvar->var_type = VAR_STRING;
 }
 
+#define SP_NOMOVE	1	/* don't move cursor */
+#define SP_REPEAT	2	/* repeat to find outer pair */
+#define SP_RETCOUNT	4	/* return matchcount */
+
 /*
  * "search()" function
  */
@@ -6315,13 +6435,24 @@ f_search(argvars, retvar)
 {
     char_u	*pat;
     pos_T	pos;
+    pos_T	save_cursor;
     int		save_p_ws = p_ws;
     int		dir;
+    int		flags = 0;
+
+    retvar->var_val.var_number = 0;	/* default: FAIL */
 
     pat = get_var_string(&argvars[0]);
-    dir = get_search_arg(&argvars[1], NULL);	/* may set p_ws */
-
-    pos = curwin->w_cursor;
+    dir = get_search_arg(&argvars[1], &flags);	/* may set p_ws */
+    if (dir == 0)
+	goto theend;
+    if ((flags & ~SP_NOMOVE) != 0)
+    {
+	EMSG2(_(e_invarg2), get_var_string(&argvars[1]));
+	goto theend;
+    }
+
+    pos = save_cursor = curwin->w_cursor;
     if (searchit(curwin, curbuf, &pos, dir, pat, 1L,
 					      SEARCH_KEEP, RE_SEARCH) != FAIL)
     {
@@ -6331,15 +6462,14 @@ f_search(argvars, retvar)
 	 * correct that here */
 	check_cursor();
     }
-    else
-	retvar->var_val.var_number = 0;
+
+    /* If 'n' flag is used: restore cursor position. */
+    if (flags & SP_NOMOVE)
+	curwin->w_cursor = save_cursor;
+theend:
     p_ws = save_p_ws;
 }
 
-#define SP_NOMOVE	1	/* don't move cursor */
-#define SP_REPEAT	2	/* repeat to find outer pair */
-#define SP_RETCOUNT	4	/* return matchcount */
-
 /*
  * "searchpair()" function
  */
@@ -6393,6 +6523,8 @@ f_searchpair(argvars, retvar)
 
     /* Handle the optional fourth argument: flags */
     dir = get_search_arg(&argvars[3], &flags); /* may set p_ws */
+    if (dir == 0)
+	goto theend;
 
     /* Optional fifth argument: skip expresion */
     if (argvars[3].var_type == VAR_UNKNOWN
@@ -6474,6 +6606,11 @@ theend:
     p_cpo = save_cpo;
 }
 
+/*
+ * Get flags for a search function.
+ * Possibly sets "p_ws".
+ * Returns BACKWARD, FORWARD or zero (for an error).
+ */
     static int
 get_search_arg(varp, flagsp)
     VAR		varp;
@@ -6482,24 +6619,37 @@ get_search_arg(varp, flagsp)
     int		dir = FORWARD;
     char_u	*flags;
     char_u	nbuf[NUMBUFLEN];
+    int		mask;
 
     if (varp->var_type != VAR_UNKNOWN)
     {
 	flags = get_var_string_buf(varp, nbuf);
-	if (vim_strchr(flags, 'b') != NULL)
-	    dir = BACKWARD;
-	if (vim_strchr(flags, 'w') != NULL)
-	    p_ws = TRUE;
-	if (vim_strchr(flags, 'W') != NULL)
-	    p_ws = FALSE;
-	if (flagsp != NULL)
-	{
-	    if (vim_strchr(flags, 'n') != NULL)
-		*flagsp |= SP_NOMOVE;
-	    if (vim_strchr(flags, 'r') != NULL)
-		*flagsp |= SP_REPEAT;
-	    if (vim_strchr(flags, 'm') != NULL)
-		*flagsp |= SP_RETCOUNT;
+	while (*flags != NUL)
+	{
+	    switch (*flags)
+	    {
+		case 'b': dir = BACKWARD; break;
+		case 'w': p_ws = TRUE; break;
+		case 'W': p_ws = FALSE; break;
+		default:  mask = 0;
+			  if (flagsp != NULL)
+			     switch (*flags)
+			     {
+				 case 'n': mask = SP_NOMOVE; break;
+				 case 'r': mask = SP_REPEAT; break;
+				 case 'm': mask = SP_RETCOUNT; break;
+			     }
+			  if (mask == 0)
+			  {
+			      EMSG2(_(e_invarg2), flags);
+			      dir = 0;
+			  }
+			  else
+			      *flagsp |= mask;
+	    }
+	    if (dir == 0)
+		break;
+	    ++flags;
 	}
     }
     return dir;
@@ -7648,7 +7798,9 @@ f_tr(argvars, retvar)
 	/* not multi-byte: fromstr and tostr must be the same length */
 	if (STRLEN(fromstr) != STRLEN(tostr))
 	{
+#ifdef FEAT_MBYTE
 error:
+#endif
 	    EMSG2(_(e_invarg2), fromstr);
 	    ga_clear(&ga);
 	    return;
@@ -7859,9 +8011,30 @@ f_winnr(argvars, retvar)
     int		nr = 1;
 #ifdef FEAT_WINDOWS
     win_T	*wp;
-
-    for (wp = firstwin; wp != curwin; wp = wp->w_next)
-	++nr;
+    win_T	*twin = curwin;
+    char_u	*arg;
+
+    if (argvars[0].var_type != VAR_UNKNOWN)
+    {
+	arg = get_var_string(&argvars[0]);
+	if (STRCMP(arg, "$") == 0)
+	    twin = lastwin;
+	else if (STRCMP(arg, "#") == 0)
+	{
+	    twin = prevwin;
+	    if (prevwin == NULL)
+		nr = 0;
+	}
+	else
+	{
+	    EMSG2(_(e_invexpr2), arg);
+	    nr = 0;
+	}
+    }
+
+    if (nr > 0)
+	for (wp = firstwin; wp != twin; wp = wp->w_next)
+	    ++nr;
 #endif
     retvar->var_val.var_number = nr;
 }
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -3806,6 +3806,7 @@ static struct prt_ps_font_S prt_ps_couri
     {"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique"}
 };
 
+#ifdef FEAT_MBYTE
 /* Generic font metrics for multi-byte fonts */
 static struct prt_ps_font_S prt_ps_mb_font =
 {
@@ -3814,6 +3815,7 @@ static struct prt_ps_font_S prt_ps_mb_fo
     -250, 805,
     {NULL, NULL, NULL, NULL}
 };
+#endif
 
 /* Pointer to current font set being used */
 static struct prt_ps_font_S* prt_ps_font;
@@ -3822,8 +3824,8 @@ static struct prt_ps_font_S* prt_ps_font
  * building CID font name */
 struct prt_ps_encoding_S
 {
-    char_u	*encoding;
-    char_u	*cmap_encoding;
+    char	*encoding;
+    char	*cmap_encoding;
     int		needs_charset;
 };
 
@@ -3834,6 +3836,8 @@ struct prt_ps_charset_S
     int		has_charset;
 };
 
+#ifdef FEAT_MBYTE
+
 #define CS_JIS_C_1978   (0x01)
 #define CS_JIS_X_1983   (0x02)
 #define CS_JIS_X_1990   (0x04)
@@ -4017,6 +4021,7 @@ static struct prt_ps_mbfont_S prt_ps_mbf
         "KS_X_1992"
     }
 };
+#endif /* FEAT_MBYTE */
 
 struct prt_ps_resource_S
 {
@@ -4076,7 +4081,7 @@ static char *prt_resource_types[] =
 
 struct prt_dsc_comment_S
 {
-    char_u	*string;
+    char	*string;
     int		len;
     int		type;
 };
@@ -4092,11 +4097,11 @@ struct prt_dsc_line_S
 #define SIZEOF_CSTR(s)      (sizeof(s) - 1)
 struct prt_dsc_comment_S prt_dsc_table[] =
 {
-    {PRT_DSC_TITLE,       SIZEOF_CSTR(PRT_DSC_TITLE),       PRT_DSC_TITLE_TYPE},
+    {PRT_DSC_TITLE,       SIZEOF_CSTR(PRT_DSC_TITLE),     PRT_DSC_TITLE_TYPE},
     {PRT_DSC_VERSION,     SIZEOF_CSTR(PRT_DSC_VERSION),
-                                                        PRT_DSC_VERSION_TYPE},
+							PRT_DSC_VERSION_TYPE},
     {PRT_DSC_ENDCOMMENTS, SIZEOF_CSTR(PRT_DSC_ENDCOMMENTS),
-                                                    PRT_DSC_ENDCOMMENTS_TYPE}
+						     PRT_DSC_ENDCOMMENTS_TYPE}
 };
 
 static void prt_write_file_raw_len __ARGS((char_u *buffer, int bytes));
@@ -4135,6 +4140,7 @@ static int prt_resfile_skip_nonws __ARGS
 static int prt_resfile_skip_ws __ARGS((int offset));
 static int prt_next_dsc __ARGS((struct prt_dsc_line_S *p_dsc_line));
 #ifdef FEAT_MBYTE
+static int prt_build_cid_fontname __ARGS((int font, char_u *name, int name_len));
 static void prt_def_cidfont __ARGS((char *new_name, int height, char *cidfont));
 static int prt_match_encoding __ARGS((char *p_encoding, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_encoding_S **pp_mbenc));
 static int prt_match_charset __ARGS((char *p_charset, struct prt_ps_mbfont_S *p_cmap, struct prt_ps_charset_S **pp_mbchar));
@@ -5097,15 +5103,16 @@ prt_get_cpl()
     return (int)((prt_right_margin - prt_left_margin) / prt_char_width);
 }
 
+#ifdef FEAT_MBYTE
     static int
 prt_build_cid_fontname(font, name, name_len)
     int     font;
-    char    *name;
+    char_u  *name;
     int     name_len;
 {
     char    *fontname;
 
-    fontname = alloc(name_len + 1);
+    fontname = (char *)alloc(name_len + 1);
     if (fontname == NULL)
         return FALSE;
     STRNCPY(fontname, name, name_len);
@@ -5114,6 +5121,7 @@ prt_build_cid_fontname(font, name, name_
 
     return TRUE;
 }
+#endif
 
 /*
  * Get number of lines of text that fit on a page (excluding the header).
@@ -5152,13 +5160,13 @@ prt_get_lpp()
 #ifdef FEAT_MBYTE
     static int
 prt_match_encoding(p_encoding, p_cmap, pp_mbenc)
-    char    *p_encoding;
-    struct prt_ps_mbfont_S *p_cmap;
-    struct prt_ps_encoding_S **pp_mbenc;
-{
-    int     mbenc;
-    int     enc_len;
-    struct prt_ps_encoding_S *p_mbenc;
+    char			*p_encoding;
+    struct prt_ps_mbfont_S	*p_cmap;
+    struct prt_ps_encoding_S	**pp_mbenc;
+{
+    int				mbenc;
+    int				enc_len;
+    struct prt_ps_encoding_S	*p_mbenc;
 
     *pp_mbenc = NULL;
     /* Look for recognised encoding */
@@ -5178,12 +5186,12 @@ prt_match_encoding(p_encoding, p_cmap, p
 
     static int
 prt_match_charset(p_charset, p_cmap, pp_mbchar)
-    char    *p_charset;
-    struct prt_ps_mbfont_S *p_cmap;
+    char		    *p_charset;
+    struct prt_ps_mbfont_S  *p_cmap;
     struct prt_ps_charset_S **pp_mbchar;
 {
-    int     mbchar;
-    int     char_len;
+    int			    mbchar;
+    int			    char_len;
     struct prt_ps_charset_S *p_mbchar;
 
     /* Look for recognised character set, using default if one is not given */
@@ -5226,7 +5234,7 @@ mch_print_init(psettings, jobname, force
     char_u	*p_encoding;
     struct prt_ps_encoding_S *p_mbenc;
     struct prt_ps_encoding_S *p_mbenc_first;
-    struct prt_ps_charset_S *p_mbchar;
+    struct prt_ps_charset_S  *p_mbchar;
 #endif
 
 #if 0
@@ -5262,11 +5270,13 @@ mch_print_init(psettings, jobname, force
     p_mbenc_first = NULL;
     p_mbchar = NULL;
     for (cmap = 0; cmap < NUM_ELEMENTS(prt_ps_mbfonts); cmap++)
-        if (prt_match_encoding(p_encoding, &prt_ps_mbfonts[cmap], &p_mbenc))
+        if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],
+								    &p_mbenc))
         {
             if (p_mbenc_first == NULL)
                 p_mbenc_first = p_mbenc;
-            if (prt_match_charset(p_pmcs, &prt_ps_mbfonts[cmap], &p_mbchar))
+            if (prt_match_charset((char *)p_pmcs, &prt_ps_mbfonts[cmap],
+								   &p_mbchar))
                 break;
         }
 
@@ -5343,8 +5353,8 @@ mch_print_init(psettings, jobname, force
                 return FALSE;
         if (mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].present)
             if (!prt_build_cid_fontname(PRT_PS_FONT_BOLDOBLIQUE,
-                                        mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].string,
-                                        mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].strlen))
+				   mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].string,
+				  mbfont_opts[OPT_MBFONT_BOLDOBLIQUE].strlen))
                 return FALSE;
 
         /* Check if need to use Courier for ASCII code range, and if so pick up
@@ -5555,8 +5565,8 @@ prt_add_resource(resource)
 	EMSG2(_("E456: Can't open file \"%s\""), resource->filename);
 	return FALSE;
     }
-    prt_dsc_resources("BeginResource",
-                        prt_resource_types[resource->type], resource->title);
+    prt_dsc_resources("BeginResource", prt_resource_types[resource->type],
+						     (char *)resource->title);
 
     prt_dsc_textline("BeginDocument", (char *)resource->filename);
 
@@ -5602,7 +5612,7 @@ mch_print_begin(psettings)
     double      bottom;
     struct prt_ps_resource_S res_prolog;
     struct prt_ps_resource_S res_encoding;
-    char_u      buffer[256];
+    char	buffer[256];
     char_u      *p_encoding;
 #ifdef FEAT_MBYTE
     struct prt_ps_resource_S res_cidfont;
@@ -5614,7 +5624,7 @@ mch_print_begin(psettings)
      */
     prt_dsc_start();
     prt_dsc_textline("Title", (char *)psettings->jobname);
-    if (!get_user_name(buffer, 256))
+    if (!get_user_name((char_u *)buffer, 256))
         STRCPY(buffer, "Unknown");
     prt_dsc_textline("For", buffer);
     prt_dsc_textline("Creator", VIM_VERSION_LONG);
@@ -5757,7 +5767,7 @@ mch_print_begin(psettings)
             if (!prt_find_resource(prt_ascii_encoding, &res_encoding))
             {
                 EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
-                      prt_ascii_encoding);
+							  prt_ascii_encoding);
                 return FALSE;
             }
             if (!prt_open_resource(&res_encoding))
@@ -5786,7 +5796,7 @@ mch_print_begin(psettings)
         if (!prt_find_resource(prt_cmap, &res_cmap))
         {
             EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""),
-                  prt_cmap);
+								    prt_cmap);
             return FALSE;
         }
         if (!prt_open_resource(&res_cmap))
@@ -5911,7 +5921,7 @@ mch_print_begin(psettings)
         /* When using Courier for ASCII range when printing multi-byte, need to
          * pick up ASCII encoding to use with it. */
         if (prt_use_courier)
-            p_encoding = prt_ascii_encoding;
+            p_encoding = (char_u *)prt_ascii_encoding;
 #endif
         prt_dsc_resources("IncludeResource", "font",
                           prt_ps_courier_font.ps_fontname[PRT_PS_FONT_ROMAN]);
@@ -6015,7 +6025,7 @@ mch_print_end(psettings)
 
     /* Write CTRL-D to close serial communication link if used.
      * NOTHING MUST BE WRITTEN AFTER THIS! */
-    prt_write_file(IF_EB("\004", "\067"));
+    prt_write_file((char_u *)IF_EB("\004", "\067"));
 
     if (!prt_file_error && psettings->outfile == NULL
 					&& !got_int && !psettings->user_abort)
@@ -6274,7 +6284,7 @@ mch_print_text_out(p, len)
          */
         do
         {
-           ch = prt_hexchar[(*p) >> 4];
+           ch = prt_hexchar[(unsigned)(*p) >> 4];
            ga_append(&prt_ps_buffer, ch);
            ch = prt_hexchar[(*p) & 0xf];
            ga_append(&prt_ps_buffer, ch);
--- a/src/gui_kde.cc
+++ b/src/gui_kde.cc
@@ -29,7 +29,7 @@
 #include <qmessagebox.h>
 #include <qiconset.h>
 #include <qtextcodec.h>
-#include "gui_kde_widget.h"
+#include "gui_kde_wid.h"
 
 extern "C" {
 #include "vim.h"
new file mode 100644
--- /dev/null
+++ b/src/gui_kde_wid.cc
@@ -0,0 +1,1449 @@
+/* vi:set ts=8 sts=4 sw=4:
+ *
+ * VIM - Vi IMproved		by Bram Moolenaar
+ *
+ * Do ":help uganda"  in Vim to read copying and usage conditions.
+ * Do ":help credits" in Vim to see a list of people who contributed.
+ */
+
+/*
+ * Porting to KDE(2) was done by
+ *
+ *  (C) 2000 by Thomas Capricelli <orzel@freehackers.org>
+ *
+ *  Please visit http://freehackers.org/kvim for other vim- or
+ *  kde-related coding.
+ *
+ *  $Id$
+ *
+ */
+
+#include <assert.h>
+#include <qpainter.h>
+#include <qevent.h>
+#include <qpushbutton.h>
+#include <qscrollbar.h>
+#include <qlayout.h>
+#include <qclipboard.h>
+#include <qdragobject.h>
+#include <qstrlist.h>
+#include <qmenubar.h>
+#include <qtextcodec.h>
+#if QT_VERSION>=300
+#include <qptrlist.h>
+#include <ktip.h>
+#endif
+#include <kglobal.h>
+#include <kconfig.h>
+#include <kaboutapplication.h>
+#include <dcopclient.h>
+#include <kaboutkde.h>
+#include <kbugreport.h>
+#include <kurldrag.h>
+#include <kmenubar.h>
+#include <ktoolbar.h>
+#include <kstandarddirs.h>
+#include "gui_kde_wid.h"
+#include <qxembed.h>
+
+extern "C"
+{
+#include "version.h"
+}
+
+// Pixmap for dialog
+#ifdef FEAT_GUI_DIALOG
+# include "../../pixmaps/alert.xpm"
+# include "../../pixmaps/error.xpm"
+# include "../../pixmaps/generic.xpm"
+# include "../../pixmaps/info.xpm"
+# include "../../pixmaps/quest.xpm"
+#endif
+
+/**
+ * Keycodes recognized by vim.
+ */
+struct special_key {//{{{
+    int qtkey;
+    char_u code0;
+    char_u code1;
+} special_keys[] =
+{
+    { Qt::Key_Up,		'k', 'u' },
+    { Qt::Key_Down,		'k', 'd' },
+    { Qt::Key_Left,		'k', 'l' },
+    { Qt::Key_Right,		'k', 'r' },
+    { Qt::Key_F1,		'k', '1' },
+    { Qt::Key_F2,		'k', '2' },
+    { Qt::Key_F3,		'k', '3' },
+    { Qt::Key_F4,		'k', '4' },
+    { Qt::Key_F5,		'k', '5' },
+    { Qt::Key_F6,		'k', '6' },
+    { Qt::Key_F7,		'k', '7' },
+    { Qt::Key_F8,		'k', '8' },
+    { Qt::Key_F9,		'k', '9' },
+    { Qt::Key_F10,		'k', ';' },
+    { Qt::Key_F11,		'F', '1' },
+    { Qt::Key_F12,		'F', '2' },
+    { Qt::Key_F13,		'F', '3' },
+    { Qt::Key_F14,		'F', '4' },
+    { Qt::Key_F15,		'F', '5' },
+    { Qt::Key_F16,		'F', '6' },
+    { Qt::Key_F17,		'F', '7' },
+    { Qt::Key_F18,		'F', '8' },
+    { Qt::Key_F19,		'F', '9' },
+    { Qt::Key_F20,		'F', 'A' },
+    { Qt::Key_F21,		'F', 'B' },
+    { Qt::Key_F22,		'F', 'C' },
+    { Qt::Key_F23,		'F', 'D' },
+    { Qt::Key_F24,		'F', 'E' },
+    { Qt::Key_F25,		'F', 'F' },
+    { Qt::Key_F26,		'F', 'G' },
+    { Qt::Key_F27,		'F', 'H' },
+    { Qt::Key_F28,		'F', 'I' },
+    { Qt::Key_F29,		'F', 'J' },
+    { Qt::Key_F30,		'F', 'K' },
+    { Qt::Key_F31,		'F', 'L' },
+    { Qt::Key_F32,		'F', 'M' },
+    { Qt::Key_F33,		'F', 'N' },
+    { Qt::Key_F34,		'F', 'O' },
+    { Qt::Key_F35,		'F', 'P' },
+    { Qt::Key_Help,		'%', '1' },
+    //    { Qt::Key_Undo,		'&', '8' }, <= hmmm ?
+    { Qt::Key_BackSpace,	'k', 'b' },
+    { Qt::Key_Insert,		KS_EXTRA, KE_KINS },
+    { Qt::Key_Delete,		KS_EXTRA, KE_KDEL },
+    { Qt::Key_Home,		'K', '1' },
+    { Qt::Key_End,		'K', '4' },
+    { Qt::Key_Prior,		'K', '3' },
+    { Qt::Key_Next,		'K', '5' },
+    { Qt::Key_Print,		'%', '9' },
+
+    { Qt::Key_Plus,	'K', '6'},
+    { Qt::Key_Minus,	'K', '7'},
+    { Qt::Key_Slash,	'K', '8'},
+    { Qt::Key_multiply,	'K', '9'},
+    { Qt::Key_Enter,	'K', 'A'},
+    { Qt::Key_Period,	'K', 'B'},
+
+    { Qt::Key_0,	'K', 'C'},
+    { Qt::Key_1,	'K', 'D'},
+    { Qt::Key_2,	'K', 'E'},
+    { Qt::Key_3,	'K', 'F'},
+    { Qt::Key_4,	'K', 'G'},
+    { Qt::Key_5,	'K', 'H'},
+    { Qt::Key_6,	'K', 'I'},
+    { Qt::Key_7,	'K', 'J'},
+    { Qt::Key_8,	'K', 'K'},
+    { Qt::Key_9,	'K', 'L'},
+    /* End of list marker: */
+    { 0, 0, 0 }
+};//}}}
+
+#ifdef FEAT_CLIENTSERVER
+typedef int (*QX11EventFilter) (XEvent*);
+extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter);
+static QX11EventFilter oldFilter = 0;
+static int kvim_x11_event_filter( XEvent* e);
+#endif
+void gui_keypress(QKeyEvent *e);
+
+/*
+ * Return OK if the key with the termcap name "name" is supported.
+ */
+    int
+gui_mch_haskey(char_u * name)//{{{
+{
+    for (int i=0; special_keys[i].qtkey != 0; i++)
+	if (name[0] == special_keys[i].code0 &&
+		name[1] == special_keys[i].code1)
+	    return OK;
+    return FAIL;
+}//}}}
+
+/*
+ * custom Frame for drawing ...
+ */
+void VimWidget::paintEvent( QPaintEvent *e)//{{{
+{
+    QRect r = e->rect();
+    gui_redraw(r.x(), r.y(), r.width(), r.height() );
+}//}}}
+
+void VimWidget::draw_string(int x, int y, QString s, int len, int flags)//{{{
+{
+    gui.current_font->setBold( flags & DRAW_BOLD );
+    gui.current_font->setUnderline( flags & DRAW_UNDERL );
+    gui.current_font->setItalic(flags & DRAW_ITALIC);
+    painter->setBackgroundMode( flags & DRAW_TRANSP ? Qt::TransparentMode : Qt::OpaqueMode);
+    painter->setFont( *(gui.current_font) );
+    painter->drawText( x, y, s, len);
+}//}}}
+
+void VimWidget::mousePressEvent(QMouseEvent *event)//{{{
+{
+    int button=0;
+    int modifiers=0;
+    ButtonState state = event->state();
+    ButtonState buttons = event->button();
+
+    //Look at button states
+    if (buttons & QMouseEvent::LeftButton)
+	button |= MOUSE_LEFT;
+    if (buttons & QMouseEvent::RightButton)
+	button |= MOUSE_RIGHT;
+    if (buttons & QMouseEvent::MidButton)
+	button |= MOUSE_MIDDLE;
+    //Look for keyboard modifiers
+    if (state & QMouseEvent::ShiftButton)
+	modifiers |= MOUSE_SHIFT;
+    if (state & QMouseEvent::ControlButton)
+	modifiers |= MOUSE_CTRL;
+    if (state & QMouseEvent::AltButton)
+	modifiers |= MOUSE_ALT;
+    gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers);
+#if QT_VERSION>=300
+    QByteArray params;
+    QDataStream stream(params, IO_WriteOnly);
+    stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col;
+    kapp->dcopClient()->emitDCOPSignal("mousePEvent(QCString,int,int,int,int)", params);
+#endif
+    event->accept();
+}//}}}
+
+#if defined(FEAT_SESSION)
+void VimMainWindow::saveGlobalProperties (KConfig *conf)
+{
+    //we write a mksession file to a file written in the user's ~/.kde/share/config/
+    //the name of the file in saved in 'conf'
+    //when restoring app, we source this file
+#if 0 //disabled for release
+    QString filename = KGlobal::dirs()->localkdedir() + KGlobal::dirs()->kde_default("config") + kapp->randomString(10);
+    QString cmd("mksession ");
+    cmd+=filename;
+    do_cmdline_cmd((char_u*)cmd.latin1());
+    conf->writePathEntry("sessionfile", filename);
+    conf->sync();
+#endif
+}
+
+void VimMainWindow::readGlobalProperties (KConfig *conf)
+{
+#if 0
+    QString filename = conf->readPathEntry("sessionfile");
+    if (filename.isNull()) return;
+    QString cmd("source ");
+    cmd+=filename;
+    do_cmdline_cmd((char_u*)cmd.latin1());
+#endif
+}
+#endif
+
+void VimMainWindow::wheelEvent (QWheelEvent *event)//{{{
+{
+    ButtonState state = event->state();
+    int button=0;
+    int modifiers=0;
+
+    if (event->delta()>0)
+	button|=MOUSE_4;
+    else button|=MOUSE_5;
+
+    if (state & ShiftButton)
+	modifiers|=MOUSE_SHIFT;
+    if (state & ControlButton)
+	modifiers|=MOUSE_CTRL;
+    if (state & AltButton)
+	modifiers|=MOUSE_ALT;
+
+    gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers);
+#if QT_VERSION>=300
+    QByteArray params;
+    QDataStream stream(params, IO_WriteOnly);
+    stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col;
+    kapp->dcopClient()->emitDCOPSignal("mouseWhlEvent(QCString, int, int,int,int)", params);
+#endif
+    event->accept();
+}//}}}
+
+void VimWidget::mouseDoubleClickEvent(QMouseEvent *event)//{{{
+{
+    ButtonState state = event->state();
+    ButtonState buttons = event->button();
+    int modifiers=0;
+    int button=0;
+
+    //Look at button states
+    if (buttons & LeftButton)
+	button|=MOUSE_LEFT;
+    if (buttons & RightButton)
+	button|=MOUSE_RIGHT;
+    if (buttons & MidButton)
+	button|=MOUSE_MIDDLE;
+
+    //Look for keyboard modifiers
+    if (state & ShiftButton)
+	modifiers|=MOUSE_SHIFT;
+    if (state & ControlButton)
+	modifiers|=MOUSE_CTRL;
+    if (state & AltButton)
+	modifiers|=MOUSE_ALT;
+
+    gui_send_mouse_event(button,event->x(),event->y(),TRUE,modifiers);
+#if QT_VERSION>=300
+    QByteArray params;
+    QDataStream stream(params, IO_WriteOnly);
+    stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col;
+    kapp->dcopClient()->emitDCOPSignal("mouseDblClickEvent(QCString, int, int,int,int)", params);
+#endif
+    event->accept();
+}//}}}
+
+void VimWidget::mouseMoveEvent(QMouseEvent *event){//{{{
+    ButtonState state = event->state();
+    int modifiers=0;
+    int button=0;
+
+    gui_mch_mousehide(FALSE);
+
+    //Look at button states
+    //warning: we use state here, this is important !
+    if (state & QMouseEvent::LeftButton || state & QMouseEvent::RightButton || state & QMouseEvent::MidButton)
+	button|=MOUSE_DRAG;
+
+    //Look for keyboard modifiers
+    if (state & ShiftButton)
+	modifiers|=MOUSE_SHIFT;
+    if (state & ControlButton)
+	modifiers|=MOUSE_CTRL;
+    if (state & AltButton)
+	modifiers|=MOUSE_ALT;
+    if (button!=MOUSE_DRAG)
+	gui_mouse_moved(event->x(),event->y());
+    else
+	gui_send_mouse_event(MOUSE_DRAG,event->x(),event->y(),FALSE,modifiers);
+}//}}}
+
+void VimWidget::mouseReleaseEvent(QMouseEvent *event)//{{{
+{
+    ButtonState state = event->state();
+    int modifiers=0;
+
+    //Look for keyboard modifiers
+    if (state & ShiftButton)
+	modifiers|=MOUSE_SHIFT;
+    if (state & ControlButton)
+	modifiers|=MOUSE_CTRL;
+    if (state & AltButton)
+	modifiers|=MOUSE_ALT;
+
+    gui_send_mouse_event(MOUSE_RELEASE,event->x(),event->y(),FALSE,modifiers);
+    event->accept();
+}//}}}
+
+/*
+ *  The main widget (everything but toolbar/menubar)
+ */
+    VimWidget::VimWidget( QWidget *parent, const char *name, WFlags f )//{{{
+:QWidget(parent, name, f)
+    ,DCOPObject("KVim")
+#ifdef FEAT_MZSCHEME
+    ,mzscheme_timer_id(-1)
+#endif
+{
+    //to be able to show/hide the cursor when moving the mouse
+    setMouseTracking(true);
+    painter=new QPainter(this);
+
+    setKeyCompression(true);
+    setFocusPolicy( QWidget::StrongFocus );
+    setAcceptDrops(TRUE); // DND
+    blink_state = BLINK_NONE;
+    blink_on_time = 700;
+    blink_off_time = 400;
+    blink_wait_time = 250;
+    connect( &blink_timer, SIGNAL( timeout() ), SLOT( blink_cursor() ));
+    connect( &wait_timer, SIGNAL( timeout() ), SLOT ( wait_timeout() ));
+}//}}}
+
+void VimWidget::execNormal(QString command)//{{{
+{
+    QString cmd("execute 'normal ");
+    cmd+=command;
+    cmd+="'";
+    QCString unistring = vmw->codec->fromUnicode(cmd);
+    do_cmdline_cmd((char_u *)(const char*)unistring);
+    gui_update_screen();
+}//}}}
+
+void VimWidget::execInsert(QString command)//{{{
+{
+    QString cmd("execute 'normal i");
+    cmd+=command;
+    cmd+="'";
+    QCString unistring = vmw->codec->fromUnicode(cmd);
+    do_cmdline_cmd((char_u *)(const char*)unistring);
+    gui_update_screen();
+}//}}}
+
+void VimWidget::execRaw(QString command)//{{{
+{
+    QString cmd("execute '");
+    cmd+=command;
+    cmd+="'";
+    QCString unistring = vmw->codec->fromUnicode(cmd);
+    do_cmdline_cmd((char_u *)(const char*)unistring);
+    gui_update_screen();
+}//}}}
+
+void VimWidget::execCmd(QString command)//{{{
+{
+    QCString unistring = vmw->codec->fromUnicode(command);
+    do_cmdline_cmd((char_u *)(const char*)unistring);
+    gui_update_screen();
+}//}}}
+
+QString VimWidget::eval(QString expr)//{{{
+{
+#ifdef FEAT_EVAL
+    QCString unistring = vmw->codec->fromUnicode(expr);
+    QString val((const char *)eval_to_string((char_u *)(const char*)unistring,NULL));
+    return val;
+#else
+    return QString::null;
+#endif
+}//}}}
+
+void VimWidget::wait(long wtime)//{{{
+{
+    if ( wait_timer.isActive() ) wait_timer.stop();
+    wait_done = false;
+    wait_timer.start( wtime, true);
+}//}}}
+
+void VimWidget::wait_timeout() //{{{
+{
+    wait_done = true;
+}//}}}
+
+void VimWidget::dragEnterEvent (QDragEnterEvent *e)//{{{
+{
+#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO)
+    e->accept(QUriDrag::canDecode(e));
+#else
+    e->ignore();
+#endif
+}//}}}
+
+void VimWidget::dropEvent (QDropEvent *e) // {{{
+{
+#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO)
+    QStrList  urls;
+
+    char_u	**fnames;
+    int		redo_dirs = FALSE;
+    int		i;
+    int		n;
+    int		nfiles;
+    int		url = FALSE;
+
+    /* Count how many items there may be and normalize delimiters. */
+
+    if (QUriDrag::decode(e, urls))
+    {
+	n = urls.count();
+        fnames = (char_u **)lalloc((n+1) * sizeof(char_u *), TRUE);
+	nfiles = 0;
+#if QT_VERSION>=300
+	QPtrListIterator<char> it(urls);
+	for (; it.current(); ++it )
+	{
+	    KURL u(*it);
+#else
+	    for (i=0;i<urls.count();++i)
+	    {
+		KURL u(urls.at(i));
+#endif
+		if ( !u.isLocalFile() )
+		    url = TRUE;
+		else
+		{
+		    fnames[nfiles] = (char_u *)strdup((const char *)u.path());
+		    ++nfiles;
+		}
+	    }
+	    /* Real files (i.e. not http and not ftp) */
+	    if (url == FALSE)
+	    {
+		if (nfiles == 1)
+		{
+		    if (mch_isdir(fnames[0]))
+		    {
+			/* Handle dropping a directory on Vim. */
+			if (mch_chdir((char *)fnames[0]) == 0)
+			{
+			    free(fnames[0]);
+			    fnames[0] = NULL;
+			    redo_dirs = TRUE;
+			}
+		    }
+		}
+		else
+		{
+		    /* Ignore any directories */
+		    for (i = 0; i < nfiles; ++i)
+		    {
+			if (mch_isdir(fnames[i]))
+			{
+			    vim_free(fnames[i]);
+			    fnames[i] = NULL;
+			}
+		    }
+		}
+
+		if (0)
+		{
+		    /* Shift held down, change to first file's directory */
+		    if (fnames[0] != NULL && vim_chdirfile(fnames[0]) == OK)
+			redo_dirs = TRUE;
+		}
+		else
+		{
+		    char_u	dirname[MAXPATHL];
+		    char_u	*s;
+		    if (mch_dirname(dirname, MAXPATHL) == OK)
+			for (i = 0; i < nfiles; ++i)
+			    if (fnames[i] != NULL)
+			    {
+				s = shorten_fname(fnames[i], dirname);
+				if (s != NULL && (s = vim_strsave(s)) != NULL)
+				{
+				    vim_free(fnames[i]);
+				    fnames[i] = s;
+				}
+			    }
+		}
+	    }
+
+	    /* Handle the drop, :edit or :split to get to the file */
+	    handle_drop(nfiles, fnames, FALSE);
+
+	    if (redo_dirs)
+		shorten_fnames(TRUE);
+	}
+
+	/* Update the screen display */
+	update_screen(NOT_VALID);
+#ifdef FEAT_MENU
+	gui_update_menus(0);
+#endif
+	setcursor();
+	out_flush();
+	gui_update_cursor(FALSE, FALSE);
+	gui_mch_flush();
+#endif
+} // }}}
+
+void VimWidget::keyPressEvent( QKeyEvent *e ) // {{{
+{
+    gui_keypress(e);
+} // }}}
+
+void gui_keypress(QKeyEvent *e) { // {{{
+    int key = (int)e->key();
+    int modifiers = 0,i;
+    uchar string[256],string2[256];
+    uchar *s,*d;
+    Qt::ButtonState state = e->state();
+
+    QCString unistring = vmw->codec->fromUnicode(e->text());
+    if (unistring.length()>0)
+	strncpy((char*)string, (const char*)unistring,unistring.length());
+    string[unistring.length()] = 0;
+    int len=unistring.length();
+
+    // ignore certain keys
+    if (key == Qt::Key_Shift || key == Qt::Key_Alt || key == Qt::Key_Control || key == Qt::Key_Meta
+	    || key == Qt::Key_CapsLock || key == Qt::Key_NumLock || key == Qt::Key_ScrollLock )
+    {
+	e->ignore();
+	return;
+    }
+
+#ifdef FEAT_MBYTE
+    if (input_conv.vc_type != CONV_NONE)
+    {
+	mch_memmove(string2, string, len);
+	len = convert_input(string2, len, sizeof(string2));
+	s = string2;
+    }
+    else
+#endif
+	s = string;
+    d = string;
+    for (i = 0; i < len; ++i)
+    {
+	*d++ = s[i];
+	if (d[-1] == CSI && d + 2 < string + sizeof(string))
+	{
+	    /* Turn CSI into K_CSI. */
+	    *d++ = KS_EXTRA;
+	    *d++ = (int)KE_CSI;
+	}
+    }
+    len = d - string;
+
+
+    // change shift-tab (backtab) into S_TAB
+    if ( key == Qt::Key_BackTab && state & Qt::ShiftButton)
+	key = Qt::Key_Tab;
+
+    // Change C-@ and C-2 in NUL ? Gtk does this
+    if ( (key == Qt::Key_2 || key == Qt::Key_At)
+	    && state & Qt::ControlButton )
+    {
+	string[0] = NUL;
+	len = 1;
+    }
+    else if (len == 0 && (key == Qt::Key_Space || key == Qt::Key_Tab))
+    {
+	/* When there are modifiers, these keys get zero length; we need the
+	 * original key here to be able to add a modifier below. */
+	string[0] = (key & 0xff);
+	len = 1;
+    }
+    /* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character
+     * that already has the 8th bit set.
+     * Don't do this for <S-M-Tab>, that should become K_S_TAB with ALT. */
+    if (len == 1
+	    && (key != Qt::Key_BackSpace && key != Qt::Key_Delete)
+	    && (string[0] & 0x80) == 0
+	    && (state & Qt::AltButton)
+	    && !(key == Qt::Key_Tab && (state & Qt::ShiftButton)))
+    {
+	string[0] |= 0x80;
+#ifdef FEAT_MBYTE
+	if (enc_utf8) // convert to utf-8
+	{
+	    string[1] = string[0] & 0xbf;
+	    string[0] = ((unsigned)string[0] >> 6) + 0xc0;
+	    if (string[1] == CSI)
+	    {
+		string[2] = KS_EXTRA;
+		string[3] = (int)KE_CSI;
+		len = 4;
+	    }
+	    else
+		len = 2;
+	}
+#endif
+    }
+
+    /* Check for special keys, making sure BS and DEL are recognised. */
+    if (len == 0 || key == Qt::Key_BackSpace || key == Qt::Key_Delete)
+    {
+	while (special_keys[i].qtkey != 0 && special_keys[i].qtkey != key ) i++;
+	if (special_keys[i].qtkey != 0)
+	{
+		string[0] = CSI;
+		string[1] = special_keys[i].code0;
+		string[2] = special_keys[i].code1;
+		len = -3;
+	}
+/*
+	for (i = 0; special_keys[i].qtkey != 0 ; i++)
+	{
+	    if (special_keys[i].qtkey == key )
+	    {
+		string[0] = CSI;
+		string[1] = special_keys[i].code0;
+		string[2] = special_keys[i].code1;
+		len = -3;
+		break;
+	    }
+	}*/
+    }
+
+    if (len == 0)
+    {
+	//no need to dump that, that's a QT problem, we can't do anything
+	//dbf("Unrecognised Key : %X %s", key, e->text().latin1());
+	e->ignore();
+	return;
+    }
+
+
+    /* Special keys (and a few others) may have modifiers */
+    if (len == -3 || key == Qt::Key_Space || key == Qt::Key_Tab ||
+	    key == Qt::Key_Return || key == Qt::Key_Enter ||
+	    key == Qt::Key_Escape)
+    {
+
+	modifiers = 0;
+	if (state & Qt::ShiftButton) modifiers |= MOD_MASK_SHIFT;
+	if (state & Qt::ControlButton) modifiers |= MOD_MASK_CTRL;
+	if (state & Qt::AltButton) modifiers |= MOD_MASK_ALT;
+
+	/*
+	 * For some keys a shift modifier is translated into another key
+	 * code. Do we need to handle the case where len != 1 and
+	 * string[0] != CSI?
+	 */
+	if (len == -3)
+	    key = TO_SPECIAL(string[1], string[2]);
+	else
+	    key = string[0];
+
+	key = simplify_key(key, &modifiers);
+	if (key == CSI) key=K_CSI;
+
+	if (IS_SPECIAL(key))
+	{
+	    string[0] = CSI;
+	    string[1] = K_SECOND(key);
+	    string[2] = K_THIRD(key);
+	    len = 3;
+	}
+	else
+	{
+	    string[0] = key;
+	    len = 1;
+	}
+
+
+	if (modifiers!=0)
+	{
+	    uchar string2[10];
+	    string2[0] = CSI;
+	    string2[1] = KS_MODIFIER;
+	    string2[2] = modifiers;
+	    add_to_input_buf(string2, 3);
+	}
+
+    } /* special keys */
+
+    if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
+		|| (string[0] == intr_char && intr_char != Ctrl_C)))
+    {
+	trash_input_buf();
+	got_int = TRUE;
+    }
+
+    add_to_input_buf(string, len);
+    if (p_mh)
+	gui_mch_mousehide(TRUE);
+
+    //DCOP Embedding stuff
+    //if we are here then the user has type something in the window, thus we can easily imagine that :
+    // 1 - text has changed (emit textChanged())
+    // 2 - characters were interactively inserted (emit charactersInteractivelyInserted())
+    // 3 - cursor position has changed ( emit cursorPositionChanged() )
+    // 4 - selection has changed ? dunno yet //XXX
+    // 5 - undo changed too ? (each character typed in makes the undo changes anyway)
+    // conclusion : this makes a lot of things to send to the vim kpart, maybe too much
+    // for now i'll just send : keyboardEvent to the kpart with the event string as parameter,
+    // with current current position
+    // i'll do the same for mouseEvents
+#if QT_VERSION>=300
+    QByteArray params;
+    QDataStream stream(params, IO_WriteOnly);
+    stream << kapp->dcopClient()->appId() << unistring << gui.row << gui.col;
+    kapp->dcopClient()->emitDCOPSignal("keyboardEvent(QCString, QCString,int,int)", params);
+#endif
+    e->ignore();
+} // }}}
+
+#ifdef FEAT_CLIENTSERVER
+void VimWidget::serverActivate(WId id) //{{{
+{
+    if (serverName == NULL && serverDelayedStartName != NULL)
+    {
+	commWindow = id;
+	(void)serverRegisterName(qt_xdisplay(), serverDelayedStartName);
+    }
+    else
+	serverChangeRegisteredWindow( qt_xdisplay(), id);
+}//}}}
+#endif
+
+#ifdef FEAT_XIM
+void VimWidget::imStartEvent(QIMEvent *e)
+{
+    e->accept();
+}
+
+void VimWidget::imEndEvent(QIMEvent *e)
+{
+    uchar string[256];
+
+    QCString unistring = vmw->codec->fromUnicode(e->text());
+    if (unistring.length()>0)
+	strncpy((char*)string, (const char*)unistring,unistring.length());
+    string[unistring.length()] = 0;
+    int len=unistring.length();
+
+    add_to_input_buf(string, len);
+    e->accept();
+}
+
+void VimWidget::imComposeEvent(QIMEvent *e)
+{
+    //i should do something here, displaying the text somewhere ... (status area ?)
+    e->accept();
+}
+#endif
+
+
+void VimMainWindow::lock()
+{
+    locked=true;
+}
+
+void VimMainWindow::unlock()
+{
+    locked=false;
+}
+
+bool VimMainWindow::isLocked()
+{
+    return locked;
+}
+
+// ->resize VimWidget if not locked
+//
+void VimMainWindow::resizeEvent ( QResizeEvent *e ) //{{{
+{
+    if ( vmw->isLocked() ) return;
+    //remove toolbar and menubar height
+    int height = e->size().height();
+    int width = e->size().width();
+
+    if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
+#if QT_VERSION>=300
+	    && !vmw->menuBar()->isTopLevelMenu()
+#endif
+	    )
+	height -= vmw->menuBar()->height();
+#ifdef FEAT_TOOLBAR
+    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
+	    (vmw->toolBar()->barPos()==KToolBar::Top ||
+	     vmw->toolBar()->barPos()==KToolBar::Bottom))
+	height -= vmw->toolBar()->height();
+
+    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
+	    (vmw->toolBar()->barPos()==KToolBar::Left ||
+	     vmw->toolBar()->barPos()==KToolBar::Right))
+	width -= vmw->toolBar()->width();
+#endif
+    height = ( ((int)(height/gui.char_height))*gui.char_height );
+    if (!vmw->isLocked()) gui_resize_shell(width,height);
+}//}}}
+
+void VimWidget::focusInEvent( QFocusEvent * fe ) // {{{
+{
+    gui_focus_change(true);
+
+    if (blink_state == BLINK_NONE)
+	gui_mch_start_blink();
+} // }}}
+
+void VimWidget::focusOutEvent( QFocusEvent * fe )//{{{
+{
+    gui_focus_change(false);
+
+    if (blink_state != BLINK_NONE)
+	gui_mch_stop_blink();
+}//}}}
+
+void VimWidget::set_blink_time( long wait, long on, long off)//{{{
+{
+    blink_wait_time = wait;
+    blink_on_time = on;
+    blink_off_time = off;
+}//}}}
+
+void VimWidget::start_cursor_blinking()//{{{
+{
+    if (blink_timer.isActive()) blink_timer.stop();
+
+    /* Only switch blinking on if none of the times is zero */
+    if (blink_wait_time && blink_on_time && blink_off_time && gui.in_focus)
+    {
+	blink_state = BLINK_ON;
+	gui_update_cursor(TRUE, FALSE);
+	// The first blink appears after wait_time
+	blink_timer.start( blink_wait_time, true);
+    }
+}//}}}
+
+void VimWidget::blink_cursor()//{{{
+{
+    if (blink_state == BLINK_ON)
+    {
+	// set cursor off
+	gui_undraw_cursor();
+	blink_state = BLINK_OFF;
+	blink_timer.start( blink_off_time, true);
+    }
+    else
+    {
+	// set cursor on
+	gui_update_cursor(TRUE, FALSE);
+	blink_state = BLINK_ON;
+	blink_timer.start( blink_on_time, true);
+    }
+}//}}}
+
+void VimWidget::stop_cursor_blinking()//{{{
+{
+    if (blink_timer.isActive()) blink_timer.stop();
+
+    if (blink_state == BLINK_OFF)
+	gui_update_cursor(TRUE, FALSE);
+
+    blink_state = BLINK_NONE;
+}//}}}
+
+#ifdef FEAT_MZSCHEME
+void VimWidget::timerEvent( QTimerEvent * evnt)//{{{
+{
+    if (evnt->timerId() == mzscheme_timer_id)
+	timer_proc();
+}//}}}
+
+void VimWidget::enable_mzscheme_threads()//{{{
+{
+    mzscheme_timer_id = startTimer(p_mzq);
+}//}}}
+
+void VimWidget::disable_mzscheme_threads()//{{{
+{
+    killTimer(mzscheme_timer_id);
+}//}}}
+#endif
+
+void VimWidget::flash()//{{{
+{
+    QPainter p(this);
+
+    p.setRasterOp(Qt::XorROP);
+    p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF));
+    p.flush();
+    //FIXME: Make this a little smarter. Maybe add a timer or something
+    usleep(19000);
+    p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF));
+    p.flush();
+    p.end();
+}//}}}
+
+
+/*
+ *  The main Window
+ */
+    VimMainWindow::VimMainWindow ( const char *name , WFlags f)//{{{
+:KMainWindow(0L, name,f)
+{
+#ifdef FEAT_CLIENTSERVER
+    oldFilter = qt_set_x11_event_filter( kvim_x11_event_filter );
+#endif
+    if (echo_wid_arg== 1)
+    {
+	fprintf(stderr, "WID: %ld\n", (long)winId());
+	fflush(stderr);
+    }
+
+    w = new VimWidget(this, "main vim widget");
+    gui.w = w;
+    setFocusProxy(w);
+    w->setFocus();
+    have_tearoff=0;
+
+    finddlg=new KEdFind (this,0,false);
+    repldlg=new KEdReplace (this,0,false);
+    QObject::connect( finddlg, SIGNAL(search()), this, SLOT(slotSearch()) );
+    QObject::connect( repldlg, SIGNAL(find()), this, SLOT(slotFind()) );
+    QObject::connect( repldlg, SIGNAL(replace()), this, SLOT(slotReplace()) );
+    QObject::connect( repldlg, SIGNAL(replaceAll()), this, SLOT(slotReplaceAll()) );
+
+#ifdef FEAT_TOOLBAR
+    connect(toolBar(), SIGNAL(clicked(int)), this, SLOT(menu_activated(int)));
+#endif
+#ifdef FEAT_CLIENTSERVER
+    w->serverActivate(winId());
+
+    if (serverName!=NULL)
+        kapp->dcopClient()->registerAs(QCString((const char*)serverName),false);
+    else if (serverDelayedStartName!=NULL)
+        kapp->dcopClient()->registerAs(QCString((const char*)serverDelayedStartName),false);
+    else if (argServerName!=NULL)
+        kapp->dcopClient()->registerAs(argServerName->utf8(),false);
+#else
+    if (argServerName!=NULL)
+        kapp->dcopClient()->registerAs(argServerName->utf8(),false);
+#endif
+    QXEmbed::initialize();
+
+}//{{{
+
+bool VimMainWindow::queryClose()//{{{
+{
+    gui_shell_closed();
+    return true;
+}//}}}
+
+bool VimMainWindow::queryExit()//{{{
+{
+    return true;
+}//}}}
+
+void VimMainWindow::menu_activated(int dx)//{{{
+{
+#ifdef FEAT_MENU
+    if (!dx) {	// tearoff
+	return;
+    }
+    gui_mch_set_foreground();
+    gui_menu_cb((VimMenu *) dx);
+#endif
+}//}}}
+
+
+void VimMainWindow::clipboard_selection_update(){//{{{
+    if (kapp->clipboard()->ownsSelection())
+	clip_own_selection(&clip_star);
+    else
+	clip_lose_selection(&clip_star);
+}//}}}
+
+void VimMainWindow::clipboard_data_update(){//{{{
+#if QT_VERSION>=300
+    if (kapp->clipboard()->ownsClipboard())
+	clip_own_selection(&clip_plus);
+    else
+	clip_lose_selection(&clip_plus);
+#else
+    if (kapp->clipboard()->ownsSelection())
+	clip_own_selection(&clip_star);
+    else
+	clip_lose_selection(&clip_star);
+#endif
+}//}}}
+
+void VimMainWindow::slotSearch()//{{{
+{
+    QString	find_text;
+    bool	direction_down = TRUE;
+    bool	casesensitive = TRUE;
+    int		flags = FRD_FINDNEXT;
+
+    find_text = finddlg->getText();
+    direction_down = !(finddlg->get_direction());
+    casesensitive = finddlg->case_sensitive();
+    //    if (casesensitive) find_text = "\\C" + find_text;
+    //    else find_text = "\\c" + find_text;
+    if (casesensitive) flags|=FRD_MATCH_CASE;
+    QCString unistring = vmw->codec->fromUnicode(find_text);
+    gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down);
+}//}}}
+
+void VimMainWindow::slotFind()//{{{
+{
+    QString	find_text;
+    bool	direction_down=TRUE;
+    bool	casesensitive = TRUE;
+    int		flags = FRD_R_FINDNEXT;
+
+    find_text=repldlg->getText();
+    direction_down = !(repldlg->get_direction());
+    casesensitive = repldlg->case_sensitive();
+    //    if (casesensitive) find_text = "\\C" + find_text;
+    //    else find_text = "\\c" + find_text;
+    if (casesensitive) flags|=FRD_MATCH_CASE;
+
+    QCString unistring = vmw->codec->fromUnicode(find_text);
+    gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down);
+}//}}}
+
+void VimMainWindow::slotReplace()//{{{
+{
+    QString	find_text;
+    QString     repl_text;
+    bool	direction_down=TRUE;
+    bool	casesensitive = TRUE;
+    int		flags = FRD_REPLACE;
+
+    find_text=repldlg->getText();
+    repl_text=repldlg->getReplaceText();
+    direction_down = !(repldlg->get_direction());
+    //if (casesensitive) find_text = "\\C" + find_text;
+    //else find_text = "\\c" + find_text;
+    if (casesensitive) flags|=FRD_MATCH_CASE;
+
+    QCString unistring = vmw->codec->fromUnicode(find_text);
+    QCString unistring2 = vmw->codec->fromUnicode(repl_text);
+    gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down);
+}//}}}
+
+void VimMainWindow::slotReplaceAll()//{{{
+{
+    QString	find_text;
+    QString     repl_text;
+    bool	direction_down=TRUE;
+    bool	casesensitive = TRUE;
+    int		flags = FRD_REPLACEALL;
+
+    find_text=repldlg->getText();
+    repl_text=repldlg->getReplaceText();
+    direction_down = !(repldlg->get_direction());
+    casesensitive = repldlg->case_sensitive();
+    //    if (casesensitive) find_text = "\\C" + find_text;
+    //    else find_text = "\\c" + find_text;
+    if (casesensitive) flags|=FRD_MATCH_CASE;
+    QCString unistring = vmw->codec->fromUnicode(find_text);
+    QCString unistring2 = vmw->codec->fromUnicode(repl_text);
+    gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down);
+}//}}}
+
+void VimMainWindow::showAboutKDE()
+{
+    KAboutKDE *kde = new KAboutKDE(this);
+    kde->show();
+}
+
+void VimMainWindow::showAboutApplication()//{{{
+{
+    KAboutData *aboutData = new KAboutData (
+	    "kvim"
+	    , I18N_NOOP("KVim")
+	    , VIM_VERSION_SHORT
+	    , I18N_NOOP("Vim in a KDE interface")
+	    , 0
+	    , "(c) Vim Team, \":help credits\" for more infos.\nType \":help iccf\" to see how you can help the children in Uganda"
+	    , 0l
+	    , "http://freehackers.org/kvim"
+	    , "kvim-dev@freenux.org"
+	    );
+
+    aboutData->addAuthor("Bram Moolenaar",
+	    I18N_NOOP("Main vim author"),
+	    "Bram@vim.org",
+	    "http://www.vim.org/");
+    aboutData->addAuthor("Thomas Capricelli",
+	    I18N_NOOP("KDE porting"),
+	    "orzel@freehackers.org",
+	    "http://orzel.freehackers.org");
+    aboutData->addAuthor("Philippe Fremy",
+	    I18N_NOOP("KDE porting"),
+	    "pfremy@chez.com",
+	    "http://www.freehackers.org/kvim");
+    aboutData->addAuthor("Mark Westcott",
+	    I18N_NOOP("Qtopia porting, maintainer of the Qtopia part"),
+	    "mark@houseoffish.org",
+	    "http://houseoffish.org");
+    aboutData->addAuthor("Mickael Marchand",
+	    I18N_NOOP("KDE porting, maintainer"),
+	    "marchand@kde.org",
+	    "http://freenux.org");
+    aboutData->addAuthor("Many other people",
+	    I18N_NOOP("type :help credits for more infos")
+	    );
+    aboutData->addCredit("Vince Negri",
+	    I18N_NOOP("Antialiasing support, Color fixes"),
+	    "vnegri@asl-electronics.co.uk");
+    aboutData->addCredit("Malte Starostik",
+	    I18N_NOOP("Patch for performance improvement"),
+	    "malte@kde.org");
+    aboutData->addCredit("Mark Stosberg",
+	    I18N_NOOP("Provided a FreeBSD box to debug KVim on BSD"),
+	    "mark@summersault.com"
+	    );
+    aboutData->addCredit("Henrik Skott",
+	    I18N_NOOP("Font patch when KDE not configured"),
+	    "henrik.skott@hem.utfors.se"
+	    );
+    aboutData->addCredit("Kailash Sethuraman",
+	    I18N_NOOP("NetBSD configure/compilation fixes")
+	    );
+    aboutData->setLicenseText(
+"KVim as an extension of Vim follows Vim license : \n\
+Vim is Charityware.  You can use and copy it as much as you like, but you are\n\
+encouraged to make a donation to orphans in Uganda.  Please read the file\n\
+runtime/doc/uganda.txt for details.\n\
+\n\
+There are no restrictions on distributing an unmodified copy of Vim.  Parts of\n\
+Vim may also be distributed, but this text must always be included.  You are\n\
+allowed to include executables that you made from the unmodified Vim sources,\n\
+your own usage examples and Vim scripts.\n\
+\n\
+If you distribute a modified version of Vim, you are encouraged to send the\n\
+maintainer a copy, including the source code.  Or make it available to the\n\
+maintainer through ftp; let him know where it can be found.  If the number of\n\
+changes is small (e.g., a modified Makefile) e-mailing the diffs will do.\n\
+When the maintainer asks for it (in any way) you must make your changes,\n\
+including source code, available to him.\n\
+\n\
+The maintainer reserves the right to include any changes in the official\n\
+version of Vim.  This is negotiable.  You are not allowed to distribute a\n\
+modified version of Vim when you are not willing to make the source code\n\
+available to the maintainer.\n\
+\n\
+The current maintainer is Bram Moolenaar <Bram@vim.org>.  If this changes, it\n\
+will be announced in appropriate places (most likely www.vim.org and\n\
+comp.editors).  When it is completely impossible to contact the maintainer,\n\
+the obligation to send him modified source code ceases.\n\
+\n\
+It is not allowed to remove these restrictions from the distribution of the\n\
+Vim sources or parts of it.  These restrictions may also be used for previous\n\
+Vim releases instead of the text that was included with it.");
+
+    KAboutApplication *about = new KAboutApplication(aboutData);
+    about->show();
+}//}}}
+
+void VimMainWindow::showTipOfTheDay()
+{
+#if QT_VERSION>=300
+    KTipDialog::showTip (vmw,QString::null,true);
+#endif
+}
+
+void VimMainWindow::buffersToolbar()
+{
+
+}
+
+void VimMainWindow::showBugReport()
+{
+    KBugReport *bug= new KBugReport(this,true);
+    bug->show();
+}
+/*
+ *   Vim Dialog
+ *
+ * Returns:
+ *  0: Cancel
+ *  1- : nb of the pressed button
+ */
+
+VimDialog::VimDialog (int type,		/* type of dialog *///{{{
+	char_u * title,		/* title of dialog */
+	char_u * message,	/* message text */
+	char_u * buttons,	/* names of buttons */
+	int def_but,		/* default button */
+	char_u *textfield )	/* input field */
+:QDialog(vmw, "vim generic dialog", true), // true is for "modal"
+    mapper(this, "dialog signal mapper")
+{
+    /*
+     * Create Icon
+     */
+    char ** icon_data;
+    switch (type)
+    {
+	case VIM_GENERIC:
+	    icon_data = generic_xpm;
+	    break;
+	case VIM_ERROR:
+	    icon_data = error_xpm;
+	    break;
+	case VIM_WARNING:
+	    icon_data = alert_xpm;
+	    break;
+	case VIM_INFO:
+	    icon_data = info_xpm;
+	    break;
+	case VIM_QUESTION:
+	    icon_data = quest_xpm;
+	    break;
+	default:
+	    icon_data = generic_xpm;
+    };
+    QLabel * icon = new QLabel( this );
+    icon->setPixmap( QPixmap( (const char **) icon_data ) );
+    icon->setFixedSize( icon->sizeHint() );
+
+    QLabel * text = new QLabel( (const char *)message, this );
+    text->setAlignment( AlignHCenter | AlignVCenter | ExpandTabs );
+
+    QStringList buttonText = QStringList::split( DLG_BUTTON_SEP, (char *) buttons);
+    int butNb = buttonText.count();
+
+    /*
+     *  Layout
+     */
+
+    QVBoxLayout * vly = new QVBoxLayout( this, 5, 5 );
+    QHBoxLayout * hly1 = new QHBoxLayout( vly, 5);
+    hly1->addWidget( icon );
+    hly1->addWidget( text );
+    QHBoxLayout * hly3 = new QHBoxLayout ( vly , 5);
+    if (textfield!=NULL)
+    {
+	entry = new QLineEdit((const char *)textfield,this);
+	entry->setText((const char *)textfield);
+	hly3->addWidget( entry );
+	ret=textfield;
+    }
+    else
+	entry=NULL;
+
+    QHBoxLayout * hly2 = new QHBoxLayout( vly, 15);
+    QString s;
+    QPushButton * pushButton = 0L;
+    for (int i=0; i<butNb; i++)
+    {
+	s = buttonText[i];
+	pushButton = new QPushButton(s, this );
+	if (s.find('&') != -1)
+	    pushButton->setAccel(s.at(s.find('&')+1).latin1());
+
+	hly2->addWidget( pushButton );
+	if (i == def_but-1)
+	{
+	    pushButton->setDefault( true );
+	    pushButton->setAutoDefault( true );
+	    setResult( i+1 );
+	}
+	connect(pushButton, SIGNAL(clicked()), &mapper, SLOT(map()));
+	mapper.setMapping(pushButton, i+1);
+    }
+    connect( &mapper, SIGNAL(mapped(int)), this, SLOT(done(int)));
+
+    setCaption((const char *) title);
+
+    vly->activate();
+}//}}}
+
+void VimDialog::done(int r)
+{
+    if (entry!=NULL)
+    {
+        if (r)
+	{
+	   QCString unistring=vmw->codec->fromUnicode(entry->text());
+	   STRCPY(ret,(const char*)unistring);
+	}
+	else
+	    *ret=NUL;
+    }
+    QDialog::done(r);
+}
+
+/*
+ * ScrollBar pool handling
+ */
+SBPool::SBPool(void)//{{{
+    :mapper(this, "SBPool signal mapper")
+{
+    connect(&mapper, SIGNAL(mapped(int)), this, SLOT(sbUsed(int)));
+}//}}}
+
+
+void SBPool::create(GuiScrollbar * sb, int orient)//{{{
+{
+    switch(orient)
+    {
+	case SBAR_HORIZ:
+	    sb->w = new QScrollBar(QScrollBar::Horizontal, vmw);
+	    break;
+	case SBAR_VERT:
+	    sb->w = new QScrollBar(QScrollBar::Vertical, vmw);
+	    break;
+	default:
+	    sb->w = 0;
+	    return;
+    }
+
+    connect(sb->w, SIGNAL(valueChanged(int)), &mapper, SLOT(map()));
+    mapper.setMapping(sb->w, (int)sb);
+}//}}}
+
+
+void SBPool::sbUsed(int who)//{{{
+{
+    GuiScrollbar *sb = (GuiScrollbar*)who;
+    gui_drag_scrollbar( sb, sb->w->value(), FALSE);
+}//}}}
+
+
+void SBPool::destroy(GuiScrollbar * sb)//{{{
+{
+    if (!sb->w) return;
+
+    delete sb->w;
+    sb->w = 0;
+}//}}}
+
+#ifdef FEAT_CLIENTSERVER
+static int kvim_x11_event_filter( XEvent* e)//{{{
+{
+    if (e->xproperty.type == PropertyNotify
+	    && e->xproperty.atom == commProperty
+	    && e->xproperty.window == commWindow
+	    && e->xproperty.state == PropertyNewValue)
+	serverEventProc(qt_xdisplay(), e);
+
+    if (oldFilter) return oldFilter( e );
+    return FALSE;
+}//}}}
+#endif
+
+//add some QT 3 fonts usefull functions
+#if QT_VERSION<300
+QString KVimUtils::toString(QFont *f)
+{
+    QStringList l;
+    l.append(f->family());
+    l.append(QString::number(f->pointSize()));
+    l.append(QString::number(f->pixelSize()));
+    l.append(QString::number((int)f->styleHint()));
+    l.append(QString::number(f->weight()));
+    l.append(QString::number((int)f->italic()));
+    l.append(QString::number((int)f->underline()));
+    l.append(QString::number((int)f->strikeOut()));
+    l.append(QString::number((int)f->fixedPitch()));
+    l.append(QString::number((int)f->rawMode()));
+    return l.join(",");
+}
+
+bool KVimUtils::fromString(QFont *f, QString descrip)
+{
+   QStringList l(QStringList::split(',', descrip));
+
+    int count = l.count();
+    if (count != 10 && count != 9)
+        return FALSE;
+
+    f->setFamily(l[0]);
+    f->setPointSize(l[1].toInt());
+    if ( count == 9 )
+    {
+	f->setStyleHint((QFont::StyleHint) l[2].toInt());
+	f->setWeight(l[3].toInt());
+	f->setItalic(l[4].toInt());
+	f->setUnderline(l[5].toInt());
+	f->setStrikeOut(l[6].toInt());
+	f->setFixedPitch(l[7].toInt());
+	f->setRawMode(l[8].toInt());
+    }
+    else
+    {
+	f->setPixelSize(l[2].toInt());
+	f->setStyleHint((QFont::StyleHint) l[3].toInt());
+	f->setWeight(l[4].toInt());
+	f->setItalic(l[5].toInt());
+	f->setUnderline(l[6].toInt());
+	f->setStrikeOut(l[7].toInt());
+	f->setFixedPitch(l[8].toInt());
+	f->setRawMode(l[9].toInt());
+    }
+    return TRUE;
+}
+#endif
+
+QString KVimUtils::convertEncodingName(QString name)
+{
+    if (name.startsWith("ucs") || name.startsWith("utf-16")) return QString("utf16");
+    if (name=="cp950") return QString("Big5");
+    return QString();
+}
new file mode 100644
--- /dev/null
+++ b/src/gui_kde_wid.h
@@ -0,0 +1,245 @@
+/* vi:set ts=8 sts=0 sw=8:
+ *
+ * VIM - Vi IMproved		by Bram Moolenaar
+ *
+ * Do ":help uganda"  in Vim to read copying and usage conditions.
+ * Do ":help credits" in Vim to see a list of people who contributed.
+ */
+
+/*
+ * Porting to KDE(2) was done by
+ *
+ *  (C) 2000 by Thomas Capricelli <orzel@freehackers.org>
+ *
+ *  Please visit http://freehackers.org/kvim for other vim- or
+ *  kde-related coding.
+ *
+ *  $Id$
+ *
+ */
+
+#ifndef GUI_KDE_WIDGET
+#define GUI_KDE_WIDGET
+
+#if 1
+#define dbf( format, args... ) { printf( "%s" " : " format "\n" , __FUNCTION__ , ## args ); fflush(stdout); }
+#define db()       { printf( "%s\n", __FUNCTION__ );fflush(stdout); }
+#else
+#define dbf(format, args... )
+#define db()
+#endif
+
+#define UNIX	    // prevent a warning : a symbol is defined twice in X and Qt
+
+#include <qdialog.h>
+#include <qlabel.h>
+#include <qsignalmapper.h>
+#include <qtimer.h>
+#include <qmainwindow.h>
+#include <qapplication.h>
+#include <qevent.h>
+#include <qlineedit.h>
+#include <qpainter.h>
+#include <qwidget.h>
+#include <qpopupmenu.h>
+#include <klocale.h>
+#include <kapp.h>
+#include <kcmdlineargs.h>
+#include <kaboutdata.h>
+#include <keditcl.h>
+#include <kaboutdata.h>
+#if (KDE_VERSION>=290)
+#include <kmainwindow.h>
+#else
+#include <ktmainwindow.h>
+#endif
+#include <kparts/part.h>
+#include <kurl.h>
+#include "kvim_iface.h"
+
+#undef UNIX	    // prevent a warning
+extern "C" {
+#include "vim.h"
+}
+
+class QPushButton;
+class QDialog;
+class QLineEdit;
+class QSignalMapper;
+class QPaintEvent;
+
+enum BlinkState {
+	BLINK_NONE,
+	BLINK_ON,
+	BLINK_OFF
+};
+
+class VimWidget : public QWidget, virtual public KVim
+{
+	Q_OBJECT
+
+public:
+	VimWidget( QWidget *parent=0, const char *name=0, WFlags f=0 );
+	virtual void paintEvent( QPaintEvent *);
+	void	draw_string(int x, int y, QString s, int len, int flags);
+
+	/** Init the blinking time */
+	void set_blink_time( long, long, long );
+	void start_cursor_blinking();
+	void stop_cursor_blinking();
+	void wait(long);
+#ifdef FEAT_CLIENTSERVER
+	void serverActivate(WId id);
+#endif
+#ifdef FEAT_MZSCHEME
+	void enable_mzscheme_threads();
+	void disable_mzscheme_threads();
+#endif
+	void flash();
+
+	/** DCOP */
+	void execNormal(QString command);
+	void execInsert(QString command);
+	void execRaw(QString command);
+	void execCmd(QString command);
+	QString eval(QString expr);
+
+	bool wait_done;
+	BlinkState blink_state;
+	QPainter *painter;
+	QPopupMenu *menu;
+
+protected:
+	virtual void keyPressEvent( QKeyEvent * );
+	virtual void mousePressEvent( QMouseEvent *);
+	virtual void mouseDoubleClickEvent( QMouseEvent *);
+	virtual void mouseReleaseEvent( QMouseEvent *);
+	virtual void mouseMoveEvent( QMouseEvent *);
+	virtual void focusInEvent( QFocusEvent * );
+	virtual void focusOutEvent( QFocusEvent * );
+	virtual void dragEnterEvent (QDragEnterEvent *);
+	virtual void dropEvent (QDropEvent *);
+#ifdef FEAT_XIM
+	virtual void imStartEvent ( QIMEvent * );
+	virtual void imEndEvent ( QIMEvent * );
+	virtual void imComposeEvent ( QIMEvent * );
+#endif
+#ifdef FEAT_MZSCHEME
+	virtual void timerEvent( QTimerEvent * );
+#endif
+
+	/* cursor blinking stuff */
+	QTimer blink_timer;
+	long blink_wait_time, blink_on_time, blink_off_time;
+
+	/* wait for input */
+	QTimer	wait_timer;
+
+#ifdef FEAT_MZSCHEME
+	int	mzscheme_timer_id;
+#endif
+
+public slots:
+	void    blink_cursor();
+	void	wait_timeout();
+};
+
+class VimMainWindow : public KMainWindow
+{
+	Q_OBJECT
+
+public:
+	VimMainWindow ( const char *name = 0L, WFlags f = WDestructiveClose );
+
+	/** called when the widget closes */
+//	bool close(bool alsoDelete);
+	VimWidget	*w;
+        KEdFind         *finddlg;
+        KEdReplace      *repldlg;
+	int		have_tearoff;
+	QTextCodec      *codec;
+
+public slots:
+	void    menu_activated(int dx);
+	void 	clipboard_selection_update();
+	void 	clipboard_data_update();
+        void    slotSearch();
+        void    slotFind();
+        void    slotReplace();
+        void    slotReplaceAll();
+	void    showAboutApplication();
+	void    showAboutKDE();
+	void    showBugReport();
+	void    showTipOfTheDay();
+	void    buffersToolbar();
+	bool    isLocked();
+	void    lock();
+	void    unlock();
+
+protected:
+	virtual void wheelEvent (QWheelEvent *);
+	virtual void resizeEvent ( QResizeEvent *e );
+
+#if defined(FEAT_SESSION)
+	void saveGlobalProperties (KConfig *conf);
+	void readGlobalProperties (KConfig *conf);
+#endif
+	bool queryClose();
+	bool queryExit();
+	bool locked;
+};
+
+
+class VimDialog : public QDialog
+{
+	Q_OBJECT
+public:
+	VimDialog (int type,		/* type of dialog */
+	       unsigned char * title,		/* title of dialog */
+	       unsigned char * message,	/* message text */
+	       unsigned char * buttons,	/* names of buttons */
+	       int def_but,		/* default button */
+	       char_u *textfield);		/* input text */
+private:
+	QSignalMapper	mapper;
+	QLineEdit	*entry;
+	char_u		*ret;
+	int		butNb;
+
+protected slots:
+	void done(int);
+};
+
+
+/*
+ * QScrollBar  pool
+ */
+struct GuiScrollbar;
+
+class SBPool : public QObject
+{
+	Q_OBJECT
+public:
+	SBPool(void);
+	void create(GuiScrollbar * sb, int orient);
+	void destroy(GuiScrollbar * sb);
+public slots:
+	void sbUsed(int who);
+private:
+	QSignalMapper mapper;
+};
+
+class KVimUtils {
+public:
+	static QString convertEncodingName(QString);
+#if QT_VERSION<300
+	static bool fromString(QFont*,QString);
+	static QString toString(QFont*);
+#endif
+};
+
+extern VimMainWindow	*vmw;
+extern SBPool		*sbpool;
+extern QString          *argServerName;
+
+#endif // GUI_KDE_WIDGET
deleted file mode 100644
--- a/src/gui_kde_widget.cc
+++ /dev/null
@@ -1,1417 +0,0 @@
-/* vi:set ts=8 sts=4 sw=4:
- *
- * VIM - Vi IMproved		by Bram Moolenaar
- *
- * Do ":help uganda"  in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
-
-/*
- * Porting to KDE(2) was done by
- *
- *  (C) 2000 by Thomas Capricelli <orzel@freehackers.org>
- *
- *  Please visit http://freehackers.org/kvim for other vim- or
- *  kde-related coding.
- *
- *  $Id$
- *
- */
-
-#include <assert.h>
-#include <qpainter.h>
-#include <qevent.h>
-#include <qpushbutton.h>
-#include <qscrollbar.h>
-#include <qlayout.h>
-#include <qclipboard.h>
-#include <qdragobject.h>
-#include <qstrlist.h>
-#include <qmenubar.h>
-#include <qtextcodec.h>
-#if QT_VERSION>=300
-#include <qptrlist.h>
-#include <ktip.h>
-#endif
-#include <kglobal.h>
-#include <kconfig.h>
-#include <kaboutapplication.h>
-#include <dcopclient.h>
-#include <kaboutkde.h>
-#include <kbugreport.h>
-#include <kurldrag.h>
-#include <kmenubar.h>
-#include <ktoolbar.h>
-#include <kstandarddirs.h>
-#include "gui_kde_widget.h"
-#include <qxembed.h>
-
-extern "C" {
-#include "version.h"
-}
-
-// Pixmap for dialog
-#ifdef FEAT_GUI_DIALOG
-# include "../../pixmaps/alert.xpm"
-# include "../../pixmaps/error.xpm"
-# include "../../pixmaps/generic.xpm"
-# include "../../pixmaps/info.xpm"
-# include "../../pixmaps/quest.xpm"
-#endif
-
-/**
- * Keycodes recognized by vim.
- */
-struct special_key {//{{{
-    int qtkey;
-    char_u code0;
-    char_u code1;
-} special_keys[] =
-{
-    { Qt::Key_Up,		'k', 'u' },
-    { Qt::Key_Down,		'k', 'd' },
-    { Qt::Key_Left,		'k', 'l' },
-    { Qt::Key_Right,		'k', 'r' },
-    { Qt::Key_F1,		'k', '1' },
-    { Qt::Key_F2,		'k', '2' },
-    { Qt::Key_F3,		'k', '3' },
-    { Qt::Key_F4,		'k', '4' },
-    { Qt::Key_F5,		'k', '5' },
-    { Qt::Key_F6,		'k', '6' },
-    { Qt::Key_F7,		'k', '7' },
-    { Qt::Key_F8,		'k', '8' },
-    { Qt::Key_F9,		'k', '9' },
-    { Qt::Key_F10,		'k', ';' },
-    { Qt::Key_F11,		'F', '1' },
-    { Qt::Key_F12,		'F', '2' },
-    { Qt::Key_F13,		'F', '3' },
-    { Qt::Key_F14,		'F', '4' },
-    { Qt::Key_F15,		'F', '5' },
-    { Qt::Key_F16,		'F', '6' },
-    { Qt::Key_F17,		'F', '7' },
-    { Qt::Key_F18,		'F', '8' },
-    { Qt::Key_F19,		'F', '9' },
-    { Qt::Key_F20,		'F', 'A' },
-    { Qt::Key_F21,		'F', 'B' },
-    { Qt::Key_F22,		'F', 'C' },
-    { Qt::Key_F23,		'F', 'D' },
-    { Qt::Key_F24,		'F', 'E' },
-    { Qt::Key_F25,		'F', 'F' },
-    { Qt::Key_F26,		'F', 'G' },
-    { Qt::Key_F27,		'F', 'H' },
-    { Qt::Key_F28,		'F', 'I' },
-    { Qt::Key_F29,		'F', 'J' },
-    { Qt::Key_F30,		'F', 'K' },
-    { Qt::Key_F31,		'F', 'L' },
-    { Qt::Key_F32,		'F', 'M' },
-    { Qt::Key_F33,		'F', 'N' },
-    { Qt::Key_F34,		'F', 'O' },
-    { Qt::Key_F35,		'F', 'P' },
-    { Qt::Key_Help,		'%', '1' },
-    //    { Qt::Key_Undo,		'&', '8' }, <= hmmm ?
-    { Qt::Key_BackSpace,	'k', 'b' },
-    { Qt::Key_Insert,		KS_EXTRA, KE_KINS },
-    { Qt::Key_Delete,		KS_EXTRA, KE_KDEL },
-    { Qt::Key_Home,		'K', '1' },
-    { Qt::Key_End,		'K', '4' },
-    { Qt::Key_Prior,		'K', '3' },
-    { Qt::Key_Next,		'K', '5' },
-    { Qt::Key_Print,		'%', '9' },
-
-    { Qt::Key_Plus,	'K', '6'},
-    { Qt::Key_Minus,	'K', '7'},
-    { Qt::Key_Slash,	'K', '8'},
-    { Qt::Key_multiply,	'K', '9'},
-    { Qt::Key_Enter,	'K', 'A'},
-    { Qt::Key_Period,	'K', 'B'},
-
-    { Qt::Key_0,	'K', 'C'},
-    { Qt::Key_1,	'K', 'D'},
-    { Qt::Key_2,	'K', 'E'},
-    { Qt::Key_3,	'K', 'F'},
-    { Qt::Key_4,	'K', 'G'},
-    { Qt::Key_5,	'K', 'H'},
-    { Qt::Key_6,	'K', 'I'},
-    { Qt::Key_7,	'K', 'J'},
-    { Qt::Key_8,	'K', 'K'},
-    { Qt::Key_9,	'K', 'L'},
-    /* End of list marker: */
-    { 0, 0, 0 }
-};//}}}
-
-#ifdef FEAT_CLIENTSERVER
-typedef int (*QX11EventFilter) (XEvent*);
-extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter);
-static QX11EventFilter oldFilter = 0;
-static int kvim_x11_event_filter( XEvent* e);
-#endif
-void gui_keypress(QKeyEvent *e);
-
-/*
- * Return OK if the key with the termcap name "name" is supported.
- */
-    int
-gui_mch_haskey(char_u * name)//{{{
-{
-    for (int i=0; special_keys[i].qtkey != 0; i++)
-	if (name[0] == special_keys[i].code0 &&
-		name[1] == special_keys[i].code1)
-	    return OK;
-    return FAIL;
-}//}}}
-
-/*
- * custom Frame for drawing ...
- */
-void VimWidget::paintEvent( QPaintEvent *e)//{{{
-{
-    QRect r = e->rect();
-    gui_redraw(r.x(), r.y(), r.width(), r.height() );
-}//}}}
-
-void VimWidget::draw_string(int x, int y, QString s, int len, int flags)//{{{
-{
-    gui.current_font->setBold( flags & DRAW_BOLD );
-    gui.current_font->setUnderline( flags & DRAW_UNDERL );
-    gui.current_font->setItalic(flags & DRAW_ITALIC);
-    painter->setBackgroundMode( flags & DRAW_TRANSP ? Qt::TransparentMode : Qt::OpaqueMode);
-    painter->setFont( *(gui.current_font) );
-    painter->drawText( x, y, s, len);
-}//}}}
-
-void VimWidget::mousePressEvent(QMouseEvent *event)//{{{
-{
-    int button=0;
-    int modifiers=0;
-    ButtonState state = event->state();
-    ButtonState buttons = event->button();
-
-    //Look at button states
-    if(buttons & QMouseEvent::LeftButton) {
-	button|=MOUSE_LEFT;
-    }
-    if(buttons & QMouseEvent::RightButton) {
-	button|=MOUSE_RIGHT;
-    }
-    if(buttons & QMouseEvent::MidButton) {
-	button|=MOUSE_MIDDLE;
-    }
-    //Look for keyboard modifiers
-    if(state & QMouseEvent::ShiftButton) {
-	modifiers|=MOUSE_SHIFT;
-    }
-    if(state & QMouseEvent::ControlButton){
-	modifiers|=MOUSE_CTRL;
-    }
-    if(state & QMouseEvent::AltButton){
-	modifiers|=MOUSE_ALT;
-    }
-    gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers);
-#if QT_VERSION>=300
-    QByteArray params;
-    QDataStream stream(params, IO_WriteOnly);
-    stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col;
-    kapp->dcopClient()->emitDCOPSignal("mousePEvent(QCString,int,int,int,int)", params);
-#endif
-    event->accept();
-}//}}}
-
-#if defined(FEAT_SESSION)
-void VimMainWindow::saveGlobalProperties (KConfig *conf)
-{
-    //we write a mksession file to a file written in the user's ~/.kde/share/config/
-    //the name of the file in saved in 'conf'
-    //when restoring app, we source this file
-#if 0 //disabled for release
-    QString filename = KGlobal::dirs()->localkdedir() + KGlobal::dirs()->kde_default("config") + kapp->randomString(10);
-    QString cmd("mksession ");
-    cmd+=filename;
-    do_cmdline_cmd((char_u*)cmd.latin1());
-    conf->writePathEntry("sessionfile", filename);
-    conf->sync();
-#endif
-}
-
-void VimMainWindow::readGlobalProperties (KConfig *conf)
-{
-#if 0
-    QString filename = conf->readPathEntry("sessionfile");
-    if (filename.isNull()) return;
-    QString cmd("source ");
-    cmd+=filename;
-    do_cmdline_cmd((char_u*)cmd.latin1());
-#endif
-}
-#endif
-
-void VimMainWindow::wheelEvent (QWheelEvent *event)//{{{
-{
-    ButtonState state = event->state();
-    int button=0;
-    int modifiers=0;
-
-    if (event->delta()>0)
-	button|=MOUSE_4;
-    else button|=MOUSE_5;
-
-    if(state & ShiftButton)
-	modifiers|=MOUSE_SHIFT;
-    if(state & ControlButton)
-	modifiers|=MOUSE_CTRL;
-    if(state & AltButton)
-	modifiers|=MOUSE_ALT;
-
-    gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers);
-#if QT_VERSION>=300
-    QByteArray params;
-    QDataStream stream(params, IO_WriteOnly);
-    stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col;
-    kapp->dcopClient()->emitDCOPSignal("mouseWhlEvent(QCString, int, int,int,int)", params);
-#endif
-    event->accept();
-}//}}}
-
-void VimWidget::mouseDoubleClickEvent(QMouseEvent *event)//{{{
-{
-    ButtonState state = event->state();
-    ButtonState buttons = event->button();
-    int modifiers=0;
-    int button=0;
-
-    //Look at button states
-    if(buttons & LeftButton)
-	button|=MOUSE_LEFT;
-    if(buttons & RightButton)
-	button|=MOUSE_RIGHT;
-    if(buttons & MidButton)
-	button|=MOUSE_MIDDLE;
-
-    //Look for keyboard modifiers
-    if(state & ShiftButton)
-	modifiers|=MOUSE_SHIFT;
-    if(state & ControlButton)
-	modifiers|=MOUSE_CTRL;
-    if(state & AltButton)
-	modifiers|=MOUSE_ALT;
-
-    gui_send_mouse_event(button,event->x(),event->y(),TRUE,modifiers);
-#if QT_VERSION>=300
-    QByteArray params;
-    QDataStream stream(params, IO_WriteOnly);
-    stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col;
-    kapp->dcopClient()->emitDCOPSignal("mouseDblClickEvent(QCString, int, int,int,int)", params);
-#endif
-    event->accept();
-}//}}}
-
-void VimWidget::mouseMoveEvent(QMouseEvent *event){//{{{
-    ButtonState state = event->state();
-    int modifiers=0;
-    int button=0;
-
-    gui_mch_mousehide(FALSE);
-
-    //Look at button states
-    //warning: we use state here, this is important !
-    if(state & QMouseEvent::LeftButton || state & QMouseEvent::RightButton || state & QMouseEvent::MidButton)
-	button|=MOUSE_DRAG;
-
-    //Look for keyboard modifiers
-    if(state & ShiftButton)
-	modifiers|=MOUSE_SHIFT;
-    if(state & ControlButton)
-	modifiers|=MOUSE_CTRL;
-    if(state & AltButton)
-	modifiers|=MOUSE_ALT;
-    if (button!=MOUSE_DRAG)
-	gui_mouse_moved(event->x(),event->y());
-    else
-	gui_send_mouse_event(MOUSE_DRAG,event->x(),event->y(),FALSE,modifiers);
-}//}}}
-
-void VimWidget::mouseReleaseEvent(QMouseEvent *event)//{{{
-{
-    ButtonState state = event->state();
-    int modifiers=0;
-
-    //Look for keyboard modifiers
-    if(state & ShiftButton)
-	modifiers|=MOUSE_SHIFT;
-    if(state & ControlButton)
-	modifiers|=MOUSE_CTRL;
-    if(state & AltButton)
-	modifiers|=MOUSE_ALT;
-
-    gui_send_mouse_event(MOUSE_RELEASE,event->x(),event->y(),FALSE,modifiers);
-    event->accept();
-}//}}}
-
-/*
- *  The main widget (everything but toolbar/menubar)
- */
-    VimWidget::VimWidget( QWidget *parent, const char *name, WFlags f )//{{{
-:QWidget(parent, name, f)
-    ,DCOPObject("KVim")
-#ifdef FEAT_MZSCHEME
-    ,mzscheme_timer_id(-1)
-#endif
-{
-    //to be able to show/hide the cursor when moving the mouse
-    setMouseTracking(true);
-    painter=new QPainter(this);
-
-    setKeyCompression(true);
-    setFocusPolicy( QWidget::StrongFocus );
-    setAcceptDrops(TRUE); // DND
-    blink_state = BLINK_NONE;
-    blink_on_time = 700;
-    blink_off_time = 400;
-    blink_wait_time = 250;
-    connect( &blink_timer, SIGNAL( timeout() ), SLOT( blink_cursor() ));
-    connect( &wait_timer, SIGNAL( timeout() ), SLOT ( wait_timeout() ));
-}//}}}
-
-void VimWidget::execNormal(QString command)//{{{
-{
-    QString cmd("execute 'normal ");
-    cmd+=command;
-    cmd+="'";
-    QCString unistring = vmw->codec->fromUnicode(cmd);
-    do_cmdline_cmd((char_u *)(const char*)unistring);
-    gui_update_screen();
-}//}}}
-
-void VimWidget::execInsert(QString command)//{{{
-{
-    QString cmd("execute 'normal i");
-    cmd+=command;
-    cmd+="'";
-    QCString unistring = vmw->codec->fromUnicode(cmd);
-    do_cmdline_cmd((char_u *)(const char*)unistring);
-    gui_update_screen();
-}//}}}
-
-void VimWidget::execRaw(QString command)//{{{
-{
-    QString cmd("execute '");
-    cmd+=command;
-    cmd+="'";
-    QCString unistring = vmw->codec->fromUnicode(cmd);
-    do_cmdline_cmd((char_u *)(const char*)unistring);
-    gui_update_screen();
-}//}}}
-
-void VimWidget::execCmd(QString command)//{{{
-{
-    QCString unistring = vmw->codec->fromUnicode(command);
-    do_cmdline_cmd((char_u *)(const char*)unistring);
-    gui_update_screen();
-}//}}}
-
-QString VimWidget::eval(QString expr)//{{{
-{
-#ifdef FEAT_EVAL
-    QCString unistring = vmw->codec->fromUnicode(expr);
-    QString val((const char *)eval_to_string((char_u *)(const char*)unistring,NULL));
-    return val;
-#else
-    return QString::null;
-#endif
-}//}}}
-
-void VimWidget::wait(long wtime)//{{{
-{
-    if ( wait_timer.isActive() ) wait_timer.stop();
-    wait_done = false;
-    wait_timer.start( wtime, true);
-}//}}}
-
-void VimWidget::wait_timeout() //{{{
-{
-    wait_done = true;
-}//}}}
-
-void VimWidget::dragEnterEvent (QDragEnterEvent *e)//{{{
-{
-#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO)
-    e->accept(QUriDrag::canDecode(e));
-#else
-    e->ignore();
-#endif
-}//}}}
-
-void VimWidget::dropEvent (QDropEvent *e) // {{{
-{
-#if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO)
-    QStrList  urls;
-
-    char_u	**fnames;
-    int		redo_dirs = FALSE;
-    int		i;
-    int		n;
-    int		nfiles;
-    int		url = FALSE;
-
-    /* Count how many items there may be and normalize delimiters. */
-
-    if (QUriDrag::decode(e, urls)) {
-	n = urls.count();
-        fnames = (char_u **)lalloc((n+1) * sizeof(char_u *), TRUE);
-	nfiles = 0;
-#if QT_VERSION>=300
-	QPtrListIterator<char> it(urls);
-	for( ; it.current(); ++it ) {
-	    KURL u(*it);
-#else
-	    for (i=0;i<urls.count();++i) {
-		KURL u(urls.at(i));
-#endif
-		if ( !u.isLocalFile() )
-		    url = TRUE;
-		else {
-		    fnames[nfiles] = (char_u *)strdup((const char *)u.path());
-		    ++nfiles;
-		}
-	    }
-	    /* Real files (i.e. not http and not ftp) */
-	    if (url == FALSE)
-	    {
-		if (nfiles == 1)
-		{
-		    if (mch_isdir(fnames[0]))
-		    {
-			/* Handle dropping a directory on Vim. */
-			if (mch_chdir((char *)fnames[0]) == 0)
-			{
-			    free(fnames[0]);
-			    fnames[0] = NULL;
-			    redo_dirs = TRUE;
-			}
-		    }
-		} else {
-		    /* Ignore any directories */
-		    for (i = 0; i < nfiles; ++i)
-		    {
-			if (mch_isdir(fnames[i]))
-			{
-			    vim_free(fnames[i]);
-			    fnames[i] = NULL;
-			}
-		    }
-		}
-
-		if (0)
-		{
-		    /* Shift held down, change to first file's directory */
-		    if (fnames[0] != NULL && vim_chdirfile(fnames[0]) == OK)
-			redo_dirs = TRUE;
-		} else {
-		    char_u	dirname[MAXPATHL];
-		    char_u	*s;
-		    if (mch_dirname(dirname, MAXPATHL) == OK)
-			for (i = 0; i < nfiles; ++i)
-			    if (fnames[i] != NULL)
-			    {
-				s = shorten_fname(fnames[i], dirname);
-				if (s != NULL && (s = vim_strsave(s)) != NULL)
-				{
-				    vim_free(fnames[i]);
-				    fnames[i] = s;
-				}
-			    }
-		}
-	    }
-
-	    /* Handle the drop, :edit or :split to get to the file */
-	    handle_drop(nfiles, fnames, FALSE);
-
-	    if (redo_dirs)
-		shorten_fnames(TRUE);
-	}
-
-	/* Update the screen display */
-	update_screen(NOT_VALID);
-#ifdef FEAT_MENU
-	gui_update_menus(0);
-#endif
-	setcursor();
-	out_flush();
-	gui_update_cursor(FALSE, FALSE);
-	gui_mch_flush();
-#endif
-} // }}}
-
-void VimWidget::keyPressEvent( QKeyEvent *e ) // {{{
-{
-    gui_keypress(e);
-} // }}}
-
-void gui_keypress(QKeyEvent *e) { // {{{
-    int key = (int)e->key();
-    int modifiers = 0,i;
-    uchar string[256],string2[256];
-    uchar *s,*d;
-    Qt::ButtonState state = e->state();
-
-    QCString unistring = vmw->codec->fromUnicode(e->text());
-    if (unistring.length()>0)
-	strncpy((char*)string, (const char*)unistring,unistring.length());
-    string[unistring.length()] = 0;
-    int len=unistring.length();
-
-    // ignore certain keys
-    if (key == Qt::Key_Shift || key == Qt::Key_Alt || key == Qt::Key_Control || key == Qt::Key_Meta
-	    || key == Qt::Key_CapsLock || key == Qt::Key_NumLock || key == Qt::Key_ScrollLock ) {
-	e->ignore();
-	return;
-    }
-
-#ifdef FEAT_MBYTE
-    if (input_conv.vc_type != CONV_NONE)
-    {
-	mch_memmove(string2, string, len);
-	len = convert_input(string2, len, sizeof(string2));
-	s = string2;
-    }
-    else
-#endif
-	s = string;
-    d = string;
-    for (i = 0; i < len; ++i)
-    {
-	*d++ = s[i];
-	if (d[-1] == CSI && d + 2 < string + sizeof(string))
-	{
-	    /* Turn CSI into K_CSI. */
-	    *d++ = KS_EXTRA;
-	    *d++ = (int)KE_CSI;
-	}
-    }
-    len = d - string;
-
-
-    // change shift-tab (backtab) into S_TAB
-    if ( key == Qt::Key_BackTab && state & Qt::ShiftButton) {
-	key = Qt::Key_Tab;
-    }
-
-    // Change C-@ and C-2 in NUL ? Gtk does this
-    if ( (key == Qt::Key_2 || key == Qt::Key_At)
-	    && state & Qt::ControlButton ) {
-	string[0] = NUL;
-	len = 1;
-    }
-    else if (len == 0 && (key == Qt::Key_Space || key == Qt::Key_Tab))
-    {
-	/* When there are modifiers, these keys get zero length; we need the
-	 * original key here to be able to add a modifier below. */
-	string[0] = (key & 0xff);
-	len = 1;
-    }
-    /* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character
-     * that already has the 8th bit set.
-     * Don't do this for <S-M-Tab>, that should become K_S_TAB with ALT. */
-    if (len == 1
-	    && (key != Qt::Key_BackSpace && key != Qt::Key_Delete)
-	    && (string[0] & 0x80) == 0
-	    && (state & Qt::AltButton)
-	    && !(key == Qt::Key_Tab && (state & Qt::ShiftButton)))
-    {
-	string[0] |= 0x80;
-#ifdef FEAT_MBYTE
-	if (enc_utf8) // convert to utf-8
-	{
-	    string[1] = string[0] & 0xbf;
-	    string[0] = ((unsigned)string[0] >> 6) + 0xc0;
-	    if (string[1] == CSI)
-	    {
-		string[2] = KS_EXTRA;
-		string[3] = (int)KE_CSI;
-		len = 4;
-	    }
-	    else
-		len = 2;
-	}
-#endif
-    }
-
-    /* Check for special keys, making sure BS and DEL are recognised. */
-    if (len == 0 || key == Qt::Key_BackSpace || key == Qt::Key_Delete)
-    {
-	while (special_keys[i].qtkey != 0 && special_keys[i].qtkey != key ) i++;
-	if (special_keys[i].qtkey != 0) {
-		string[0] = CSI;
-		string[1] = special_keys[i].code0;
-		string[2] = special_keys[i].code1;
-		len = -3;
-	}
-/*
-	for (i = 0; special_keys[i].qtkey != 0 ; i++)
-	{
-	    if (special_keys[i].qtkey == key ) {
-		string[0] = CSI;
-		string[1] = special_keys[i].code0;
-		string[2] = special_keys[i].code1;
-		len = -3;
-		break;
-	    }
-	}*/
-    }
-
-    if (len == 0)   {
-	//no need to dump that, that's a QT problem, we can't do anything
-	//dbf("Unrecognised Key : %X %s", key, e->text().latin1());
-	e->ignore();
-	return;
-    }
-
-
-    /* Special keys (and a few others) may have modifiers */
-    if (len == -3 || key == Qt::Key_Space || key == Qt::Key_Tab ||
-	    key == Qt::Key_Return || key == Qt::Key_Enter ||
-	    key == Qt::Key_Escape) {
-
-	modifiers = 0;
-	if (state & Qt::ShiftButton) modifiers |= MOD_MASK_SHIFT;
-	if (state & Qt::ControlButton) modifiers |= MOD_MASK_CTRL;
-	if (state & Qt::AltButton) modifiers |= MOD_MASK_ALT;
-
-	/*
-	 * For some keys a shift modifier is translated into another key
-	 * code. Do we need to handle the case where len != 1 and
-	 * string[0] != CSI?
-	 */
-	if (len == -3)
-	    key = TO_SPECIAL(string[1], string[2]);
-	else
-	    key = string[0];
-
-	key = simplify_key(key, &modifiers);
-	if (key == CSI) key=K_CSI;
-
-	if (IS_SPECIAL(key)) {
-	    string[0] = CSI;
-	    string[1] = K_SECOND(key);
-	    string[2] = K_THIRD(key);
-	    len = 3;
-	} else {
-	    string[0] = key;
-	    len = 1;
-	}
-
-
-	if (modifiers!=0) {
-	    uchar string2[10];
-	    string2[0] = CSI;
-	    string2[1] = KS_MODIFIER;
-	    string2[2] = modifiers;
-	    add_to_input_buf(string2, 3);
-	}
-
-    } /* special keys */
-
-    if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
-		|| (string[0] == intr_char && intr_char != Ctrl_C)))
-    {
-	trash_input_buf();
-	got_int = TRUE;
-    }
-
-    add_to_input_buf(string, len);
-    if (p_mh) {
-	gui_mch_mousehide(TRUE);
-    }
-    //DCOP Embedding stuff
-    //if we are here then the user has type something in the window, thus we can easily imagine that :
-    // 1 - text has changed (emit textChanged())
-    // 2 - characters were interactively inserted (emit charactersInteractivelyInserted())
-    // 3 - cursor position has changed ( emit cursorPositionChanged() )
-    // 4 - selection has changed ? dunno yet //XXX
-    // 5 - undo changed too ? (each character typed in makes the undo changes anyway)
-    // conclusion : this makes a lot of things to send to the vim kpart, maybe too much
-    // for now i'll just send : keyboardEvent to the kpart with the event string as parameter,
-    // with current current position
-    // i'll do the same for mouseEvents
-#if QT_VERSION>=300
-    QByteArray params;
-    QDataStream stream(params, IO_WriteOnly);
-    stream << kapp->dcopClient()->appId() << unistring << gui.row << gui.col;
-    kapp->dcopClient()->emitDCOPSignal("keyboardEvent(QCString, QCString,int,int)", params);
-#endif
-    e->ignore();
-} // }}}
-
-#ifdef FEAT_CLIENTSERVER
-void VimWidget::serverActivate(WId id) //{{{
-{
-    if (serverName == NULL && serverDelayedStartName != NULL) {
-	commWindow = id;
-	(void)serverRegisterName(qt_xdisplay(), serverDelayedStartName);
-    } else {
-	serverChangeRegisteredWindow( qt_xdisplay(), id );
-    }
-}//}}}
-#endif
-
-#ifdef FEAT_XIM
-void VimWidget::imStartEvent(QIMEvent *e) {
-    e->accept();
-}
-
-void VimWidget::imEndEvent(QIMEvent *e) {
-    uchar string[256];
-
-    QCString unistring = vmw->codec->fromUnicode(e->text());
-    if (unistring.length()>0)
-	strncpy((char*)string, (const char*)unistring,unistring.length());
-    string[unistring.length()] = 0;
-    int len=unistring.length();
-
-    add_to_input_buf(string, len);
-    e->accept();
-}
-
-void VimWidget::imComposeEvent(QIMEvent *e) {
-    //i should do something here, displaying the text somewhere ... (status area ?)
-    e->accept();
-}
-#endif
-
-
-void VimMainWindow::lock()
-{
-    locked=true;
-}
-
-void VimMainWindow::unlock()
-{
-    locked=false;
-}
-
-bool VimMainWindow::isLocked()
-{
-    return locked;
-}
-
-// ->resize VimWidget if not locked
-//
-void VimMainWindow::resizeEvent ( QResizeEvent *e ) //{{{
-{
-    if ( vmw->isLocked() ) return;
-    //remove toolbar and menubar height
-    int height = e->size().height();
-    int width = e->size().width();
-
-    if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
-#if QT_VERSION>=300
-	    && !vmw->menuBar()->isTopLevelMenu()
-#endif
-	    )
-	height -= vmw->menuBar()->height();
-#ifdef FEAT_TOOLBAR
-    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-	    (vmw->toolBar()->barPos()==KToolBar::Top ||
-	     vmw->toolBar()->barPos()==KToolBar::Bottom))
-	height -= vmw->toolBar()->height();
-
-    if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
-	    (vmw->toolBar()->barPos()==KToolBar::Left ||
-	     vmw->toolBar()->barPos()==KToolBar::Right))
-	width -= vmw->toolBar()->width();
-#endif
-    height = ( ((int)(height/gui.char_height))*gui.char_height );
-    if (!vmw->isLocked()) gui_resize_shell(width,height);
-}//}}}
-
-void VimWidget::focusInEvent( QFocusEvent * fe ) // {{{
-{
-    gui_focus_change(true);
-
-    if (blink_state == BLINK_NONE)
-	gui_mch_start_blink();
-} // }}}
-
-void VimWidget::focusOutEvent( QFocusEvent * fe )//{{{
-{
-    gui_focus_change(false);
-
-    if (blink_state != BLINK_NONE)
-	gui_mch_stop_blink();
-}//}}}
-
-void VimWidget::set_blink_time( long wait, long on, long off)//{{{
-{
-    blink_wait_time = wait;
-    blink_on_time = on;
-    blink_off_time = off;
-}//}}}
-
-void VimWidget::start_cursor_blinking()//{{{
-{
-    if (blink_timer.isActive()) blink_timer.stop();
-
-    /* Only switch blinking on if none of the times is zero */
-    if (blink_wait_time && blink_on_time && blink_off_time && gui.in_focus) {
-	blink_state = BLINK_ON;
-	gui_update_cursor(TRUE, FALSE);
-	// The first blink appears after wait_time
-	blink_timer.start( blink_wait_time, true);
-    }
-}//}}}
-
-void VimWidget::blink_cursor()//{{{
-{
-    if (blink_state == BLINK_ON) {
-	// set cursor off
-	gui_undraw_cursor();
-	blink_state = BLINK_OFF;
-	blink_timer.start( blink_off_time, true);
-    } else {
-	// set cursor on
-	gui_update_cursor(TRUE, FALSE);
-	blink_state = BLINK_ON;
-	blink_timer.start( blink_on_time, true);
-    }
-}//}}}
-
-void VimWidget::stop_cursor_blinking()//{{{
-{
-    if (blink_timer.isActive()) blink_timer.stop();
-
-    if (blink_state == BLINK_OFF)
-	gui_update_cursor(TRUE, FALSE);
-
-    blink_state = BLINK_NONE;
-}//}}}
-
-#ifdef FEAT_MZSCHEME
-void VimWidget::timerEvent( QTimerEvent * evnt)//{{{
-{
-    if (evnt->timerId() == mzscheme_timer_id)
-	timer_proc();
-}//}}}
-
-void VimWidget::enable_mzscheme_threads()//{{{
-{
-    mzscheme_timer_id = startTimer(p_mzq);
-}//}}}
-
-void VimWidget::disable_mzscheme_threads()//{{{
-{
-    killTimer(mzscheme_timer_id);
-}//}}}
-#endif
-
-void VimWidget::flash()//{{{
-{
-    QPainter p(this);
-
-    p.setRasterOp(Qt::XorROP);
-    p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF));
-    p.flush();
-    //FIXME: Make this a little smarter. Maybe add a timer or something
-    usleep(19000);
-    p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF));
-    p.flush();
-    p.end();
-}//}}}
-
-
-/*
- *  The main Window
- */
-    VimMainWindow::VimMainWindow ( const char *name , WFlags f)//{{{
-:KMainWindow(0L, name,f)
-{
-#ifdef FEAT_CLIENTSERVER
-    oldFilter = qt_set_x11_event_filter( kvim_x11_event_filter );
-#endif
-    if (echo_wid_arg== 1) {
-	fprintf(stderr, "WID: %ld\n", (long)winId());
-	fflush(stderr);
-    }
-
-    w = new VimWidget(this, "main vim widget");
-    gui.w = w;
-    setFocusProxy(w);
-    w->setFocus();
-    have_tearoff=0;
-
-    finddlg=new KEdFind (this,0,false);
-    repldlg=new KEdReplace (this,0,false);
-    QObject::connect( finddlg, SIGNAL(search()), this, SLOT(slotSearch()) );
-    QObject::connect( repldlg, SIGNAL(find()), this, SLOT(slotFind()) );
-    QObject::connect( repldlg, SIGNAL(replace()), this, SLOT(slotReplace()) );
-    QObject::connect( repldlg, SIGNAL(replaceAll()), this, SLOT(slotReplaceAll()) );
-
-#ifdef FEAT_TOOLBAR
-    connect(toolBar(), SIGNAL(clicked(int)), this, SLOT(menu_activated(int)));
-#endif
-#ifdef FEAT_CLIENTSERVER
-    w->serverActivate(winId());
-
-    if (serverName!=NULL)
-        kapp->dcopClient()->registerAs(QCString((const char*)serverName),false);
-    else if (serverDelayedStartName!=NULL)
-        kapp->dcopClient()->registerAs(QCString((const char*)serverDelayedStartName),false);
-    else if (argServerName!=NULL)
-        kapp->dcopClient()->registerAs(argServerName->utf8(),false);
-#else
-    if (argServerName!=NULL)
-        kapp->dcopClient()->registerAs(argServerName->utf8(),false);
-#endif
-    QXEmbed::initialize();
-
-}//{{{
-
-bool VimMainWindow::queryClose()//{{{
-{
-    gui_shell_closed();
-    return true;
-}//}}}
-
-bool VimMainWindow::queryExit()//{{{
-{
-    return true;
-}//}}}
-
-void VimMainWindow::menu_activated(int dx)//{{{
-{
-#ifdef FEAT_MENU
-    if (!dx) {	// tearoff
-	return;
-    }
-    gui_mch_set_foreground();
-    gui_menu_cb((VimMenu *) dx);
-#endif
-}//}}}
-
-
-void VimMainWindow::clipboard_selection_update(){//{{{
-    if(kapp->clipboard()->ownsSelection()) {
-	clip_own_selection(&clip_star);
-    } else {
-	clip_lose_selection(&clip_star);
-    }
-}//}}}
-
-void VimMainWindow::clipboard_data_update(){//{{{
-#if QT_VERSION>=300
-    if (kapp->clipboard()->ownsClipboard()) {
-	clip_own_selection(&clip_plus);
-    } else {
-	clip_lose_selection(&clip_plus);
-    }
-#else
-    if (kapp->clipboard()->ownsSelection()) {
-	clip_own_selection(&clip_star);
-    } else {
-	clip_lose_selection(&clip_star);
-    }
-#endif
-}//}}}
-
-void VimMainWindow::slotSearch()//{{{
-{
-    QString	find_text;
-    bool	direction_down = TRUE;
-    bool	casesensitive = TRUE;
-    int		flags = FRD_FINDNEXT;
-
-    find_text = finddlg->getText();
-    direction_down = !(finddlg->get_direction());
-    casesensitive = finddlg->case_sensitive();
-    //    if (casesensitive) find_text = "\\C" + find_text;
-    //    else find_text = "\\c" + find_text;
-    if (casesensitive) flags|=FRD_MATCH_CASE;
-    QCString unistring = vmw->codec->fromUnicode(find_text);
-    gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down);
-}//}}}
-
-void VimMainWindow::slotFind()//{{{
-{
-    QString	find_text;
-    bool	direction_down=TRUE;
-    bool	casesensitive = TRUE;
-    int		flags = FRD_R_FINDNEXT;
-
-    find_text=repldlg->getText();
-    direction_down = !(repldlg->get_direction());
-    casesensitive = repldlg->case_sensitive();
-    //    if (casesensitive) find_text = "\\C" + find_text;
-    //    else find_text = "\\c" + find_text;
-    if (casesensitive) flags|=FRD_MATCH_CASE;
-
-    QCString unistring = vmw->codec->fromUnicode(find_text);
-    gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down);
-}//}}}
-
-void VimMainWindow::slotReplace()//{{{
-{
-    QString	find_text;
-    QString     repl_text;
-    bool	direction_down=TRUE;
-    bool	casesensitive = TRUE;
-    int		flags = FRD_REPLACE;
-
-    find_text=repldlg->getText();
-    repl_text=repldlg->getReplaceText();
-    direction_down = !(repldlg->get_direction());
-    //if (casesensitive) find_text = "\\C" + find_text;
-    //else find_text = "\\c" + find_text;
-    if (casesensitive) flags|=FRD_MATCH_CASE;
-
-    QCString unistring = vmw->codec->fromUnicode(find_text);
-    QCString unistring2 = vmw->codec->fromUnicode(repl_text);
-    gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down);
-}//}}}
-
-void VimMainWindow::slotReplaceAll()//{{{
-{
-    QString	find_text;
-    QString     repl_text;
-    bool	direction_down=TRUE;
-    bool	casesensitive = TRUE;
-    int		flags = FRD_REPLACEALL;
-
-    find_text=repldlg->getText();
-    repl_text=repldlg->getReplaceText();
-    direction_down = !(repldlg->get_direction());
-    casesensitive = repldlg->case_sensitive();
-    //    if (casesensitive) find_text = "\\C" + find_text;
-    //    else find_text = "\\c" + find_text;
-    if (casesensitive) flags|=FRD_MATCH_CASE;
-    QCString unistring = vmw->codec->fromUnicode(find_text);
-    QCString unistring2 = vmw->codec->fromUnicode(repl_text);
-    gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down);
-}//}}}
-
-void VimMainWindow::showAboutKDE()
-{
-    KAboutKDE *kde = new KAboutKDE(this);
-    kde->show();
-}
-
-void VimMainWindow::showAboutApplication()//{{{
-{
-    KAboutData *aboutData = new KAboutData (
-	    "kvim"
-	    , I18N_NOOP("KVim")
-	    , VIM_VERSION_SHORT
-	    , I18N_NOOP("Vim in a KDE interface")
-	    , 0
-	    , "(c) Vim Team, \":help credits\" for more infos.\nType \":help iccf\" to see how you can help the children in Uganda"
-	    , 0l
-	    , "http://freehackers.org/kvim"
-	    , "kvim-dev@freenux.org"
-	    );
-
-    aboutData->addAuthor("Bram Moolenaar",
-	    I18N_NOOP("Main vim author"),
-	    "Bram@vim.org",
-	    "http://www.vim.org/");
-    aboutData->addAuthor("Thomas Capricelli",
-	    I18N_NOOP("KDE porting"),
-	    "orzel@freehackers.org",
-	    "http://orzel.freehackers.org");
-    aboutData->addAuthor("Philippe Fremy",
-	    I18N_NOOP("KDE porting"),
-	    "pfremy@chez.com",
-	    "http://www.freehackers.org/kvim");
-    aboutData->addAuthor("Mark Westcott",
-	    I18N_NOOP("Qtopia porting, maintainer of the Qtopia part"),
-	    "mark@houseoffish.org",
-	    "http://houseoffish.org");
-    aboutData->addAuthor("Mickael Marchand",
-	    I18N_NOOP("KDE porting, maintainer"),
-	    "marchand@kde.org",
-	    "http://freenux.org");
-    aboutData->addAuthor("Many other people",
-	    I18N_NOOP("type :help credits for more infos")
-	    );
-    aboutData->addCredit("Vince Negri",
-	    I18N_NOOP("Antialiasing support, Color fixes"),
-	    "vnegri@asl-electronics.co.uk");
-    aboutData->addCredit("Malte Starostik",
-	    I18N_NOOP("Patch for performance improvement"),
-	    "malte@kde.org");
-    aboutData->addCredit("Mark Stosberg",
-	    I18N_NOOP("Provided a FreeBSD box to debug KVim on BSD"),
-	    "mark@summersault.com"
-	    );
-    aboutData->addCredit("Henrik Skott",
-	    I18N_NOOP("Font patch when KDE not configured"),
-	    "henrik.skott@hem.utfors.se"
-	    );
-    aboutData->addCredit("Kailash Sethuraman",
-	    I18N_NOOP("NetBSD configure/compilation fixes")
-	    );
-    aboutData->setLicenseText(
-"KVim as an extension of Vim follows Vim license : \n\
-Vim is Charityware.  You can use and copy it as much as you like, but you are\n\
-encouraged to make a donation to orphans in Uganda.  Please read the file\n\
-runtime/doc/uganda.txt for details.\n\
-\n\
-There are no restrictions on distributing an unmodified copy of Vim.  Parts of\n\
-Vim may also be distributed, but this text must always be included.  You are\n\
-allowed to include executables that you made from the unmodified Vim sources,\n\
-your own usage examples and Vim scripts.\n\
-\n\
-If you distribute a modified version of Vim, you are encouraged to send the\n\
-maintainer a copy, including the source code.  Or make it available to the\n\
-maintainer through ftp; let him know where it can be found.  If the number of\n\
-changes is small (e.g., a modified Makefile) e-mailing the diffs will do.\n\
-When the maintainer asks for it (in any way) you must make your changes,\n\
-including source code, available to him.\n\
-\n\
-The maintainer reserves the right to include any changes in the official\n\
-version of Vim.  This is negotiable.  You are not allowed to distribute a\n\
-modified version of Vim when you are not willing to make the source code\n\
-available to the maintainer.\n\
-\n\
-The current maintainer is Bram Moolenaar <Bram@vim.org>.  If this changes, it\n\
-will be announced in appropriate places (most likely www.vim.org and\n\
-comp.editors).  When it is completely impossible to contact the maintainer,\n\
-the obligation to send him modified source code ceases.\n\
-\n\
-It is not allowed to remove these restrictions from the distribution of the\n\
-Vim sources or parts of it.  These restrictions may also be used for previous\n\
-Vim releases instead of the text that was included with it.");
-
-    KAboutApplication *about = new KAboutApplication(aboutData);
-    about->show();
-}//}}}
-
-void VimMainWindow::showTipOfTheDay() {
-#if QT_VERSION>=300
-    KTipDialog::showTip (vmw,QString::null,true);
-#endif
-}
-
-void VimMainWindow::buffersToolbar() {
-
-}
-
-void VimMainWindow::showBugReport() {
-    KBugReport *bug= new KBugReport(this,true);
-    bug->show();
-}
-/*
- *   Vim Dialog
- *
- * Returns:
- *  0: Cancel
- *  1- : nb of the pressed button
- */
-
-VimDialog::VimDialog (int type,		/* type of dialog *///{{{
-	char_u * title,		/* title of dialog */
-	char_u * message,	/* message text */
-	char_u * buttons,	/* names of buttons */
-	int def_but,		/* default button */
-	char_u *textfield )	/* input field */
-:QDialog(vmw, "vim generic dialog", true), // true is for "modal"
-    mapper(this, "dialog signal mapper")
-{
-    /*
-     * Create Icon
-     */
-    char ** icon_data;
-    switch (type) {
-	case VIM_GENERIC:
-	    icon_data = generic_xpm;
-	    break;
-	case VIM_ERROR:
-	    icon_data = error_xpm;
-	    break;
-	case VIM_WARNING:
-	    icon_data = alert_xpm;
-	    break;
-	case VIM_INFO:
-	    icon_data = info_xpm;
-	    break;
-	case VIM_QUESTION:
-	    icon_data = quest_xpm;
-	    break;
-	default:
-	    icon_data = generic_xpm;
-    };
-    QLabel * icon = new QLabel( this );
-    icon->setPixmap( QPixmap( (const char **) icon_data ) );
-    icon->setFixedSize( icon->sizeHint() );
-
-    QLabel * text = new QLabel( (const char *)message, this );
-    text->setAlignment( AlignHCenter | AlignVCenter | ExpandTabs );
-
-    QStringList buttonText = QStringList::split( DLG_BUTTON_SEP, (char *) buttons);
-    int butNb = buttonText.count();
-
-    /*
-     *  Layout
-     */
-
-    QVBoxLayout * vly = new QVBoxLayout( this, 5, 5 );
-    QHBoxLayout * hly1 = new QHBoxLayout( vly, 5);
-    hly1->addWidget( icon );
-    hly1->addWidget( text );
-    QHBoxLayout * hly3 = new QHBoxLayout ( vly , 5);
-    if (textfield!=NULL) {
-	entry = new QLineEdit((const char *)textfield,this);
-	entry->setText((const char *)textfield);
-	hly3->addWidget( entry );
-	ret=textfield;
-    } else entry=NULL;
-
-    QHBoxLayout * hly2 = new QHBoxLayout( vly, 15);
-    QString s;
-    QPushButton * pushButton = 0L;
-    for( int i=0; i<butNb; i++) {
-	s = buttonText[i];
-	pushButton = new QPushButton(s, this );
-	if (s.find('&') != -1) {
-	    pushButton->setAccel( s.at(s.find('&')+1).latin1() );
-	}
-
-	hly2->addWidget( pushButton );
-	if (i == def_but-1) {
-	    pushButton->setDefault( true );
-	    pushButton->setAutoDefault( true );
-	    setResult( i+1 );
-	}
-	connect(pushButton, SIGNAL(clicked()), &mapper, SLOT(map()));
-	mapper.setMapping(pushButton, i+1);
-    }
-    connect( &mapper, SIGNAL(mapped(int)), this, SLOT(done(int)));
-
-    setCaption((const char *) title);
-
-    vly->activate();
-}//}}}
-
-void VimDialog::done(int r) {
-    if (entry!=NULL) {
-        if (r) {
-	   QCString unistring=vmw->codec->fromUnicode(entry->text());
-	   STRCPY(ret,(const char*)unistring);
-	} else
-	    *ret=NUL;
-    }
-    QDialog::done(r);
-}
-
-/*
- * ScrollBar pool handling
- */
-SBPool::SBPool(void)//{{{
-    :mapper(this, "SBPool signal mapper")
-{
-    connect(&mapper, SIGNAL(mapped(int)), this, SLOT(sbUsed(int)));
-}//}}}
-
-
-void SBPool::create(GuiScrollbar * sb, int orient)//{{{
-{
-    switch(orient) {
-	case SBAR_HORIZ:
-	    sb->w = new QScrollBar(QScrollBar::Horizontal, vmw);
-	    break;
-	case SBAR_VERT:
-	    sb->w = new QScrollBar(QScrollBar::Vertical, vmw);
-	    break;
-	default:
-	    sb->w = 0;
-	    return;
-    }
-
-    connect(sb->w, SIGNAL(valueChanged(int)), &mapper, SLOT(map()));
-    mapper.setMapping(sb->w, (int)sb);
-}//}}}
-
-
-void SBPool::sbUsed(int who)//{{{
-{
-    GuiScrollbar *sb = (GuiScrollbar*)who;
-    gui_drag_scrollbar( sb, sb->w->value(), FALSE);
-}//}}}
-
-
-void SBPool::destroy(GuiScrollbar * sb)//{{{
-{
-    if (!sb->w) return;
-
-    delete sb->w;
-    sb->w = 0;
-}//}}}
-
-#ifdef FEAT_CLIENTSERVER
-static int kvim_x11_event_filter( XEvent* e)//{{{
-{
-    if (e->xproperty.type == PropertyNotify
-	    && e->xproperty.atom == commProperty
-	    && e->xproperty.window == commWindow
-	    && e->xproperty.state == PropertyNewValue ) {
-	serverEventProc(qt_xdisplay(), e);
-    }
-
-    if (oldFilter) return oldFilter( e );
-    return FALSE;
-}//}}}
-#endif
-
-//add some QT 3 fonts usefull functions
-#if QT_VERSION<300
-QString KVimUtils::toString(QFont *f)
-{
-    QStringList l;
-    l.append(f->family());
-    l.append(QString::number(f->pointSize()));
-    l.append(QString::number(f->pixelSize()));
-    l.append(QString::number((int)f->styleHint()));
-    l.append(QString::number(f->weight()));
-    l.append(QString::number((int)f->italic()));
-    l.append(QString::number((int)f->underline()));
-    l.append(QString::number((int)f->strikeOut()));
-    l.append(QString::number((int)f->fixedPitch()));
-    l.append(QString::number((int)f->rawMode()));
-    return l.join(",");
-}
-
-bool KVimUtils::fromString(QFont *f, QString descrip)
-{
-   QStringList l(QStringList::split(',', descrip));
-
-    int count = l.count();
-    if (count != 10 && count != 9) {
-        return FALSE;
-    }
-
-    f->setFamily(l[0]);
-    f->setPointSize(l[1].toInt());
-    if ( count == 9 ) {
-        f->setStyleHint((QFont::StyleHint) l[2].toInt());
-        f->setWeight(l[3].toInt());
-        f->setItalic(l[4].toInt());
-        f->setUnderline(l[5].toInt());
-        f->setStrikeOut(l[6].toInt());
-        f->setFixedPitch(l[7].toInt());
-        f->setRawMode(l[8].toInt());
-    } else {
-        f->setPixelSize(l[2].toInt());
-        f->setStyleHint((QFont::StyleHint) l[3].toInt());
-        f->setWeight(l[4].toInt());
-        f->setItalic(l[5].toInt());
-        f->setUnderline(l[6].toInt());
-        f->setStrikeOut(l[7].toInt());
-        f->setFixedPitch(l[8].toInt());
-        f->setRawMode(l[9].toInt());
-    }
-    return TRUE;
-}
-#endif
-
-QString KVimUtils::convertEncodingName(QString name)
-{
-    if (name.startsWith("ucs") || name.startsWith("utf-16")) return QString("utf16");
-    if (name=="cp950") return QString("Big5");
-    return QString();
-}
deleted file mode 100644
--- a/src/gui_kde_widget.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/* vi:set ts=8 sts=0 sw=8:
- *
- * VIM - Vi IMproved		by Bram Moolenaar
- *
- * Do ":help uganda"  in Vim to read copying and usage conditions.
- * Do ":help credits" in Vim to see a list of people who contributed.
- */
-
-/*
- * Porting to KDE(2) was done by
- *
- *  (C) 2000 by Thomas Capricelli <orzel@freehackers.org>
- *
- *  Please visit http://freehackers.org/kvim for other vim- or
- *  kde-related coding.
- *
- *  $Id$
- *
- */
-
-#ifndef GUI_KDE_WIDGET
-#define GUI_KDE_WIDGET
-
-#if 1
-#define dbf( format, args... ) { printf( "%s" " : " format "\n" , __FUNCTION__ , ## args ); fflush(stdout); }
-#define db()       { printf( "%s\n", __FUNCTION__ );fflush(stdout); }
-#else
-#define dbf(format, args... )
-#define db()
-#endif
-
-#define UNIX	    // prevent a warning : a symbol is defined twice in X and Qt
-
-#include <qdialog.h>
-#include <qlabel.h>
-#include <qsignalmapper.h>
-#include <qtimer.h>
-#include <qmainwindow.h>
-#include <qapplication.h>
-#include <qevent.h>
-#include <qlineedit.h>
-#include <qpainter.h>
-#include <qwidget.h>
-#include <qpopupmenu.h>
-#include <klocale.h>
-#include <kapp.h>
-#include <kcmdlineargs.h>
-#include <kaboutdata.h>
-#include <keditcl.h>
-#include <kaboutdata.h>
-#if (KDE_VERSION>=290)
-#include <kmainwindow.h>
-#else
-#include <ktmainwindow.h>
-#endif
-#include <kparts/part.h>
-#include <kurl.h>
-#include "kvim_iface.h"
-
-#undef UNIX	    // prevent a warning
-extern "C" {
-#include "vim.h"
-}
-
-class QPushButton;
-class QDialog;
-class QLineEdit;
-class QSignalMapper;
-class QPaintEvent;
-
-enum BlinkState {
-	BLINK_NONE,
-	BLINK_ON,
-	BLINK_OFF
-};
-
-class VimWidget : public QWidget, virtual public KVim
-{
-	Q_OBJECT
-
-public:
-	VimWidget( QWidget *parent=0, const char *name=0, WFlags f=0 );
-	virtual void paintEvent( QPaintEvent *);
-	void	draw_string(int x, int y, QString s, int len, int flags);
-
-	/** Init the blinking time */
-	void set_blink_time( long, long, long );
-	void start_cursor_blinking();
-	void stop_cursor_blinking();
-	void wait(long);
-#ifdef FEAT_CLIENTSERVER
-	void serverActivate(WId id);
-#endif
-#ifdef FEAT_MZSCHEME
-	void enable_mzscheme_threads();
-	void disable_mzscheme_threads();
-#endif
-	void flash();
-	
-	/** DCOP */
-	void execNormal(QString command);
-	void execInsert(QString command);
-	void execRaw(QString command);
-	void execCmd(QString command);
-	QString eval(QString expr);
-	
-	bool wait_done;
-	BlinkState blink_state;
-	QPainter *painter;
-	QPopupMenu *menu;
-
-protected:
-	virtual void keyPressEvent( QKeyEvent * );
-	virtual void mousePressEvent( QMouseEvent *);
-	virtual void mouseDoubleClickEvent( QMouseEvent *);
-	virtual void mouseReleaseEvent( QMouseEvent *);
-	virtual void mouseMoveEvent( QMouseEvent *);
-	virtual void focusInEvent( QFocusEvent * );
-	virtual void focusOutEvent( QFocusEvent * );
-	virtual void dragEnterEvent (QDragEnterEvent *);
-	virtual void dropEvent (QDropEvent *);
-#ifdef FEAT_XIM
-	virtual void imStartEvent ( QIMEvent * );
-	virtual void imEndEvent ( QIMEvent * );
-	virtual void imComposeEvent ( QIMEvent * );
-#endif
-#ifdef FEAT_MZSCHEME
-	virtual void timerEvent( QTimerEvent * );
-#endif
-
-	/* cursor blinking stuff */
-	QTimer blink_timer;
-	long blink_wait_time, blink_on_time, blink_off_time;
-
-	/* wait for input */
-	QTimer	wait_timer;
-	
-#ifdef FEAT_MZSCHEME
-	int	mzscheme_timer_id;
-#endif
-
-public slots:
-	void    blink_cursor();
-	void	wait_timeout();
-};
-
-class VimMainWindow : public KMainWindow
-{
-	Q_OBJECT
-
-public:
-	VimMainWindow ( const char *name = 0L, WFlags f = WDestructiveClose );
-
-	/** called when the widget closes */
-//	bool close(bool alsoDelete);
-	VimWidget	*w;
-        KEdFind         *finddlg;
-        KEdReplace      *repldlg;
-	int		have_tearoff;
-	QTextCodec      *codec;
-
-public slots:
-	void    menu_activated(int dx);
-	void 	clipboard_selection_update();
-	void 	clipboard_data_update();
-        void    slotSearch();
-        void    slotFind();
-        void    slotReplace();
-        void    slotReplaceAll();
-	void    showAboutApplication();
-	void    showAboutKDE();
-	void    showBugReport();
-	void    showTipOfTheDay();
-	void    buffersToolbar();
-	bool    isLocked();
-	void    lock();
-	void    unlock();
-
-protected:
-	virtual void wheelEvent (QWheelEvent *);
-	virtual void resizeEvent ( QResizeEvent *e );
-
-#if defined(FEAT_SESSION)
-	void saveGlobalProperties (KConfig *conf);
-	void readGlobalProperties (KConfig *conf);
-#endif
-	bool queryClose();
-	bool queryExit();
-	bool locked;
-};
-
-
-class VimDialog : public QDialog
-{
-	Q_OBJECT
-public:
-	VimDialog (int type,		/* type of dialog */
-	       unsigned char * title,		/* title of dialog */
-	       unsigned char * message,	/* message text */
-	       unsigned char * buttons,	/* names of buttons */
-	       int def_but,		/* default button */
-	       char_u *textfield);		/* input text */
-private:
-	QSignalMapper	mapper;
-	QLineEdit	*entry;
-	char_u		*ret;
-	int		butNb;
-
-protected slots:
-	void done(int);
-};
-
-
-/*
- * QScrollBar  pool
- */
-struct GuiScrollbar;
-
-class SBPool : public QObject
-{
-	Q_OBJECT
-public:
-	SBPool(void);
-	void create(GuiScrollbar * sb, int orient);
-	void destroy(GuiScrollbar * sb);
-public slots:
-	void sbUsed(int who);
-private:
-	QSignalMapper mapper;
-};
-
-class KVimUtils {
-public:
-	static QString convertEncodingName(QString);
-#if QT_VERSION<300
-	static bool fromString(QFont*,QString);
-	static QString toString(QFont*);
-#endif
-};
-
-extern VimMainWindow	*vmw;
-extern SBPool		*sbpool;
-extern QString          *argServerName;
-
-#endif // GUI_KDE_WIDGET
--- a/src/gui_kde_x11.cc
+++ b/src/gui_kde_x11.cc
@@ -45,7 +45,7 @@
 #include <qfont.h>
 
 
-#include "gui_kde_widget.h"
+#include "gui_kde_wid.h"
 
 
 extern "C" {
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -2731,6 +2731,7 @@ StringToLine(PyObject *obj)
     char *save;
     int len;
     int i;
+    char *p;
 
     if (obj == NULL || !PyString_Check(obj))
     {
@@ -2741,14 +2742,22 @@ StringToLine(PyObject *obj)
     str = PyString_AsString(obj);
     len = PyString_Size(obj);
 
-    /* Error checking: String must not contain newlines, as we
+    /*
+     * Error checking: String must not contain newlines, as we
      * are replacing a single line, and we must replace it with
      * a single line.
+     * A trailing newline is removed, so that append(f.readlines()) works.
      */
-    if (memchr(str, '\n', len))
+    p = memchr(str, '\n', len);
+    if (p != NULL)
     {
-	PyErr_SetVim(_("string cannot contain newlines"));
-	return NULL;
+	if (p == str + len - 1)
+	    --len;
+	else
+	{
+	    PyErr_SetVim(_("string cannot contain newlines"));
+	    return NULL;
+	}
     }
 
     /* Create a copy of the string, with internal nulls replaced by
--- a/src/main.aap
+++ b/src/main.aap
@@ -100,9 +100,9 @@ prefix = `os.path.expanduser(prefix)`
 	GUI_TESTTARGET	= gui
     KDE
         GUI_SRC		= gui.c pty.c gui_kde.cc gui_kde_x11.cc
-                            gui_kde_widget_moc.cc
+                            gui_kde_wid_moc.cc
                             kvim_iface_skel.cc
-        GUI_OBJ		= $BDIR/gui_kde_widget.o
+        GUI_OBJ		= $BDIR/gui_kde_wid.o
         GUI_DEFS	= -DFEAT_GUI_KDE $NARROW_PROTO
         GUI_IPATH	= $GUI_INC_LOC
         GUI_LIBS_DIR	= $GUI_LIB_LOC
@@ -218,7 +218,7 @@ test check:
 testclean {virtual}:
     :del {force} testdir/*.out testdir/test.log
 
-CLEANFILES += gui_kde_widget_moc.cc kvim_iface_skel.cc *.kidl
+CLEANFILES += gui_kde_wid_moc.cc kvim_iface_skel.cc *.kidl
 
 # When no fetch target exists we are not a child of the ../main.aap recipe,
 # Use ../main.aap to do the fetching.
@@ -356,18 +356,18 @@ auto/if_perl.c: if_perl.xs
 	:sys $PERL $PERLLIB/ExtUtils/xsubpp -prototypes -typemap \
 	    $PERLLIB/ExtUtils/typemap if_perl.xs >> $target
 
-$BDIR/gui_kde_widget.o: gui_kde_widget.cc
-        :sys $MOC -o gui_kde_widget_moc.cc gui_kde_widget.h
+$BDIR/gui_kde_wid.o: gui_kde_wid.cc
+        :sys $MOC -o gui_kde_wid_moc.cc gui_kde_wid.h
         @try:
             :sys $KDE_PREFIX/bin/dcopidl kvim_iface.h > kvim_iface.kidl
         @except:
             :del {f} kvim_iface.kidl
         :sys $KDE_PREFIX/bin/dcopidl2cpp --c++-suffix cc --no-stub kvim_iface.kidl
-        :do compile gui_kde_widget.cc
+        :do compile gui_kde_wid.cc
 
-gui_kde_widget_moc.cc: $BDIR/gui_kde_widget.o
+gui_kde_wid_moc.cc: $BDIR/gui_kde_wid.o
 
-kvim_iface_skel.cc: $BDIR/gui_kde_widget.o
+kvim_iface_skel.cc: $BDIR/gui_kde_wid.o
 
 
 auto/osdef.h: auto/config.h osdef.sh osdef1.h.in osdef2.h.in
--- a/src/memline.c
+++ b/src/memline.c
@@ -4338,8 +4338,17 @@ ml_find_line_or_offset(buf, line, offp)
 	curline = buf->b_ml.ml_locked_high + 1;
     }
 
-    if (ffdos)
-	size += line - 1;
+    if (line != 0)
+    {
+	/* Count extra CR characters. */
+	if (ffdos)
+	    size += line - 1;
+
+	/* Don't count the last line break if 'bin' and 'noeol'. */
+	if (buf->b_p_bin && !buf->b_p_eol)
+	    size -= ffdos + 1;
+    }
+
     return size;
 }
 
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -3606,8 +3606,7 @@ vim_findfile_init(path, filename, stopdi
     }
 
     /* Store information on starting dir now if path is relative.
-     * If path is absolute, we do that later.
-     */
+     * If path is absolute, we do that later.  */
     if (path[0] == '.'
 	    && (vim_ispathsep(path[1]) || path[1] == NUL)
 	    && (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL)
@@ -3886,7 +3885,7 @@ vim_findfile_cleanup(ctx)
  * Return a pointer to an allocated file name or NULL if nothing found.
  * To get all matching files call this function until you get NULL.
  *
- * If the passed search_context is NULL, it the returns NULL.
+ * If the passed search_context is NULL, NULL is returned.
  *
  * The search algorithm is depth first. To change this replace the
  * stack with a list (don't forget to leave partly searched directories on the
--- a/src/ops.c
+++ b/src/ops.c
@@ -1129,7 +1129,7 @@ do_execreg(regname, colon, addcr)
 	new_last_cmdline = NULL;
 	/* Escape all control characters with a CTRL-V */
 	p = vim_strsave_escaped_ext(last_cmdline,
-		"\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", Ctrl_V, FALSE);
+		(char_u *)"\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", Ctrl_V, FALSE);
 	if (p != NULL)
 	    retval = put_in_typebuf(p, TRUE);
 	vim_free(p);
--- a/src/os_mac.h
+++ b/src/os_mac.h
@@ -119,8 +119,8 @@
  *       ~/Library/Vim or ~/Library/Preferences/org.vim.vim/ ? (Dany)
  */
 /* When compiled under MacOS X (including CARBON version)
- * we use the Unix File path style */
-#if defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX
+ * we use the Unix File path style.  Also when UNIX is defined. */
+#if defined(UNIX) || (defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX)
 # undef COLON_AS_PATHSEP
 # define USE_UNIXFILENAME
 #else
@@ -140,14 +140,16 @@
 #define CASE_INSENSITIVE_FILENAME   /* ignore case when comparing file names */
 #define SPACE_IN_FILENAME
 #define BREAKCHECK_SKIP	   32	    /* call mch_breakcheck() each time, it's
-				       quite fast. Did I forgot to update the comment */
+				       quite fast. Did I forgot to update the
+				       comment */
 
 
-#undef  USE_FNAME_CASE	    /* So that :e os_Mac.c, :w, save back the file as os_mac.c */
+#undef  USE_FNAME_CASE		/* So that :e os_Mac.c, :w, save back the file
+				   as os_mac.c */
 #define BINARY_FILE_IO
 #define EOL_DEFAULT EOL_MAC
-#ifndef MACOS_X_UNIX	    /* I hope that switching these two lines */
-# define USE_CR		    /* does what I want -- BNF */
+#ifndef MACOS_X_UNIX		/* I hope that switching these two lines */
+# define USE_CR			/* does what I want -- BNF */
 # define NO_CONSOLE		/* don't include console mode */
 #endif
 #define HAVE_AVAIL_MEM
--- a/src/os_mac_conv.c
+++ b/src/os_mac_conv.c
@@ -16,6 +16,7 @@
 #define NO_X11_INCLUDES
 #include "vim.h"
 
+#ifdef FEAT_MBYTE
 extern char_u *mac_string_convert __ARGS((char_u *ptr, int len, int *lenp, int fail_on_error, int from, int to, int *unconvlenp));
 extern int macroman2enc __ARGS((char_u *ptr, long *sizep, long real_size));
 extern int enc2macroman __ARGS((char_u *from, size_t fromlen, char_u *to, int *tolenp, int maxtolen, char_u *rest, int *restlenp));
@@ -228,3 +229,5 @@ enc2macroman(from, fromlen, to, tolenp, 
     *tolenp = l;
     return OK;
 }
+
+#endif /* FEAT_MBYTE */
--- a/src/po/ru.cp1251.po
+++ b/src/po/ru.cp1251.po
@@ -1239,7 +1239,7 @@ msgstr "E173: 1 файл ожидает редактирования."
 #: ex_docmd.c:4584
 #, c-format
 msgid "E173: %ld more files to edit"
-msgstr "E173: Есть неотредактированные файлы (%d)."
+msgstr "E173: Есть неотредактированные файлы (%ld)."
 
 #: ex_docmd.c:4679
 msgid "E174: Command already exists: add ! to replace it"
@@ -2446,7 +2446,7 @@ msgstr "Добавлена база данных cscope %s"
 #: if_cscope.c:589
 #, c-format
 msgid "E262: error reading cscope connection %ld"
-msgstr "E262: ошибка получения информации от соединения cscope %d"
+msgstr "E262: ошибка получения информации от соединения cscope %ld"
 
 #: if_cscope.c:694
 msgid "E561: unknown cscope search type"
@@ -2524,7 +2524,7 @@ msgstr "E261: соединение с cscope %s не обнаружено"
 #: if_cscope.c:1458
 #, c-format
 msgid "cscope connection %s closed"
-msgstr "соединение с cscope закрыто"
+msgstr "соединение с cscope %s закрыто"
 
 #. should not reach here
 #: if_cscope.c:1598
--- a/src/po/ru.po
+++ b/src/po/ru.po
@@ -1239,7 +1239,7 @@ msgstr "E173: 1 файл ожидает редактирования."
 #: ex_docmd.c:4584
 #, c-format
 msgid "E173: %ld more files to edit"
-msgstr "E173: Есть неотредактированные файлы (%d)."
+msgstr "E173: Есть неотредактированные файлы (%ld)."
 
 #: ex_docmd.c:4679
 msgid "E174: Command already exists: add ! to replace it"
@@ -2446,7 +2446,7 @@ msgstr "Добавлена база данных cscope %s"
 #: if_cscope.c:589
 #, c-format
 msgid "E262: error reading cscope connection %ld"
-msgstr "E262: ошибка получения информации от соединения cscope %d"
+msgstr "E262: ошибка получения информации от соединения cscope %ld"
 
 #: if_cscope.c:694
 msgid "E561: unknown cscope search type"
@@ -2524,7 +2524,7 @@ msgstr "E261: соединение с cscope %s не обнаружено"
 #: if_cscope.c:1458
 #, c-format
 msgid "cscope connection %s closed"
-msgstr "соединение с cscope закрыто"
+msgstr "соединение с cscope %s закрыто"
 
 #. should not reach here
 #: if_cscope.c:1598
--- a/src/search.c
+++ b/src/search.c
@@ -3760,10 +3760,11 @@ find_prev_quote(line, col_start, quotech
  * Find quote under the cursor, cursor at end.
  * Returns TRUE if found, else FALSE.
  */
+/*ARGSUSED*/
     int
 current_quote(oap, count, include, quotechar)
     oparg_T	*oap;
-    long	count;
+    long	count;		/* not used */
     int		include;	/* TRUE == include quote char */
     int		quotechar;	/* Quote character */
 {