updated for version 7.0003
diff --git a/src/INSTALL b/src/INSTALL
index b1aa6a8..0c01ef2 100644
--- a/src/INSTALL
+++ b/src/INSTALL
@@ -88,7 +88,7 @@
 Unix: COMPILING WITH/WITHOUT GUI
 
 These configure arguments can be used to select which GUI to use:
---enable-gui=	gtk, motif, athena or auto
+--enable-gui=	gtk, kde, motif, athena or auto
 --disable-gtk-check
 --disable-motif-check
 --disable-athena-check
@@ -98,19 +98,19 @@
 does not proceed to check any of the remaining ones.  Otherwise, it moves on
 to the next one.
 
---enable-{gtk,motif,athena}-check all default to "yes", such that if
+--enable-{gtk,kde,motif,athena}-check all default to "yes", such that if
 --enable-gui is "auto" (which it is by default), GTK, Motif, and Athena will
 be checked for.  If you want to *exclude* a certain check, then you use
---disable-{gtk,motif,athena}-check.
+--disable-{gtk,kde,motif,athena}-check.
 
 For example, if --enable-gui is set to "auto", but you don't want it look for
 Motif, you then also specify --disable-motif-check.  This results in only
 checking for GTK and Athena.
 
 Lastly, if you know which one you want to use, then you can just do
---enable-gui={gtk,motif,athena}.  So if you wanted to only use Motif, then
+--enable-gui={gtk,kde,motif,athena}.  So if you wanted to only use Motif, then
 you'd specify --enable-gui=motif.  Once you specify what you want, the
---enable-{gtk,motif,athena}-check options are ignored.
+--enable-{gtk,kde,motif,athena}-check options are ignored.
 
 For compiling with the GTK+ GUI, you need a recent version of glib and gtk+.
 Configure checks for at least version 1.1.16, but below 2.0.  An older versions
@@ -124,6 +124,9 @@
 auto/config.log for any error messages that may give you a hint as to what's
 happening.
 
+For KDE see INSTALLkde.txt.
+
+
 Unix: COMPILING WITH MULTI-BYTE
 
 When you want to compile with the multi-byte features enabled, make sure you
diff --git a/src/INSTALLkde.txt b/src/INSTALLkde.txt
new file mode 100644
index 0000000..42d4a12
--- /dev/null
+++ b/src/INSTALLkde.txt
@@ -0,0 +1,101 @@
+Vim with KDE: kvim
+
+ON THE INTERNET
+===============
+
+	The homepage is http://www.freehackers.org/kvim/
+	The core is build around the official vim-6.x releases and patches
+
+	KVim CVS is full and does not need extra package. Just download and compile it.
+
+INSTALL :
+=========
+	We now use Vim's configure to configure, compile and install KVim.
+
+	Don't forget, that you need to have QT and KDE headers and tools installed, otherwise it won't
+	work ! (these can commonly be found in kde-devel/qt-devel packages)
+	
+	Enter the 'src' directory and configure it your way (you need to add at least these flags to the configure command line : --enable-gui=kde --with-qt-dir=$QTDIR ) then make and make install as root.
+	We added to configure some options for KDE / QT detection, it will for example, find whether you use KDE 2.x or KDE 3.x automatically. For now, QT is _not_ autodetected. I hope to fix this soon.
+	From KVim 6.1, you can now use a KDE toolbar instead of Vim's Toolbar, to enable it, use the --enable-kde-toolbar configure flag.
+
+
+=> If it fails : (yes it still can, the configure script i wrote is still experimental and probably not
+perfect ;p)
+	or 'how to make a bug report' :
+
+	In some cases, I can imagine it will fail, if this happens then send to marchand@kde.org :
+		->auto/config.mk (important one)
+		->your configure command line with your options
+		->your paths : where KDE is (which version ?), where QT is (version ?), and find where your
+			libs are (your kdelibs, your QT libs and QT headers)
+		->the output of 'kde-config --version'
+		->your OS / Linux Distribution version
+		->in case of a compilation error : the full error output.
+		->the compiler used (gcc 2.95, 2.96, 3.1 ...)
+		->any stuff you think could be usefull to me :)
+
+	Thanks for giving KVim a try, we hope you'll enjoy it !
+
+
+DEVELOPMENT STATE AND KNOWN BUGS:
+=================================
+Most Vim GUI features are now implemented, only multibyte support is incomplete.
+We are working on this and this is our primary goal after KVim 6.1 release.
+We hope to get it to work before we include KVim into the core Vim which we want to
+do before the end of the year 2002 if possible.
+
+We would be happy to hear from you if you've tried kvim. Tell us
+what is missing, what you like and don't like, and what you want.
+
+As people have wished it for a while, Philippe developped a component for Vim.
+The component is now fully usable with GVim and KVim and can be found on KDE's CVS
+in the kdeextragear-1 module.
+
+SOURCE ACCESS:
+==============
+Releases and maybe snapshots are/will be found on http://freehackers.org/kvim/
+The CVS is CVSROOT=:pserver:anonymous@cvs.tuxfamily.org:/cvsroot/kvim
+(with no password)
+You'll find there a full vim 6.x package (with runtime files included).
+
+MAILING LIST:
+=============
+As we released KVim 6.0, we created a public mailing list, for feedback,
+user help and development related discussions : "kvim-dev@freenux.org",
+ to subscribe send a mail to "kvim-dev-subscribe@freenux.org" with
+"subscribe" as the subject and just reply to the mail you will receive.
+(sorry the admin messages are in french, but the list discussions are in
+english)
+
+THANKS :
+========
+To all the guys on #kde@opn (Neil, Malte and many other) and to all the people who
+tried, debugged, compiled and recompiled again KVim to bring now a much more robust KVim
+and of course to all of you who send patchs and comments :)
+And of course to Vim Authors :)
+
+CURRENT MAINTAINER:
+===================
+	Mickael Marchand <marchand@kde.org>
+	
+DEVELOPERS (CVS accounts):
+==========
+	Mickael Marchand <marchand@kde.org> (marchand)
+	Mark Westcott <mark@houseoffish.org> Qtopia GUI (mark)
+	Thomas Capricelli <orzel@kde.org> Initial KVim author (orzel)
+	Philippe Fremy <pfremy@chez.com> Initial KVim author (pfremy)
+
+AUTHORS
+=========
+	Thomas Capricelli <orzel@kde.org> Initial KVim author
+	Philippe Fremy <pfremy@chez.com> Initial KVim author
+	
+CONTRIBUTORS
+============
+	David Spencer Tyree <celer@scrypt.net>
+	Vince Negri <vince@bulbous.freeserve.co.uk> AntiAliasing support
+	Kailash Sethuraman (hsaliak, #netbsd@opn) NetBSD configuration/compilation fixes
+	Some other, see the About KVim dialog box in KVim...
+
+
diff --git a/src/Makefile b/src/Makefile
index d59f32a..7e4c385 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -336,6 +336,7 @@
 # use it (e.g., want a GTK-only version), then use --enable-gui=gtk.
 #
 # If the selected GUI isn't found, the GUI is disabled automatically
+#CONF_OPT_GUI = --enable-gui=kde
 #CONF_OPT_GUI = --enable-gui=gtk
 #CONF_OPT_GUI = --enable-gui=gtk --disable-gtktest
 #CONF_OPT_GUI = --enable-gui=gtk2
@@ -1041,6 +1042,35 @@
 # Without a GUI install the normal way.
 NONE_INSTALL = install_normal
 
+### KDE GUI interface.
+KDE_DIR		= $(KDE_PREFIX)
+KDE_INCL	= gui.h
+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_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/kvim_iface_skel.o
+KDE_DEFS	= -DFEAT_GUI_KDE $(NARROW_PROTO)
+KDE_IPATH	= $(GUI_INC_LOC)
+KDE_LIBS_DIR	= $(GUI_LIB_LOC)
+KDE_LIBS1	=
+KDE_LIBS2	= $(KDE_LIBNAME)
+KDE_INSTALL     = install_normal
+KDE_TARGETS	= installklinks installkdeicons
+KDE_MAN_TARGETS =
+KDE_TESTTARGET = gui
+
+#for KDE rename files to avoid confusion with gvim for GTK
+KVIMNAME	= k$(VIMNAME)
+KVIMTARGET	= $(KVIMNAME)$(LNKEXT)
+KVIEWNAME	= k$(VIEWNAME)
+KVIEWTARGET	= $(KVIEWNAME)$(LNKEXT)
+RKVIMNAME	= r$(KVIMNAME)
+RKVIMTARGET	= $(RKVIMNAME)$(LNKEXT)
+RKVIEWNAME	= r$(KVIEWNAME)
+RKVIEWTARGET	= $(RKVIEWNAME)$(LNKEXT)
+KVIMDIFFNAME	= k$(VIMDIFFNAME)
+KVIMDIFFTARGET	= $(KVIMDIFFNAME)$(LNKEXT)
+
 ### GTK GUI
 GTK_SRC		= gui.c gui_gtk.c gui_gtk_x11.c pty.c gui_gtk_f.c \
 			gui_beval.c
@@ -1170,8 +1200,8 @@
 CARBONGUI_TESTTARGET =
 
 # 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
-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
+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_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
 
 # }}}
 
@@ -1307,7 +1337,7 @@
 SRC =	$(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) $(PERL_SRC) $(PYTHON_SRC) \
 	$(TCL_SRC) $(RUBY_SRC) $(SNIFF_SRC) $(WORKSHOP_SRC) $(WSDEBUG_SRC)
 
-TAGS_SRC = *.c *.cpp if_perl.xs
+TAGS_SRC = *.c *.cpp *.cc if_perl.xs
 
 EXTRA_SRC = hangulin.c auto/if_perl.c if_perlsfio.c if_python.c if_tcl.c \
 		if_ruby.c if_sniff.c gui_beval.c \
@@ -1800,6 +1830,23 @@
 	fi
 
 # install the icons for KDE, if the directory exists and the icon doesn't.
+# doesn't.<=looks strange to install icons to user's directory ;), i add my
+# own install procedure, mikmak
+installkdeicons:
+	mkdir -p $(DESTDIR)$(KDE_DIR)/share/applnk/Editors/
+	mkdir -p $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/32x32/apps/
+	mkdir -p $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/48x48/apps/
+	mkdir -p $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/22x22/actions/
+	mkdir -p $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/16x16/actions/
+	mkdir -p $(DESTDIR)$(KDE_DIR)/share/apps/kvim
+
+	cp ../runtime/KVim.desktop $(DESTDIR)$(KDE_DIR)/share/applnk/Editors/ && chmod 644 $(DESTDIR)$(KDE_DIR)/share/applnk/Editors/KVim.desktop
+	cp ../runtime/kvim32x32.png $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/32x32/apps/kvim.png && chmod 644 $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/32x32/apps/kvim.png
+	cp ../runtime/kvim48x48.png $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/48x48/apps/kvim.png && chmod 644 $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/48x48/apps/kvim.png
+	cp ../runtime/hi16-action-make.png $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/16x16/actions/hi16-action-make.png
+	cp ../runtime/hi22-action-make.png $(DESTDIR)$(KDE_DIR)/share/icons/hicolor/22x22/actions/hi22-action-make.png
+	cp ../runtime/kde-tips $(DESTDIR)$(KDE_DIR)/share/apps/kvim/tips && chmod 644 $(DESTDIR)$(KDE_DIR)/share/apps/kvim/tips
+
 ICON48PATH = $(DESTDIR)$(DATADIR)/icons/hicolor/48x48/apps
 ICON32PATH = $(DESTDIR)$(DATADIR)/icons/locolor/32x32/apps
 ICON16PATH = $(DESTDIR)$(DATADIR)/icons/locolor/16x16/apps
@@ -1848,8 +1895,17 @@
 			$(DEST_BIN)/$(EVIEWTARGET) \
 			$(INSTALLGVIMDIFF)
 
+installklinks: $(DEST_BIN)/$(KVIMTARGET) \
+			$(DEST_BIN)/$(KVIEWTARGET) \
+			$(DEST_BIN)/$(RKVIMTARGET) \
+			$(DEST_BIN)/$(RKVIEWTARGET) \
+			$(DEST_BIN)/$(EVIMTARGET) \
+			$(DEST_BIN)/$(EVIEWTARGET) \
+			installkvimdiff
+
 installvimdiff: $(DEST_BIN)/$(VIMDIFFTARGET)
 installgvimdiff: $(DEST_BIN)/$(GVIMDIFFTARGET)
+installkvimdiff: $(DEST_BIN)/$(KVIMDIFFTARGET)
 
 $(DEST_BIN)/$(EXTARGET):
 	cd $(DEST_BIN); ln -s $(VIMTARGET) $(EXTARGET)
@@ -1863,6 +1919,12 @@
 $(DEST_BIN)/$(GVIEWTARGET):
 	cd $(DEST_BIN); ln -s $(VIMTARGET) $(GVIEWTARGET)
 
+$(DEST_BIN)/$(KVIMTARGET):
+	cd $(DEST_BIN); ln -s $(VIMTARGET) $(KVIMTARGET)
+
+$(DEST_BIN)/$(KVIEWTARGET):
+	cd $(DEST_BIN); ln -s $(VIMTARGET) $(KVIEWTARGET)
+
 $(DEST_BIN)/$(RVIMTARGET):
 	cd $(DEST_BIN); ln -s $(VIMTARGET) $(RVIMTARGET)
 
@@ -1875,12 +1937,21 @@
 $(DEST_BIN)/$(RGVIEWTARGET):
 	cd $(DEST_BIN); ln -s $(VIMTARGET) $(RGVIEWTARGET)
 
+$(DEST_BIN)/$(RKVIMTARGET):
+	cd $(DEST_BIN); ln -s $(VIMTARGET) $(RKVIMTARGET)
+
+$(DEST_BIN)/$(RKVIEWTARGET):
+	cd $(DEST_BIN); ln -s $(VIMTARGET) $(RKVIEWTARGET)
+
 $(DEST_BIN)/$(VIMDIFFTARGET):
 	cd $(DEST_BIN); ln -s $(VIMTARGET) $(VIMDIFFTARGET)
 
 $(DEST_BIN)/$(GVIMDIFFTARGET):
 	cd $(DEST_BIN); ln -s $(VIMTARGET) $(GVIMDIFFTARGET)
 
+$(DEST_BIN)/$(KVIMDIFFTARGET):
+	cd $(DEST_BIN); ln -s $(VIMTARGET) $(KVIMDIFFTARGET)
+
 $(DEST_BIN)/$(EVIMTARGET):
 	cd $(DEST_BIN); ln -s $(VIMTARGET) $(EVIMTARGET)
 
@@ -1895,7 +1966,7 @@
 			$(DEST_MAN)/$(RVIMNAME).1 \
 			$(DEST_MAN)/$(RVIEWNAME).1
 
-installghelplinks: $(DEST_MAN)/$(GVIMNAME).1 \
+installghelplinks installkhelplinks : $(DEST_MAN)/$(GVIMNAME).1 \
 			$(DEST_MAN)/$(GVIEWNAME).1 \
 			$(DEST_MAN)/$(RGVIMNAME).1 \
 			$(DEST_MAN)/$(RGVIEWNAME).1 \
@@ -1939,9 +2010,12 @@
 	-rm -f $(DEST_BIN)/xxd$(EXEEXT) $(DEST_MAN)/xxd.1
 	-rm -f $(DEST_BIN)/$(EXTARGET) $(DEST_BIN)/$(VIEWTARGET)
 	-rm -f $(DEST_BIN)/$(GVIMTARGET) $(DEST_BIN)/$(GVIEWTARGET)
+	-rm -f $(DEST_BIN)/$(KVIMTARGET) $(DEST_BIN)/$(KVIEWTARGET)
 	-rm -f $(DEST_BIN)/$(RVIMTARGET) $(DEST_BIN)/$(RVIEWTARGET)
 	-rm -f $(DEST_BIN)/$(RGVIMTARGET) $(DEST_BIN)/$(RGVIEWTARGET)
+	-rm -f $(DEST_BIN)/$(RKVIMTARGET) $(DEST_BIN)/$(RKVIEWTARGET)
 	-rm -f $(DEST_BIN)/$(VIMDIFFTARGET) $(DEST_BIN)/$(GVIMDIFFTARGET)
+	-rm -f $(DEST_BIN)/$(VIMDIFFTARGET) $(DEST_BIN)/$(KVIMDIFFTARGET)
 	-rm -f $(DEST_BIN)/$(EVIMTARGET) $(DEST_BIN)/$(EVIEWTARGET)
 	-rm -f $(DEST_MAN)/$(EXNAME).1 $(DEST_MAN)/$(VIEWNAME).1
 	-rm -f $(DEST_MAN)/$(GVIMNAME).1 $(DEST_MAN)/$(GVIEWNAME).1
@@ -1984,6 +2058,7 @@
 	-rm -f *.o objects/* core $(VIMTARGET).core $(VIMTARGET) xxd/*.o
 	-rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c
 	-rm -f conftest* *~ auto/link.sed
+	-rm -f gui_kde_widget_moc.cc kvim_iface_skel.cc *.kidl
 	if test -d $(PODIR); then \
 		cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) clean; \
 	fi
@@ -2326,6 +2401,24 @@
 objects/wsdebug.o: wsdebug.c
 	$(CCC) -o $@ wsdebug.c
 
+objects/gui_kde.o: gui_kde.cc
+	$(CCC) -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
+	$(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
+
+objects/gui_kde_widget_moc.o: gui_kde_widget_moc.cc
+	$(CCC) -o $@ gui_kde_widget_moc.cc
+
+objects/kvim_iface_skel.o: kvim_iface_skel.cc
+	$(CCC) -o $@ kvim_iface_skel.cc
+
 objects/netbeans.o: netbeans.c
 	$(CCC) -o $@ netbeans.c
 
@@ -2637,6 +2730,24 @@
  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 \
+ 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 \
+ 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 \
+ 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 \
+ 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
 objects/hangulin.o: hangulin.c 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 gui_beval.h proto/gui_beval.pro option.h ex_cmds.h proto.h \
diff --git a/src/auto/configure b/src/auto/configure
index b040a75..e9e5637 100755
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -62,7 +62,9 @@
 ac_help="$ac_help
   --with-x                use the X Window System"
 ac_help="$ac_help
-  --enable-gui[=OPTS]     X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/motif/athena/neXtaw/beos/photon/carbon]"
+  --enable-gui[=OPTS]     X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/kde/motif/athena/neXtaw/beos/photon/carbon]"
+ac_help="$ac_help
+  --enable-kde-check      If auto-select GUI, check for KDE [default=no]"
 ac_help="$ac_help
   --enable-gtk-check      If auto-select GUI, check for GTK [default=yes]"
 ac_help="$ac_help
@@ -78,6 +80,24 @@
 ac_help="$ac_help
   --enable-carbon-check   If auto-select GUI, check for Carbon [default=yes]"
 ac_help="$ac_help
+  --with-qt-dir=DIR	Specify prefix of QT files"
+ac_help="$ac_help
+  --with-qt-includes=DIR	Specify location of Qt headers"
+ac_help="$ac_help
+  --with-qt-libs=DIR	Specify location of Qt libraries"
+ac_help="$ac_help
+  --enable-kde-toolbar   if KDE GUI is selected, enable a KDE-look toolbar [default=no]"
+ac_help="$ac_help
+  --disable-rpath      Disable rpath."
+ac_help="$ac_help
+  --with-kde-prefix=PFX	Prefix where KDE is installed (optional)"
+ac_help="$ac_help
+  --with-kde-includes=DIR	Specify location of KDE headers"
+ac_help="$ac_help
+  --with-kde-libs=DIR	Specify location of KDE libraries"
+ac_help="$ac_help
+  --disable-kdetest	Do not try to compile and run a test KDE program"
+ac_help="$ac_help
   --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)"
 ac_help="$ac_help
   --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)"
@@ -616,7 +636,7 @@
 EOF
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:620: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:640: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -646,7 +666,7 @@
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:650: checking for $ac_word" >&5
+echo "configure:670: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -676,7 +696,7 @@
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:680: checking for $ac_word" >&5
+echo "configure:700: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -727,7 +747,7 @@
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:731: checking for $ac_word" >&5
+echo "configure:751: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -759,7 +779,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:763: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:783: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -770,12 +790,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 774 "configure"
+#line 794 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:799: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -801,12 +821,12 @@
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:805: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:825: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:810: checking whether we are using GNU C" >&5
+echo "configure:830: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -815,7 +835,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:819: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:839: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -834,7 +854,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:838: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:858: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -865,7 +885,7 @@
   fi
 fi
 	echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:869: checking how to run the C preprocessor" >&5
+echo "configure:889: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -880,13 +900,13 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 884 "configure"
+#line 904 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:890: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:910: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -897,13 +917,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 901 "configure"
+#line 921 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:907: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:927: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -914,13 +934,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 918 "configure"
+#line 938 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:924: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:944: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -944,7 +964,7 @@
 fi
 echo "$ac_t""$CPP" 1>&6
 	cat > conftest.$ac_ext <<EOF
-#line 948 "configure"
+#line 968 "configure"
 #include "confdefs.h"
 
 EOF
@@ -954,7 +974,7 @@
 fi
 rm -f conftest*
  echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:958: checking for POSIXized ISC" >&5
+echo "configure:978: checking for POSIXized ISC" >&5
 if test -d /etc/conf/kconfig.d &&
   grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
 then
@@ -978,7 +998,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:982: checking for $ac_word" >&5
+echo "configure:1002: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1010,7 +1030,7 @@
 # Extract the first word of "strip", so it can be a program name with args.
 set dummy strip; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1014: checking for $ac_word" >&5
+echo "configure:1034: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1039,12 +1059,12 @@
 
 
 echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
-echo "configure:1043: checking for Cygwin environment" >&5
+echo "configure:1063: checking for Cygwin environment" >&5
 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1048 "configure"
+#line 1068 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1055,7 +1075,7 @@
 return __CYGWIN__;
 ; return 0; }
 EOF
-if { (eval echo configure:1059: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1079: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_cygwin=yes
 else
@@ -1072,19 +1092,19 @@
 CYGWIN=
 test "$ac_cv_cygwin" = yes && CYGWIN=yes
 echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
-echo "configure:1076: checking for mingw32 environment" >&5
+echo "configure:1096: checking for mingw32 environment" >&5
 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1081 "configure"
+#line 1101 "configure"
 #include "confdefs.h"
 
 int main() {
 return __MINGW32__;
 ; return 0; }
 EOF
-if { (eval echo configure:1088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1108: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_mingw32=yes
 else
@@ -1103,7 +1123,7 @@
 
 
 echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
-echo "configure:1107: checking for executable suffix" >&5
+echo "configure:1127: checking for executable suffix" >&5
 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1113,7 +1133,7 @@
   rm -f conftest*
   echo 'int main () { return 0; }' > conftest.$ac_ext
   ac_cv_exeext=
-  if { (eval echo configure:1117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+  if { (eval echo configure:1137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
     for file in conftest.*; do
       case $file in
       *.c | *.o | *.obj) ;;
@@ -1160,14 +1180,14 @@
 
 if test -f ./toolcheck; then
   echo "checking for buggy tools" 1>&6
-echo "configure:1164: checking for buggy tools" >&5
+echo "configure:1184: checking for buggy tools" >&5
   sh ./toolcheck 1>&6
 fi
 
 OS_EXTRA_SRC=""; OS_EXTRA_OBJ=""
 
 echo $ac_n "checking for BeOS""... $ac_c" 1>&6
-echo "configure:1171: checking for BeOS" >&5
+echo "configure:1191: checking for BeOS" >&5
 case `uname` in
     BeOS)	OS_EXTRA_SRC=os_beos.c; OS_EXTRA_OBJ=objects/os_beos.o
 		BEOS=yes; echo "$ac_t""yes" 1>&6;;
@@ -1175,7 +1195,7 @@
 esac
 
 echo $ac_n "checking for QNX""... $ac_c" 1>&6
-echo "configure:1179: checking for QNX" >&5
+echo "configure:1199: checking for QNX" >&5
 case `uname` in
     QNX)	OS_EXTRA_SRC=os_qnx.c; OS_EXTRA_OBJ=objects/os_qnx.o
 		test -z "$with_x" && with_x=no
@@ -1185,12 +1205,12 @@
 
 DEFAULT_VIMNAME=vim
 echo $ac_n "checking for Darwin (Mac OS X)""... $ac_c" 1>&6
-echo "configure:1189: checking for Darwin (Mac OS X)" >&5
+echo "configure:1209: checking for Darwin (Mac OS X)" >&5
 if test "`(uname) 2>/dev/null`" = Darwin; then
   echo "$ac_t""yes" 1>&6
 
   echo $ac_n "checking --disable-darwin argument""... $ac_c" 1>&6
-echo "configure:1194: checking --disable-darwin argument" >&5
+echo "configure:1214: checking --disable-darwin argument" >&5
   # Check whether --enable-darwin or --disable-darwin was given.
 if test "${enable_darwin+set}" = set; then
   enableval="$enable_darwin"
@@ -1202,7 +1222,7 @@
   if test "$enable_darwin" = "yes"; then
     echo "$ac_t""no" 1>&6
     echo $ac_n "checking if Darwin files are there""... $ac_c" 1>&6
-echo "configure:1206: checking if Darwin files are there" >&5
+echo "configure:1226: checking if Darwin files are there" >&5
     if test -f os_macosx.c; then
       echo "$ac_t""yes" 1>&6
     else
@@ -1221,17 +1241,17 @@
 
             ac_safe=`echo "Carbon/Carbon.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for Carbon/Carbon.h""... $ac_c" 1>&6
-echo "configure:1225: checking for Carbon/Carbon.h" >&5
+echo "configure:1245: checking for Carbon/Carbon.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1230 "configure"
+#line 1250 "configure"
 #include "confdefs.h"
 #include <Carbon/Carbon.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1235: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1255: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1288,7 +1308,7 @@
 fi
 
 echo $ac_n "checking --with-vim-name argument""... $ac_c" 1>&6
-echo "configure:1292: checking --with-vim-name argument" >&5
+echo "configure:1312: checking --with-vim-name argument" >&5
 # Check whether --with-vim-name or --without-vim-name was given.
 if test "${with_vim_name+set}" = set; then
   withval="$with_vim_name"
@@ -1299,7 +1319,7 @@
 
 
 echo $ac_n "checking --with-ex-name argument""... $ac_c" 1>&6
-echo "configure:1303: checking --with-ex-name argument" >&5
+echo "configure:1323: checking --with-ex-name argument" >&5
 # Check whether --with-ex-name or --without-ex-name was given.
 if test "${with_ex_name+set}" = set; then
   withval="$with_ex_name"
@@ -1310,7 +1330,7 @@
 
 
 echo $ac_n "checking --with-view-name argument""... $ac_c" 1>&6
-echo "configure:1314: checking --with-view-name argument" >&5
+echo "configure:1334: checking --with-view-name argument" >&5
 # Check whether --with-view-name or --without-view-name was given.
 if test "${with_view_name+set}" = set; then
   withval="$with_view_name"
@@ -1322,7 +1342,7 @@
 
 
 echo $ac_n "checking --with-global-runtime argument""... $ac_c" 1>&6
-echo "configure:1326: checking --with-global-runtime argument" >&5
+echo "configure:1346: checking --with-global-runtime argument" >&5
 # Check whether --with-global-runtime or --without-global-runtime was given.
 if test "${with_global_runtime+set}" = set; then
   withval="$with_global_runtime"
@@ -1336,7 +1356,7 @@
 
 
 echo $ac_n "checking --with-modified-by argument""... $ac_c" 1>&6
-echo "configure:1340: checking --with-modified-by argument" >&5
+echo "configure:1360: checking --with-modified-by argument" >&5
 # Check whether --with-modified-by or --without-modified-by was given.
 if test "${with_modified_by+set}" = set; then
   withval="$with_modified_by"
@@ -1350,9 +1370,9 @@
 
 
 echo $ac_n "checking if character set is EBCDIC""... $ac_c" 1>&6
-echo "configure:1354: checking if character set is EBCDIC" >&5
+echo "configure:1374: checking if character set is EBCDIC" >&5
 cat > conftest.$ac_ext <<EOF
-#line 1356 "configure"
+#line 1376 "configure"
 #include "confdefs.h"
  
 int main() {
@@ -1365,7 +1385,7 @@
 #endif 
 ; return 0; }
 EOF
-if { (eval echo configure:1369: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1389: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
    # TryCompile action if true
 cf_cv_ebcdic=yes 
@@ -1393,7 +1413,7 @@
 
 if test "$cf_cv_ebcdic" = "yes"; then
 echo $ac_n "checking for OS/390 Unix""... $ac_c" 1>&6
-echo "configure:1397: checking for OS/390 Unix" >&5
+echo "configure:1417: checking for OS/390 Unix" >&5
 case `uname` in
     OS/390)	OS390Unix="yes";
 										if test "$CC" = "cc"; then
@@ -1430,7 +1450,7 @@
 
 
 echo $ac_n "checking --with-features argument""... $ac_c" 1>&6
-echo "configure:1434: checking --with-features argument" >&5
+echo "configure:1454: checking --with-features argument" >&5
 # Check whether --with-features or --without-features was given.
 if test "${with_features+set}" = set; then
   withval="$with_features"
@@ -1473,7 +1493,7 @@
 
 
 echo $ac_n "checking --with-compiledby argument""... $ac_c" 1>&6
-echo "configure:1477: checking --with-compiledby argument" >&5
+echo "configure:1497: checking --with-compiledby argument" >&5
 # Check whether --with-compiledby or --without-compiledby was given.
 if test "${with_compiledby+set}" = set; then
   withval="$with_compiledby"
@@ -1485,7 +1505,7 @@
 
 
 echo $ac_n "checking --disable-xsmp argument""... $ac_c" 1>&6
-echo "configure:1489: checking --disable-xsmp argument" >&5
+echo "configure:1509: checking --disable-xsmp argument" >&5
 # Check whether --enable-xsmp or --disable-xsmp was given.
 if test "${enable_xsmp+set}" = set; then
   enableval="$enable_xsmp"
@@ -1498,7 +1518,7 @@
 if test "$enable_xsmp" = "yes"; then
   echo "$ac_t""no" 1>&6
   echo $ac_n "checking --disable-xsmp-interact argument""... $ac_c" 1>&6
-echo "configure:1502: checking --disable-xsmp-interact argument" >&5
+echo "configure:1522: checking --disable-xsmp-interact argument" >&5
   # Check whether --enable-xsmp-interact or --disable-xsmp-interact was given.
 if test "${enable_xsmp_interact+set}" = set; then
   enableval="$enable_xsmp_interact"
@@ -1521,7 +1541,7 @@
 fi
 
 echo $ac_n "checking --enable-perlinterp argument""... $ac_c" 1>&6
-echo "configure:1525: checking --enable-perlinterp argument" >&5
+echo "configure:1545: checking --enable-perlinterp argument" >&5
 # Check whether --enable-perlinterp or --disable-perlinterp was given.
 if test "${enable_perlinterp+set}" = set; then
   enableval="$enable_perlinterp"
@@ -1536,7 +1556,7 @@
   # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1540: checking for $ac_word" >&5
+echo "configure:1560: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_perl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1570,7 +1590,7 @@
 
   if test "X$vi_cv_path_perl" != "X"; then
     echo $ac_n "checking Perl version""... $ac_c" 1>&6
-echo "configure:1574: checking Perl version" >&5
+echo "configure:1594: checking Perl version" >&5
     if $vi_cv_path_perl -e 'require 5.003_01' >/dev/null 2>/dev/null; then
      eval `$vi_cv_path_perl -V:usethreads`
      if test "X$usethreads" = "XUNKNOWN" -o "X$usethreads" = "Xundef"; then
@@ -1606,7 +1626,7 @@
 		-e 'ccdlflags' | sed -e 's/-bE:perl.exp//'`
 
                   echo $ac_n "checking if compile and link flags for Perl are sane""... $ac_c" 1>&6
-echo "configure:1610: checking if compile and link flags for Perl are sane" >&5
+echo "configure:1630: checking if compile and link flags for Perl are sane" >&5
       cflags_save=$CFLAGS
       libs_save=$LIBS
       ldflags_save=$LDFLAGS
@@ -1614,14 +1634,14 @@
       LIBS="$LIBS $perllibs"
       LDFLAGS="$perlldflags $LDFLAGS"
       cat > conftest.$ac_ext <<EOF
-#line 1618 "configure"
+#line 1638 "configure"
 #include "confdefs.h"
 
 int main() {
  
 ; return 0; }
 EOF
-if { (eval echo configure:1625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; perl_ok=yes
 else
@@ -1684,7 +1704,7 @@
 
 
 echo $ac_n "checking --enable-pythoninterp argument""... $ac_c" 1>&6
-echo "configure:1688: checking --enable-pythoninterp argument" >&5
+echo "configure:1708: checking --enable-pythoninterp argument" >&5
 # Check whether --enable-pythoninterp or --disable-pythoninterp was given.
 if test "${enable_pythoninterp+set}" = set; then
   enableval="$enable_pythoninterp"
@@ -1698,7 +1718,7 @@
     # Extract the first word of "python", so it can be a program name with args.
 set dummy python; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1702: checking for $ac_word" >&5
+echo "configure:1722: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_python'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1733,7 +1753,7 @@
   if test "X$vi_cv_path_python" != "X"; then
 
         echo $ac_n "checking Python version""... $ac_c" 1>&6
-echo "configure:1737: checking Python version" >&5
+echo "configure:1757: checking Python version" >&5
 if eval "test \"`echo '$''{'vi_cv_var_python_version'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1745,14 +1765,14 @@
 echo "$ac_t""$vi_cv_var_python_version" 1>&6
 
         echo $ac_n "checking Python is 1.4 or better""... $ac_c" 1>&6
-echo "configure:1749: checking Python is 1.4 or better" >&5
+echo "configure:1769: checking Python is 1.4 or better" >&5
     if ${vi_cv_path_python} -c \
 	"import sys; sys.exit(${vi_cv_var_python_version} < 1.4)"
     then
       echo "$ac_t""yep" 1>&6
 
             echo $ac_n "checking Python's install prefix""... $ac_c" 1>&6
-echo "configure:1756: checking Python's install prefix" >&5
+echo "configure:1776: checking Python's install prefix" >&5
 if eval "test \"`echo '$''{'vi_cv_path_python_pfx'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1764,7 +1784,7 @@
 echo "$ac_t""$vi_cv_path_python_pfx" 1>&6
 
             echo $ac_n "checking Python's execution prefix""... $ac_c" 1>&6
-echo "configure:1768: checking Python's execution prefix" >&5
+echo "configure:1788: checking Python's execution prefix" >&5
 if eval "test \"`echo '$''{'vi_cv_path_python_epfx'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1795,7 +1815,7 @@
 
 
       echo $ac_n "checking Python's configuration directory""... $ac_c" 1>&6
-echo "configure:1799: checking Python's configuration directory" >&5
+echo "configure:1819: checking Python's configuration directory" >&5
 if eval "test \"`echo '$''{'vi_cv_path_python_conf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1868,7 +1888,7 @@
 	PYTHON_GETPATH_CFLAGS="-DPYTHONPATH='\"${vi_cv_path_pythonpath}\"' -DPREFIX='\"${vi_cv_path_python_pfx}\"' -DEXEC_PREFIX='\"${vi_cv_path_python_epfx}\"'"
 
 								echo $ac_n "checking if -pthread should be used""... $ac_c" 1>&6
-echo "configure:1872: checking if -pthread should be used" >&5
+echo "configure:1892: checking if -pthread should be used" >&5
 	threadsafe_flag=
 	thread_lib=
 	if test "x$MACOSX" != "xyes"; then
@@ -1884,14 +1904,14 @@
 	  CFLAGS="$CFLAGS $threadsafe_flag"
 	  LIBS="$LIBS $thread_lib"
 	  cat > conftest.$ac_ext <<EOF
-#line 1888 "configure"
+#line 1908 "configure"
 #include "confdefs.h"
 
 int main() {
  
 ; return 0; }
 EOF
-if { (eval echo configure:1895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; PYTHON_CFLAGS="$PYTHON_CFLAGS $threadsafe_flag"
 else
@@ -1908,20 +1928,20 @@
 	fi
 
 			echo $ac_n "checking if compile and link flags for Python are sane""... $ac_c" 1>&6
-echo "configure:1912: checking if compile and link flags for Python are sane" >&5
+echo "configure:1932: checking if compile and link flags for Python are sane" >&5
 	cflags_save=$CFLAGS
 	libs_save=$LIBS
 	CFLAGS="$CFLAGS $PYTHON_CFLAGS"
 	LIBS="$LIBS $PYTHON_LIBS"
 	cat > conftest.$ac_ext <<EOF
-#line 1918 "configure"
+#line 1938 "configure"
 #include "confdefs.h"
 
 int main() {
  
 ; return 0; }
 EOF
-if { (eval echo configure:1925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; python_ok=yes
 else
@@ -1960,7 +1980,7 @@
 
 
 echo $ac_n "checking --enable-tclinterp argument""... $ac_c" 1>&6
-echo "configure:1964: checking --enable-tclinterp argument" >&5
+echo "configure:1984: checking --enable-tclinterp argument" >&5
 # Check whether --enable-tclinterp or --disable-tclinterp was given.
 if test "${enable_tclinterp+set}" = set; then
   enableval="$enable_tclinterp"
@@ -1974,7 +1994,7 @@
 if test "$enable_tclinterp" = "yes"; then
 
     echo $ac_n "checking --with-tclsh argument""... $ac_c" 1>&6
-echo "configure:1978: checking --with-tclsh argument" >&5
+echo "configure:1998: checking --with-tclsh argument" >&5
   # Check whether --with-tclsh or --without-tclsh was given.
 if test "${with_tclsh+set}" = set; then
   withval="$with_tclsh"
@@ -1986,7 +2006,7 @@
   # Extract the first word of "$tclsh_name", so it can be a program name with args.
 set dummy $tclsh_name; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1990: checking for $ac_word" >&5
+echo "configure:2010: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_tcl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2025,7 +2045,7 @@
     # Extract the first word of "$tclsh_name", so it can be a program name with args.
 set dummy $tclsh_name; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2029: checking for $ac_word" >&5
+echo "configure:2049: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_tcl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2063,7 +2083,7 @@
     # Extract the first word of "$tclsh_name", so it can be a program name with args.
 set dummy $tclsh_name; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2067: checking for $ac_word" >&5
+echo "configure:2087: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_tcl'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2098,14 +2118,14 @@
   fi
   if test "X$vi_cv_path_tcl" != "X"; then
     echo $ac_n "checking Tcl version""... $ac_c" 1>&6
-echo "configure:2102: checking Tcl version" >&5
+echo "configure:2122: checking Tcl version" >&5
     if echo 'exit [expr [info tclversion] < 8.0]' | $vi_cv_path_tcl - ; then
       tclver=`echo 'puts [info tclversion]' | $vi_cv_path_tcl -`
       echo "$ac_t""$tclver - OK" 1>&6;
       tclloc=`echo 'set l [info library];set i [string last lib $l];incr i -2;puts [string range $l 0 $i]' | $vi_cv_path_tcl -`
 
       echo $ac_n "checking for location of Tcl include""... $ac_c" 1>&6
-echo "configure:2109: checking for location of Tcl include" >&5
+echo "configure:2129: checking for location of Tcl include" >&5
       if test "x$MACOSX" != "xyes"; then
 	tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include"
       else
@@ -2124,7 +2144,7 @@
       fi
       if test -z "$SKIP_TCL"; then
 	echo $ac_n "checking for location of tclConfig.sh script""... $ac_c" 1>&6
-echo "configure:2128: checking for location of tclConfig.sh script" >&5
+echo "configure:2148: checking for location of tclConfig.sh script" >&5
 	if test "x$MACOSX" != "xyes"; then
 	  tclcnf=`echo $tclinc | sed s/include/lib/g`
 	else
@@ -2142,7 +2162,7 @@
 	if test -z "$TCL_LIBS"; then
 	  echo "$ac_t""<not found>" 1>&6
 	  echo $ac_n "checking for Tcl library by myself""... $ac_c" 1>&6
-echo "configure:2146: checking for Tcl library by myself" >&5
+echo "configure:2166: checking for Tcl library by myself" >&5
 	  tcllib=`echo $tclinc | sed s/include/lib/g`
 	  for ext in .so .a ; do
 	    for ver in "" $tclver ; do
@@ -2188,7 +2208,7 @@
 
 
 echo $ac_n "checking --enable-rubyinterp argument""... $ac_c" 1>&6
-echo "configure:2192: checking --enable-rubyinterp argument" >&5
+echo "configure:2212: checking --enable-rubyinterp argument" >&5
 # Check whether --enable-rubyinterp or --disable-rubyinterp was given.
 if test "${enable_rubyinterp+set}" = set; then
   enableval="$enable_rubyinterp"
@@ -2203,7 +2223,7 @@
   # Extract the first word of "ruby", so it can be a program name with args.
 set dummy ruby; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2207: checking for $ac_word" >&5
+echo "configure:2227: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_vi_cv_path_ruby'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2237,11 +2257,11 @@
 
   if test "X$vi_cv_path_ruby" != "X"; then
     echo $ac_n "checking Ruby version""... $ac_c" 1>&6
-echo "configure:2241: checking Ruby version" >&5
+echo "configure:2261: checking Ruby version" >&5
     if $vi_cv_path_ruby -e 'VERSION >= "1.6.0" or exit 1' >/dev/null 2>/dev/null; then
       echo "$ac_t""OK" 1>&6
       echo $ac_n "checking Ruby header files""... $ac_c" 1>&6
-echo "configure:2245: checking Ruby header files" >&5
+echo "configure:2265: checking Ruby header files" >&5
       rubyhdrdir=`$vi_cv_path_ruby -r mkmf -e 'print Config::CONFIG["archdir"] || $hdrdir' 2>/dev/null`
       if test "X$rubyhdrdir" != "X"; then
 	echo "$ac_t""$rubyhdrdir" 1>&6
@@ -2293,7 +2313,7 @@
 
 
 echo $ac_n "checking --enable-cscope argument""... $ac_c" 1>&6
-echo "configure:2297: checking --enable-cscope argument" >&5
+echo "configure:2317: checking --enable-cscope argument" >&5
 # Check whether --enable-cscope or --disable-cscope was given.
 if test "${enable_cscope+set}" = set; then
   enableval="$enable_cscope"
@@ -2311,7 +2331,7 @@
 fi
 
 echo $ac_n "checking --enable-workshop argument""... $ac_c" 1>&6
-echo "configure:2315: checking --enable-workshop argument" >&5
+echo "configure:2335: checking --enable-workshop argument" >&5
 # Check whether --enable-workshop or --disable-workshop was given.
 if test "${enable_workshop+set}" = set; then
   enableval="$enable_workshop"
@@ -2336,7 +2356,7 @@
 fi
 
 echo $ac_n "checking --disable-netbeans argument""... $ac_c" 1>&6
-echo "configure:2340: checking --disable-netbeans argument" >&5
+echo "configure:2360: checking --disable-netbeans argument" >&5
 # Check whether --enable-netbeans or --disable-netbeans was given.
 if test "${enable_netbeans+set}" = set; then
   enableval="$enable_netbeans"
@@ -2348,7 +2368,7 @@
 if test "$enable_netbeans" = "yes"; then
   echo "$ac_t""no" 1>&6
     echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:2352: checking for socket in -lsocket" >&5
+echo "configure:2372: checking for socket in -lsocket" >&5
 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2356,7 +2376,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2360 "configure"
+#line 2380 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2367,7 +2387,7 @@
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:2371: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2395,7 +2415,7 @@
 fi
 
   echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:2399: checking for gethostbyname in -lnsl" >&5
+echo "configure:2419: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2403,7 +2423,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2407 "configure"
+#line 2427 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2414,7 +2434,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:2418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2438: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2442,9 +2462,9 @@
 fi
 
   echo $ac_n "checking whether compiling netbeans integration is possible""... $ac_c" 1>&6
-echo "configure:2446: checking whether compiling netbeans integration is possible" >&5
+echo "configure:2466: checking whether compiling netbeans integration is possible" >&5
   cat > conftest.$ac_ext <<EOF
-#line 2448 "configure"
+#line 2468 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -2474,7 +2494,7 @@
 	    
 ; return 0; }
 EOF
-if { (eval echo configure:2478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -2499,7 +2519,7 @@
 fi
 
 echo $ac_n "checking --enable-sniff argument""... $ac_c" 1>&6
-echo "configure:2503: checking --enable-sniff argument" >&5
+echo "configure:2523: checking --enable-sniff argument" >&5
 # Check whether --enable-sniff or --disable-sniff was given.
 if test "${enable_sniff+set}" = set; then
   enableval="$enable_sniff"
@@ -2521,7 +2541,7 @@
 fi
 
 echo $ac_n "checking --enable-multibyte argument""... $ac_c" 1>&6
-echo "configure:2525: checking --enable-multibyte argument" >&5
+echo "configure:2545: checking --enable-multibyte argument" >&5
 # Check whether --enable-multibyte or --disable-multibyte was given.
 if test "${enable_multibyte+set}" = set; then
   enableval="$enable_multibyte"
@@ -2539,7 +2559,7 @@
 fi
 
 echo $ac_n "checking --enable-hangulinput argument""... $ac_c" 1>&6
-echo "configure:2543: checking --enable-hangulinput argument" >&5
+echo "configure:2563: checking --enable-hangulinput argument" >&5
 # Check whether --enable-hangulinput or --disable-hangulinput was given.
 if test "${enable_hangulinput+set}" = set; then
   enableval="$enable_hangulinput"
@@ -2551,7 +2571,7 @@
 echo "$ac_t""$enable_hangulinput" 1>&6
 
 echo $ac_n "checking --enable-xim argument""... $ac_c" 1>&6
-echo "configure:2555: checking --enable-xim argument" >&5
+echo "configure:2575: checking --enable-xim argument" >&5
 # Check whether --enable-xim or --disable-xim was given.
 if test "${enable_xim+set}" = set; then
   enableval="$enable_xim"
@@ -2562,7 +2582,7 @@
 
 
 echo $ac_n "checking --enable-fontset argument""... $ac_c" 1>&6
-echo "configure:2566: checking --enable-fontset argument" >&5
+echo "configure:2586: checking --enable-fontset argument" >&5
 # Check whether --enable-fontset or --disable-fontset was given.
 if test "${enable_fontset+set}" = set; then
   enableval="$enable_fontset"
@@ -2582,7 +2602,7 @@
   # Extract the first word of "xmkmf", so it can be a program name with args.
 set dummy xmkmf; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2586: checking for $ac_word" >&5
+echo "configure:2606: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_xmkmfpath'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2620,7 +2640,7 @@
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:2624: checking for X" >&5
+echo "configure:2644: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -2682,12 +2702,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 2686 "configure"
+#line 2706 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2691: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2711: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2756,14 +2776,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2760 "configure"
+#line 2780 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:2767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -2869,17 +2889,17 @@
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:2873: checking whether -R must be followed by a space" >&5
+echo "configure:2893: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 2876 "configure"
+#line 2896 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2883: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2903: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -2895,14 +2915,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 2899 "configure"
+#line 2919 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:2906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -2934,7 +2954,7 @@
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:2938: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:2958: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2942,7 +2962,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2946 "configure"
+#line 2966 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2953,7 +2973,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:2957: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2975,7 +2995,7 @@
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:2979: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:2999: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2983,7 +3003,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2987 "configure"
+#line 3007 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -2994,7 +3014,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:2998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3023,12 +3043,12 @@
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:3027: checking for gethostbyname" >&5
+echo "configure:3047: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3032 "configure"
+#line 3052 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -3051,7 +3071,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -3072,7 +3092,7 @@
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:3076: checking for gethostbyname in -lnsl" >&5
+echo "configure:3096: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3080,7 +3100,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3084 "configure"
+#line 3104 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3091,7 +3111,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:3095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3121,12 +3141,12 @@
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:3125: checking for connect" >&5
+echo "configure:3145: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3130 "configure"
+#line 3150 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -3149,7 +3169,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3173: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -3170,7 +3190,7 @@
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:3174: checking for connect in -lsocket" >&5
+echo "configure:3194: checking for connect in -lsocket" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3178,7 +3198,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3182 "configure"
+#line 3202 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3189,7 +3209,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:3193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3213: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3213,12 +3233,12 @@
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:3217: checking for remove" >&5
+echo "configure:3237: checking for remove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3222 "configure"
+#line 3242 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -3241,7 +3261,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -3262,7 +3282,7 @@
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:3266: checking for remove in -lposix" >&5
+echo "configure:3286: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3270,7 +3290,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3274 "configure"
+#line 3294 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3281,7 +3301,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:3285: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3305: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3305,12 +3325,12 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:3309: checking for shmat" >&5
+echo "configure:3329: checking for shmat" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3314 "configure"
+#line 3334 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -3333,7 +3353,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3357: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -3354,7 +3374,7 @@
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:3358: checking for shmat in -lipc" >&5
+echo "configure:3378: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3362,7 +3382,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3366 "configure"
+#line 3386 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3373,7 +3393,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:3377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3406,7 +3426,7 @@
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:3410: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:3430: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3414,7 +3434,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lICE $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3418 "configure"
+#line 3438 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3425,7 +3445,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:3429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3479,18 +3499,18 @@
 
 
       echo $ac_n "checking if X11 header files can be found""... $ac_c" 1>&6
-echo "configure:3483: checking if X11 header files can be found" >&5
+echo "configure:3503: checking if X11 header files can be found" >&5
   cflags_save=$CFLAGS
   CFLAGS="$CFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 3487 "configure"
+#line 3507 "configure"
 #include "confdefs.h"
 #include <X11/Xlib.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3494: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3514: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -3516,7 +3536,7 @@
     LDFLAGS="-L$x_libraries $LDFLAGS"
 
             echo $ac_n "checking for _XdmcpAuthDoIt in -lXdmcp""... $ac_c" 1>&6
-echo "configure:3520: checking for _XdmcpAuthDoIt in -lXdmcp" >&5
+echo "configure:3540: checking for _XdmcpAuthDoIt in -lXdmcp" >&5
 ac_lib_var=`echo Xdmcp'_'_XdmcpAuthDoIt | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3524,7 +3544,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXdmcp -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lXdmcp $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3528 "configure"
+#line 3548 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3535,7 +3555,7 @@
 _XdmcpAuthDoIt()
 ; return 0; }
 EOF
-if { (eval echo configure:3539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3557,7 +3577,7 @@
 
 
                     echo $ac_n "checking for IceOpenConnection in -lICE""... $ac_c" 1>&6
-echo "configure:3561: checking for IceOpenConnection in -lICE" >&5
+echo "configure:3581: checking for IceOpenConnection in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceOpenConnection | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3565,7 +3585,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lICE $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3569 "configure"
+#line 3589 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3576,7 +3596,7 @@
 IceOpenConnection()
 ; return 0; }
 EOF
-if { (eval echo configure:3580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3599,7 +3619,7 @@
 
         LDFLAGS="$X_LIBS $ac_save_LDFLAGS"
     echo $ac_n "checking for XpmCreatePixmapFromData in -lXpm""... $ac_c" 1>&6
-echo "configure:3603: checking for XpmCreatePixmapFromData in -lXpm" >&5
+echo "configure:3623: checking for XpmCreatePixmapFromData in -lXpm" >&5
 ac_lib_var=`echo Xpm'_'XpmCreatePixmapFromData | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3607,7 +3627,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXpm -lXt $X_PRE_LIBS -lXpm -lX11 $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3611 "configure"
+#line 3631 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3618,7 +3638,7 @@
 XpmCreatePixmapFromData()
 ; return 0; }
 EOF
-if { (eval echo configure:3622: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3640,18 +3660,18 @@
 
 
         echo $ac_n "checking if X11 header files implicitly declare return values""... $ac_c" 1>&6
-echo "configure:3644: checking if X11 header files implicitly declare return values" >&5
+echo "configure:3664: checking if X11 header files implicitly declare return values" >&5
     cflags_save=$CFLAGS
     CFLAGS="$CFLAGS $X_CFLAGS -Werror"
     cat > conftest.$ac_ext <<EOF
-#line 3648 "configure"
+#line 3668 "configure"
 #include "confdefs.h"
 #include <X11/Xlib.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3655: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3675: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
 else
@@ -3660,14 +3680,14 @@
   rm -rf conftest*
   CFLAGS="$CFLAGS -Wno-implicit-int"
 	cat > conftest.$ac_ext <<EOF
-#line 3664 "configure"
+#line 3684 "configure"
 #include "confdefs.h"
 #include <X11/Xlib.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3671: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3691: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cflags_save="$cflags_save -Wno-implicit-int"
 else
@@ -3691,7 +3711,7 @@
 test "x$with_x" = xno -a "x$BEOS" != "xyes" -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no
 
 echo $ac_n "checking --enable-gui argument""... $ac_c" 1>&6
-echo "configure:3695: checking --enable-gui argument" >&5
+echo "configure:3715: checking --enable-gui argument" >&5
 # Check whether --enable-gui or --disable-gui was given.
 if test "${enable_gui+set}" = set; then
   enableval="$enable_gui"
@@ -3753,7 +3773,6 @@
 
 else
 
-
   case "$enable_gui_canon" in
     no|none)	echo "$ac_t""no GUI support" 1>&6 ;;
     yes|""|auto)	echo "$ac_t""yes/auto - automatic GUI support" 1>&6
@@ -3764,6 +3783,8 @@
 		SKIP_ATHENA=
 		SKIP_NEXTAW=
 		SKIP_CARBON=;;
+    kde|Kde|KDE)	echo "$ac_t""KDE 2.x or 3.x GUI support" 1>&6
+    		SKIP_KDE=;;
     gtk)	echo "$ac_t""GTK+ 1.x GUI support" 1>&6
 		SKIP_GTK=;;
     gtk2)	echo "$ac_t""GTK+ 2.x GUI support" 1>&6
@@ -3787,9 +3808,26 @@
 
 fi
 
+if test "x$SKIP_KDE" != "xYES" -a "$enable_gui_canon" != "kde"; then
+    echo $ac_n "checking whether or not to look for KDE""... $ac_c" 1>&6
+echo "configure:3814: checking whether or not to look for KDE" >&5
+    # Check whether --enable-kde-check or --disable-kde-check was given.
+if test "${enable_kde_check+set}" = set; then
+  enableval="$enable_kde_check"
+  :
+else
+  enable_kde_check="no"
+fi
+
+    echo "$ac_t""$enable_kde_check" 1>&6;
+    if test "x$enable_kde_check" = "xno"; then
+       SKIP_KDE=YES
+    fi
+fi
+
 if test "x$SKIP_GTK" != "xYES" -a "$enable_gui_canon" != "gtk" -a "$enable_gui_canon" != "gtk2"; then
   echo $ac_n "checking whether or not to look for GTK""... $ac_c" 1>&6
-echo "configure:3793: checking whether or not to look for GTK" >&5
+echo "configure:3831: checking whether or not to look for GTK" >&5
   # Check whether --enable-gtk-check or --disable-gtk-check was given.
 if test "${enable_gtk_check+set}" = set; then
   enableval="$enable_gtk_check"
@@ -3808,7 +3846,7 @@
 if test "x$SKIP_GTK2" != "xYES" -a "$enable_gui_canon" != "gtk2" \
 				-a "$enable_gui_canon" != "gnome2"; then
   echo $ac_n "checking whether or not to look for GTK+ 2""... $ac_c" 1>&6
-echo "configure:3812: checking whether or not to look for GTK+ 2" >&5
+echo "configure:3850: checking whether or not to look for GTK+ 2" >&5
   # Check whether --enable-gtk2-check or --disable-gtk2-check was given.
 if test "${enable_gtk2_check+set}" = set; then
   enableval="$enable_gtk2_check"
@@ -3826,7 +3864,7 @@
 if test "x$SKIP_GNOME" != "xYES" -a "$enable_gui_canon" != "gnome" \
 				 -a "$enable_gui_canon" != "gnome2"; then
   echo $ac_n "checking whether or not to look for GNOME""... $ac_c" 1>&6
-echo "configure:3830: checking whether or not to look for GNOME" >&5
+echo "configure:3868: checking whether or not to look for GNOME" >&5
   # Check whether --enable-gnome-check or --disable-gnome-check was given.
 if test "${enable_gnome_check+set}" = set; then
   enableval="$enable_gnome_check"
@@ -3843,7 +3881,7 @@
 
 if test "x$SKIP_MOTIF" != "xYES" -a "$enable_gui_canon" != "motif"; then
   echo $ac_n "checking whether or not to look for Motif""... $ac_c" 1>&6
-echo "configure:3847: checking whether or not to look for Motif" >&5
+echo "configure:3885: checking whether or not to look for Motif" >&5
   # Check whether --enable-motif-check or --disable-motif-check was given.
 if test "${enable_motif_check+set}" = set; then
   enableval="$enable_motif_check"
@@ -3860,7 +3898,7 @@
 
 if test "x$SKIP_ATHENA" != "xYES" -a "$enable_gui_canon" != "athena"; then
   echo $ac_n "checking whether or not to look for Athena""... $ac_c" 1>&6
-echo "configure:3864: checking whether or not to look for Athena" >&5
+echo "configure:3902: checking whether or not to look for Athena" >&5
   # Check whether --enable-athena-check or --disable-athena-check was given.
 if test "${enable_athena_check+set}" = set; then
   enableval="$enable_athena_check"
@@ -3877,7 +3915,7 @@
 
 if test "x$SKIP_NEXTAW" != "xYES" -a "$enable_gui_canon" != "nextaw"; then
   echo $ac_n "checking whether or not to look for neXtaw""... $ac_c" 1>&6
-echo "configure:3881: checking whether or not to look for neXtaw" >&5
+echo "configure:3919: checking whether or not to look for neXtaw" >&5
   # Check whether --enable-nextaw-check or --disable-nextaw-check was given.
 if test "${enable_nextaw_check+set}" = set; then
   enableval="$enable_nextaw_check"
@@ -3894,7 +3932,7 @@
 
 if test "x$SKIP_CARBON" != "xYES" -a "$enable_gui_canon" != "carbon"; then
   echo $ac_n "checking whether or not to look for Carbon""... $ac_c" 1>&6
-echo "configure:3898: checking whether or not to look for Carbon" >&5
+echo "configure:3936: checking whether or not to look for Carbon" >&5
   # Check whether --enable-carbon-check or --disable-carbon-check was given.
 if test "${enable_carbon_check+set}" = set; then
   enableval="$enable_carbon_check"
@@ -3909,9 +3947,359 @@
   fi
 fi
 
+
+if test -z "$SKIP_KDE"; then
+# Check whether --with-qt-dir or --without-qt-dir was given.
+if test "${with_qt_dir+set}" = set; then
+  withval="$with_qt_dir"
+  
+						 ROOTQT="$withval"
+						 MOC="$withval"/bin/moc
+						 QT_INCLUDES="$withval"/include
+						 QT_LIBS="$withval"/lib
+						 
+fi
+
+
+if test "x$ROOTQT" = "x"; then
+	if test -z "$QTDIR"; then
+	    	    	    # Extract the first word of "moc", so it can be a program name with args.
+set dummy moc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:3970: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_MOC'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  case "$MOC" in
+  /*)
+  ac_cv_path_MOC="$MOC" # Let the user override the test with a path.
+  ;;
+  ?:/*)			 
+  ac_cv_path_MOC="$MOC" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_MOC="$ac_dir/$ac_word"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_path_MOC" && ac_cv_path_MOC="no"
+  ;;
+esac
+fi
+MOC="$ac_cv_path_MOC"
+if test -n "$MOC"; then
+  echo "$ac_t""$MOC" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+	    if text"x$MOC" = "x"; then
+		{ echo "configure: error: could not find Qt directory" 1>&2; exit 1; }
+	    else
+	      ROOTQT=`echo $MOC | sed 's+/bin/moc++'`
+	    fi
+	else
+		ROOTQT="$QTDIR"
+	fi
+fi
+MOC="$ROOTQT"/bin/moc
+QT_INCLUDES="$ROOTQT"/include
+QT_LIBS="$ROOTQT"/lib
+
+# Check whether --with-qt-includes or --without-qt-includes was given.
+if test "${with_qt_includes+set}" = set; then
+  withval="$with_qt_includes"
+  QT_INCLUDES="$withval"
+						
+fi
+
+
+# Check whether --with-qt-libraries or --without-qt-libraries was given.
+if test "${with_qt_libraries+set}" = set; then
+  withval="$with_qt_libraries"
+  QT_LIBS="$withval"
+						
+fi
+
+
+if test "x$QT_LIBS" = "x" ; then
+	QT_LIBS="$ROOTQT"/lib
+fi
+if test "x$QT_INCLUDES" = "x" ; then
+	QT_INCLUDES="$ROOTQT"/include
+fi
+
+echo $ac_n "checking whether or not to use a KDE Toolbar in KVim""... $ac_c" 1>&6
+echo "configure:4040: checking whether or not to use a KDE Toolbar in KVim" >&5
+# Check whether --enable-kde-toolbar or --disable-kde-toolbar was given.
+if test "${enable_kde_toolbar+set}" = set; then
+  enableval="$enable_kde_toolbar"
+  :
+else
+  enable_kde_toolbar="no"
+fi
+
+if test "x$enable_kde_toolbar" != "xno"; then
+  cat >> confdefs.h <<\EOF
+#define FEAT_KDETOOLBAR 1
+EOF
+
+fi
+echo "$ac_t""$enable_kde_toolbar" 1>&6;
+fi
+
+
+if test -z "$SKIP_KDE"; then
+
+
+echo $ac_n "checking --disable-rpath argument""... $ac_c" 1>&6
+echo "configure:4063: checking --disable-rpath argument" >&5
+# Check whether --enable-rpath or --disable-rpath was given.
+if test "${enable_rpath+set}" = set; then
+  enableval="$enable_rpath"
+  :
+else
+  enable_rpath="yes"
+fi
+
+if test "$enable_rpath" = "yes"; then
+	echo "$ac_t""no" 1>&6
+else
+	echo "$ac_t""yes" 1>&6
+fi
+
+echo $ac_n "checking --with-kde-prefix argument""... $ac_c" 1>&6
+echo "configure:4079: checking --with-kde-prefix argument" >&5
+# Check whether --with-kde-prefix or --without-kde-prefix was given.
+if test "${with_kde_prefix+set}" = set; then
+  withval="$with_kde_prefix"
+  kde_config_prefix="$withval";
+echo "$ac_t""$kde_config_prefix" 1>&6
+else
+  kde_config_prefix="";echo "$ac_t""no" 1>&6
+fi
+
+
+# Check whether --with-kde-includes or --without-kde-includes was given.
+if test "${with_kde_includes+set}" = set; then
+  withval="$with_kde_includes"
+  KDE_INCLUDES="$withval"
+						
+fi
+
+
+# Check whether --with-kde-libraries or --without-kde-libraries was given.
+if test "${with_kde_libraries+set}" = set; then
+  withval="$with_kde_libraries"
+  KDE_LIBS="$withval"
+						
+fi
+
+
+echo $ac_n "checking --disable-kdetest argument""... $ac_c" 1>&6
+echo "configure:4107: checking --disable-kdetest argument" >&5
+# Check whether --enable-kdetest or --disable-kdetest was given.
+if test "${enable_kdetest+set}" = set; then
+  enableval="$enable_kdetest"
+  enable_kdetest=yes
+fi
+
+
+if test "x$enable_kdetest" = "xyes" ; then
+	echo "$ac_t""kde test enabled" 1>&6
+else
+	echo "$ac_t""kde test disabled" 1>&6
+fi
+
+if test "x$kde_config_prefix" != "x" ; then
+	kde_config_args=""
+	KDE_CONFIG=$kde_config_prefix/bin/kde-config
+fi
+
+if test "X$KDE_CONFIG" = "X"; then
+	# Extract the first word of "kde-config", so it can be a program name with args.
+set dummy kde-config; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:4130: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_KDE_CONFIG'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  case "$KDE_CONFIG" in
+  /*)
+  ac_cv_path_KDE_CONFIG="$KDE_CONFIG" # Let the user override the test with a path.
+  ;;
+  ?:/*)			 
+  ac_cv_path_KDE_CONFIG="$KDE_CONFIG" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_KDE_CONFIG="$ac_dir/$ac_word"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_path_KDE_CONFIG" && ac_cv_path_KDE_CONFIG="no"
+  ;;
+esac
+fi
+KDE_CONFIG="$ac_cv_path_KDE_CONFIG"
+if test -n "$KDE_CONFIG"; then
+  echo "$ac_t""$KDE_CONFIG" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+else
+	echo "$ac_t""Using KDE configuration program $KDE_CONFIG" 1>&6
+fi
+
+if test "X$KDE_CONFIG" != "X" ; then
+	
+	if test "X$KDE_CONFIG" != "X"; then
+	  min_kde_version=2.0.0
+	  echo $ac_n "checking for KDE version >= $min_kde_version""... $ac_c" 1>&6
+echo "configure:4172: checking for KDE version >= $min_kde_version" >&5
+	  no_kde=""
+	  if test "$KDE_CONFIG" = "no" ; then
+		no_kde=yes
+	  else
+		KDE_PREFIX=`$KDE_CONFIG $kde_config_args --prefix`
+		if test "x$KDE_LIBS" = "x"; then
+		  KDE_LIBS="$KDE_PREFIX/lib"
+		fi
+		if test "x$KDE_INCLUDES" = "x"; then
+			KDE_INCLUDES="$KDE_PREFIX/include"
+		fi
+		kde_major_version=`$KDE_CONFIG --version | grep KDE | \
+sed 's/KDE:\ //' | sed 's/\([0-9]*\).\([0-9]*.*\)/\1/'`
+		kde_minor_version=`$KDE_CONFIG --version | grep KDE | \
+sed 's/KDE:\ //' | sed 's/\([0-9]*\).\([0-9]*.*\)/\2/'`
+	
+		qt_major_version=`$KDE_CONFIG --version | grep Qt | sed -e \
+'s/Qt:\ //' | sed 's/\([0-9]*\).\([0-9]*.*\)/\1/'`
+		qt_minor_version=`$KDE_CONFIG --version | grep Qt | sed -e \
+'s/Qt:\ //' | sed 's/\([0-9]*\).\([0-9]*.*\)/\2/'`
+	
+								if test "x$enable-kdetest" = "xyes" ; then
+			ac_save_LIBS="$LIBS"
+			LIBS="$LIBS $KDE_LIBS"
+
+						if test "$cross_compiling" = yes; then
+  echo $ac_n "cross compiling KDE ? ? how can i remove that ? :)"
+else
+  cat > conftest.$ac_ext <<EOF
+#line 4202 "configure"
+#include "confdefs.h"
+
+#include <stdio.h>
+int
+main()
+{ return 0; }
+			
+EOF
+if { (eval echo configure:4211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+  :
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  no_kde=yes
+fi
+rm -fr conftest*
+fi
+
+			LIBS="$ac_save_LIBS"
+		fi
+	fi
+	if test "x$no_kde" = x ; then
+	  echo "$ac_t""found KDE $kde_major_version.$kde_minor_version" 1>&6
+	  GUI_LIB_LOC="-L$KDE_LIBS -lkdeui -lkdecore -lDCOP"
+							 GUI_INC_LOC="-I$KDE_INCLUDES"
+							 KDEDIR="$KDE_PREFIX"
+	else
+	  echo "$ac_t""no" 1>&6
+	  KDE_LIBS=""
+	  :
+	fi
+else
+  echo "$ac_t""no" 1>&6
+  KDE_LIBS=""
+  :
+fi
+
+
+
+
+	if test "x$KDE_PREFIX" != "x"; then
+		echo $ac_n "checking for QT version $qt_major_version.x""... $ac_c" 1>&6
+echo "configure:4247: checking for QT version $qt_major_version.x" >&5
+		if test "x$ROOTQT" != "x" ; then
+			GUI_INC_LOC="-I$QT_INCLUDES $GUI_INC_LOC"
+			if test $qt_major_version -lt 2; then
+				{ echo "configure: error: Your QT version is prior to 2.0; KDE 2.x and 3.x require at least QT 2" 1>&2; exit 1; }
+			fi
+						if test "`(uname) 2>/dev/null`" = "FreeBSD"; then
+				CFLAGS="$CFLAGS -D_THREAD_SAFE"
+				CXXFLAGS="$CXXFLAGS -D_THREAD_SAFE"
+				GUI_LIB_LOC="$GUI_LIB_LOC -pthread"
+				LIBS="$LIBS -pthread"
+			fi
+
+						if test "x$enable_rpath" = "xyes"; then
+				if test $qt_major_version = 2; then
+					GUI_LIB_LOC="-L$KDE_LIBS -lkfile -L$QT_LIBS -lqt $GUI_LIB_LOC \
+-Wl,--rpath -Wl,$KDE_LIBS -Wl,--rpath -Wl,$QT_LIBS"
+				else
+					GUI_LIB_LOC="-L$KDE_LIBS -lkio -L$QT_LIBS -lqt-mt $GUI_LIB_LOC \
+-Wl,--rpath -Wl,$KDE_LIBS -Wl,--rpath -Wl,$QT_LIBS"
+				fi
+			else
+				if test $qt_major_version = 2; then
+					GUI_LIB_LOC="-L$KDE_LIBS -lkfile -L$QT_LIBS -lqt $GUI_LIB_LOC"
+				else
+					GUI_LIB_LOC="-L$KDE_LIBS -lkio -L$QT_LIBS -lqt-mt $GUI_LIB_LOC"
+				fi
+			fi
+
+						GUI_INC_LOC="`echo $GUI_INC_LOC\ | sed 's%-I/usr/include %%'`"
+
+			echo "$ac_t""found $qt_major_version.$qt_minor_version in $ROOTQT" 1>&6
+			SKIP_GTK=YES
+			SKIP_ATHENA=YES
+			SKIP_MOTIF=YES
+			GUITYPE=KDE
+			
+			
+			
+			
+			
+			cat >> confdefs.h <<\EOF
+#define FEAT_GUI_KDE 1
+EOF
+
+		else
+			{ echo "configure: error: Detected QT version mismatched" 1>&2; exit 1; }
+		fi
+	else
+		{ echo "configure: error: Could not find KDE installation prefix" 1>&2; exit 1; }
+	fi
+fi
+fi
+
 if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
   echo $ac_n "checking for Carbon GUI""... $ac_c" 1>&6
-echo "configure:3915: checking for Carbon GUI" >&5
+echo "configure:4303: checking for Carbon GUI" >&5
     echo "$ac_t""yes" 1>&6;
   GUITYPE=CARBONGUI
     SKIP_GTK=YES;
@@ -3933,11 +4321,10 @@
 
 
 
-
 if test -z "$SKIP_GTK"; then
 
   echo $ac_n "checking --with-gtk-prefix argument""... $ac_c" 1>&6
-echo "configure:3941: checking --with-gtk-prefix argument" >&5
+echo "configure:4328: checking --with-gtk-prefix argument" >&5
   # Check whether --with-gtk-prefix or --without-gtk-prefix was given.
 if test "${with_gtk_prefix+set}" = set; then
   withval="$with_gtk_prefix"
@@ -3948,7 +4335,7 @@
 
 
   echo $ac_n "checking --with-gtk-exec-prefix argument""... $ac_c" 1>&6
-echo "configure:3952: checking --with-gtk-exec-prefix argument" >&5
+echo "configure:4339: checking --with-gtk-exec-prefix argument" >&5
   # Check whether --with-gtk-exec-prefix or --without-gtk-exec-prefix was given.
 if test "${with_gtk_exec_prefix+set}" = set; then
   withval="$with_gtk_exec_prefix"
@@ -3959,7 +4346,7 @@
 
 
   echo $ac_n "checking --disable-gtktest argument""... $ac_c" 1>&6
-echo "configure:3963: checking --disable-gtktest argument" >&5
+echo "configure:4350: checking --disable-gtktest argument" >&5
   # Check whether --enable-gtktest or --disable-gtktest was given.
 if test "${enable_gtktest+set}" = set; then
   enableval="$enable_gtktest"
@@ -3986,7 +4373,7 @@
     # Extract the first word of "gtk-config", so it can be a program name with args.
 set dummy gtk-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:3990: checking for $ac_word" >&5
+echo "configure:4377: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_GTK_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4023,7 +4410,7 @@
             # Extract the first word of "gtk12-config", so it can be a program name with args.
 set dummy gtk12-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4027: checking for $ac_word" >&5
+echo "configure:4414: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_GTK12_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4065,7 +4452,7 @@
     # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4069: checking for $ac_word" >&5
+echo "configure:4456: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4107,7 +4494,7 @@
   {
     min_gtk_version=2.2.0
     echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6
-echo "configure:4111: checking for GTK - version >= $min_gtk_version" >&5
+echo "configure:4498: checking for GTK - version >= $min_gtk_version" >&5
     no_gtk=""
     if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
 	  && $PKG_CONFIG --exists gtk+-2.0; then
@@ -4148,7 +4535,7 @@
   echo $ac_n "cross compiling; assumed OK... $ac_c"
 else
   cat > conftest.$ac_ext <<EOF
-#line 4152 "configure"
+#line 4539 "configure"
 #include "confdefs.h"
 
 #include <gtk/gtk.h>
@@ -4180,7 +4567,7 @@
 }
 
 EOF
-if { (eval echo configure:4184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4571: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -4238,7 +4625,7 @@
   {
     min_gtk_version=1.1.16
     echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6
-echo "configure:4242: checking for GTK - version >= $min_gtk_version" >&5
+echo "configure:4629: checking for GTK - version >= $min_gtk_version" >&5
     no_gtk=""
     if (test "X$SKIP_GTK2" != "XYES" -a "X$PKG_CONFIG" != "Xno") \
 	  && $PKG_CONFIG --exists gtk+-2.0; then
@@ -4279,7 +4666,7 @@
   echo $ac_n "cross compiling; assumed OK... $ac_c"
 else
   cat > conftest.$ac_ext <<EOF
-#line 4283 "configure"
+#line 4670 "configure"
 #include "confdefs.h"
 
 #include <gtk/gtk.h>
@@ -4311,7 +4698,7 @@
 }
 
 EOF
-if { (eval echo configure:4315: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -4429,7 +4816,7 @@
   if test "x$want_gnome" = xyes -a "0$gtk_major_version" -ge 2; then
   {
     echo $ac_n "checking for libgnomeui-2.0""... $ac_c" 1>&6
-echo "configure:4433: checking for libgnomeui-2.0" >&5
+echo "configure:4820: checking for libgnomeui-2.0" >&5
     if $PKG_CONFIG --exists libgnomeui-2.0; then
       echo "$ac_t""yes" 1>&6
       GNOME_LIBS=`$PKG_CONFIG --libs-only-l libgnomeui-2.0`
@@ -4448,7 +4835,7 @@
     # Extract the first word of "gnome-config", so it can be a program name with args.
 set dummy gnome-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:4452: checking for $ac_word" >&5
+echo "configure:4839: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_GNOME_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4485,7 +4872,7 @@
       no_gnome_config="yes"
     else
       echo $ac_n "checking if $GNOME_CONFIG works""... $ac_c" 1>&6
-echo "configure:4489: checking if $GNOME_CONFIG works" >&5
+echo "configure:4876: checking if $GNOME_CONFIG works" >&5
       if $GNOME_CONFIG --libs-only-l gnome >/dev/null 2>&1; then
 	echo "$ac_t""yes" 1>&6
 	GNOME_LIBS="`$GNOME_CONFIG --libs-only-l gnome gnomeui`"
@@ -4510,7 +4897,7 @@
 
     if test "$no_gnome_config" = "yes"; then
       echo $ac_n "checking for gnomeConf.sh file in $gnome_prefix""... $ac_c" 1>&6
-echo "configure:4514: checking for gnomeConf.sh file in $gnome_prefix" >&5
+echo "configure:4901: checking for gnomeConf.sh file in $gnome_prefix" >&5
       if test -f $gnome_prefix/gnomeConf.sh; then
 	echo "$ac_t""found" 1>&6
 	echo "loading gnome configuration from" \
@@ -4548,7 +4935,7 @@
     GUI_INC_LOC="`echo $GUI_INC_LOC|sed 's%-I%%g'`"
 
   echo $ac_n "checking for location of Motif GUI includes""... $ac_c" 1>&6
-echo "configure:4552: checking for location of Motif GUI includes" >&5
+echo "configure:4939: checking for location of Motif GUI includes" >&5
   gui_includes="`echo $x_includes|sed 's%/^/^/*$%%'` `echo "$gui_XXX" | sed s/XXX/include/g` $GUI_INC_LOC"
   GUI_INC_LOC=
   for try in $gui_includes; do
@@ -4572,7 +4959,7 @@
 
 if test -z "$SKIP_MOTIF"; then
   echo $ac_n "checking --with-motif-lib argument""... $ac_c" 1>&6
-echo "configure:4576: checking --with-motif-lib argument" >&5
+echo "configure:4963: checking --with-motif-lib argument" >&5
   # Check whether --with-motif-lib or --without-motif-lib was given.
 if test "${with_motif_lib+set}" = set; then
   withval="$with_motif_lib"
@@ -4589,7 +4976,7 @@
         GUI_LIB_LOC="`echo $GUI_LIB_LOC|sed 's%-L%%g'`"
 
     echo $ac_n "checking for location of Motif GUI libs""... $ac_c" 1>&6
-echo "configure:4593: checking for location of Motif GUI libs" >&5
+echo "configure:4980: checking for location of Motif GUI libs" >&5
     gui_libs="`echo $x_libraries|sed 's%/^/^/*$%%'` `echo "$gui_XXX" | sed s/XXX/lib/g` `echo "$GUI_INC_LOC" | sed s/include/lib/` $GUI_LIB_LOC"
     GUI_LIB_LOC=
     for try in $gui_libs; do
@@ -4632,11 +5019,11 @@
 
 if test -z "$SKIP_ATHENA"; then
   echo $ac_n "checking if Athena header files can be found""... $ac_c" 1>&6
-echo "configure:4636: checking if Athena header files can be found" >&5
+echo "configure:5023: checking if Athena header files can be found" >&5
   cflags_save=$CFLAGS
   CFLAGS="$CFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 4640 "configure"
+#line 5027 "configure"
 #include "confdefs.h"
 
 #include <X11/Intrinsic.h>
@@ -4645,7 +5032,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5036: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -4664,11 +5051,11 @@
 
 if test -z "$SKIP_NEXTAW"; then
   echo $ac_n "checking if neXtaw header files can be found""... $ac_c" 1>&6
-echo "configure:4668: checking if neXtaw header files can be found" >&5
+echo "configure:5055: checking if neXtaw header files can be found" >&5
   cflags_save=$CFLAGS
   CFLAGS="$CFLAGS $X_CFLAGS"
   cat > conftest.$ac_ext <<EOF
-#line 4672 "configure"
+#line 5059 "configure"
 #include "confdefs.h"
 
 #include <X11/Intrinsic.h>
@@ -4677,7 +5064,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4681: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5068: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -4705,7 +5092,7 @@
     ldflags_save=$LDFLAGS
   LDFLAGS="$X_LIBS $LDFLAGS"
   echo $ac_n "checking for XShapeQueryExtension in -lXext""... $ac_c" 1>&6
-echo "configure:4709: checking for XShapeQueryExtension in -lXext" >&5
+echo "configure:5096: checking for XShapeQueryExtension in -lXext" >&5
 ac_lib_var=`echo Xext'_'XShapeQueryExtension | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4713,7 +5100,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXext -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4717 "configure"
+#line 5104 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4724,7 +5111,7 @@
 XShapeQueryExtension()
 ; return 0; }
 EOF
-if { (eval echo configure:4728: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4745,7 +5132,7 @@
 fi
 
     echo $ac_n "checking for wslen in -lw""... $ac_c" 1>&6
-echo "configure:4749: checking for wslen in -lw" >&5
+echo "configure:5136: checking for wslen in -lw" >&5
 ac_lib_var=`echo w'_'wslen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4753,7 +5140,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lw $GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4757 "configure"
+#line 5144 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4764,7 +5151,7 @@
 wslen()
 ; return 0; }
 EOF
-if { (eval echo configure:4768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5155: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4785,7 +5172,7 @@
 fi
 
   echo $ac_n "checking for dlsym in -ldl""... $ac_c" 1>&6
-echo "configure:4789: checking for dlsym in -ldl" >&5
+echo "configure:5176: checking for dlsym in -ldl" >&5
 ac_lib_var=`echo dl'_'dlsym | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4793,7 +5180,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldl $GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4797 "configure"
+#line 5184 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4804,7 +5191,7 @@
 dlsym()
 ; return 0; }
 EOF
-if { (eval echo configure:4808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4825,7 +5212,7 @@
 fi
 
   echo $ac_n "checking for XmuCreateStippledPixmap in -lXmu""... $ac_c" 1>&6
-echo "configure:4829: checking for XmuCreateStippledPixmap in -lXmu" >&5
+echo "configure:5216: checking for XmuCreateStippledPixmap in -lXmu" >&5
 ac_lib_var=`echo Xmu'_'XmuCreateStippledPixmap | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4833,7 +5220,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXmu $GUI_X_LIBS -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4837 "configure"
+#line 5224 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4844,7 +5231,7 @@
 XmuCreateStippledPixmap()
 ; return 0; }
 EOF
-if { (eval echo configure:4848: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4866,7 +5253,7 @@
 
   if test -z "$SKIP_MOTIF"; then
     echo $ac_n "checking for XpEndJob in -lXp""... $ac_c" 1>&6
-echo "configure:4870: checking for XpEndJob in -lXp" >&5
+echo "configure:5257: checking for XpEndJob in -lXp" >&5
 ac_lib_var=`echo Xp'_'XpEndJob | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4874,7 +5261,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lXp $GUI_X_LIBS -lXm -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4878 "configure"
+#line 5265 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4885,7 +5272,7 @@
 XpEndJob()
 ; return 0; }
 EOF
-if { (eval echo configure:4889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4909,7 +5296,7 @@
   LDFLAGS=$ldflags_save
 
     echo $ac_n "checking for extra X11 defines""... $ac_c" 1>&6
-echo "configure:4913: checking for extra X11 defines" >&5
+echo "configure:5300: checking for extra X11 defines" >&5
   NARROW_PROTO=
   rm -fr conftestdir
   if mkdir conftestdir; then
@@ -4939,17 +5326,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4943: checking for $ac_hdr" >&5
+echo "configure:5330: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4948 "configure"
+#line 5335 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4953: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5340: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4986,17 +5373,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4990: checking for $ac_hdr" >&5
+echo "configure:5377: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4995 "configure"
+#line 5382 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5000: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5387: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5025,9 +5412,9 @@
 
     if test ! "$enable_xim" = "no"; then
     echo $ac_n "checking for XIMText in X11/Xlib.h""... $ac_c" 1>&6
-echo "configure:5029: checking for XIMText in X11/Xlib.h" >&5
+echo "configure:5416: checking for XIMText in X11/Xlib.h" >&5
     cat > conftest.$ac_ext <<EOF
-#line 5031 "configure"
+#line 5418 "configure"
 #include "confdefs.h"
 #include <X11/Xlib.h>
 EOF
@@ -5058,17 +5445,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5062: checking for $ac_hdr" >&5
+echo "configure:5449: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5067 "configure"
+#line 5454 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5072: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5459: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5104,17 +5491,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5108: checking for $ac_hdr" >&5
+echo "configure:5495: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5113 "configure"
+#line 5500 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5118: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5505: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5207,17 +5594,17 @@
 
 
 echo $ac_n "checking quality of toupper""... $ac_c" 1>&6
-echo "configure:5211: checking quality of toupper" >&5
+echo "configure:5598: checking quality of toupper" >&5
 if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 5216 "configure"
+#line 5603 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 main() { exit(toupper('A') == 'A' && tolower('z') == 'z'); }
 EOF
-if { (eval echo configure:5221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5608: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cat >> confdefs.h <<\EOF
 #define BROKEN_TOUPPER 1
@@ -5234,16 +5621,16 @@
 
 
 echo $ac_n "checking whether __DATE__ and __TIME__ work""... $ac_c" 1>&6
-echo "configure:5238: checking whether __DATE__ and __TIME__ work" >&5
+echo "configure:5625: checking whether __DATE__ and __TIME__ work" >&5
 cat > conftest.$ac_ext <<EOF
-#line 5240 "configure"
+#line 5627 "configure"
 #include "confdefs.h"
 
 int main() {
 printf("(" __DATE__ " " __TIME__ ")");
 ; return 0; }
 EOF
-if { (eval echo configure:5247: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5634: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_DATE_TIME 1
@@ -5259,17 +5646,17 @@
 
 ac_safe=`echo "elf.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for elf.h""... $ac_c" 1>&6
-echo "configure:5263: checking for elf.h" >&5
+echo "configure:5650: checking for elf.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5268 "configure"
+#line 5655 "configure"
 #include "confdefs.h"
 #include <elf.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5273: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5660: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5292,7 +5679,7 @@
 
 if test "$HAS_ELF" = 1; then
   echo $ac_n "checking for main in -lelf""... $ac_c" 1>&6
-echo "configure:5296: checking for main in -lelf" >&5
+echo "configure:5683: checking for main in -lelf" >&5
 ac_lib_var=`echo elf'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5300,14 +5687,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lelf  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5304 "configure"
+#line 5691 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:5311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5698: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5341,12 +5728,12 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:5345: checking for $ac_hdr that defines DIR" >&5
+echo "configure:5732: checking for $ac_hdr that defines DIR" >&5
 if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5350 "configure"
+#line 5737 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_hdr>
@@ -5354,7 +5741,7 @@
 DIR *dirp = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:5358: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5745: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   eval "ac_cv_header_dirent_$ac_safe=yes"
 else
@@ -5379,7 +5766,7 @@
 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
 if test $ac_header_dirent = dirent.h; then
 echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:5383: checking for opendir in -ldir" >&5
+echo "configure:5770: checking for opendir in -ldir" >&5
 ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5387,7 +5774,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldir  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5391 "configure"
+#line 5778 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5398,7 +5785,7 @@
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:5402: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5420,7 +5807,7 @@
 
 else
 echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:5424: checking for opendir in -lx" >&5
+echo "configure:5811: checking for opendir in -lx" >&5
 ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5428,7 +5815,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lx  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5432 "configure"
+#line 5819 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5439,7 +5826,7 @@
 opendir()
 ; return 0; }
 EOF
-if { (eval echo configure:5443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5463,12 +5850,12 @@
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:5467: checking for ANSI C header files" >&5
+echo "configure:5854: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5472 "configure"
+#line 5859 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -5476,7 +5863,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5480: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5867: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5493,7 +5880,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 5497 "configure"
+#line 5884 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -5511,7 +5898,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 5515 "configure"
+#line 5902 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -5532,7 +5919,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 5536 "configure"
+#line 5923 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -5543,7 +5930,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:5547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -5567,12 +5954,12 @@
 fi
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:5571: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:5958: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5576 "configure"
+#line 5963 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -5588,7 +5975,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:5592: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5979: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -5611,16 +5998,16 @@
 
 if test $ac_cv_header_sys_wait_h = no; then
   echo $ac_n "checking for sys/wait.h that defines union wait""... $ac_c" 1>&6
-echo "configure:5615: checking for sys/wait.h that defines union wait" >&5
+echo "configure:6002: checking for sys/wait.h that defines union wait" >&5
   cat > conftest.$ac_ext <<EOF
-#line 5617 "configure"
+#line 6004 "configure"
 #include "confdefs.h"
 #include <sys/wait.h>
 int main() {
 union wait xx, yy; xx = yy
 ; return 0; }
 EOF
-if { (eval echo configure:5624: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6011: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 			cat >> confdefs.h <<\EOF
@@ -5651,17 +6038,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5655: checking for $ac_hdr" >&5
+echo "configure:6042: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5660 "configure"
+#line 6047 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5665: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6052: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5693,17 +6080,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5697: checking for $ac_hdr" >&5
+echo "configure:6084: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5702 "configure"
+#line 6089 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5707: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6094: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -5732,11 +6119,11 @@
 fi
 
 echo $ac_n "checking if strings.h can be included after string.h""... $ac_c" 1>&6
-echo "configure:5736: checking if strings.h can be included after string.h" >&5
+echo "configure:6123: checking if strings.h can be included after string.h" >&5
 cppflags_save=$CPPFLAGS
 CPPFLAGS="$CPPFLAGS $X_CFLAGS"
 cat > conftest.$ac_ext <<EOF
-#line 5740 "configure"
+#line 6127 "configure"
 #include "confdefs.h"
 
 #if defined(_AIX) && !defined(_AIX51) && !defined(_NO_PROTO)
@@ -5757,7 +6144,7 @@
 int i; i = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:5761: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6148: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 else
@@ -5775,13 +6162,13 @@
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:5779: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:6166: checking whether ${CC-cc} needs -traditional" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
     ac_pattern="Autoconf.*'x'"
   cat > conftest.$ac_ext <<EOF
-#line 5785 "configure"
+#line 6172 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
@@ -5799,7 +6186,7 @@
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 5803 "configure"
+#line 6190 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
@@ -5821,12 +6208,12 @@
 fi
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:5825: checking for working const" >&5
+echo "configure:6212: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5830 "configure"
+#line 6217 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -5875,7 +6262,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5879: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6266: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -5896,12 +6283,12 @@
 fi
 
 echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:5900: checking for mode_t" >&5
+echo "configure:6287: checking for mode_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5905 "configure"
+#line 6292 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -5929,12 +6316,12 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:5933: checking for off_t" >&5
+echo "configure:6320: checking for off_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5938 "configure"
+#line 6325 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -5962,12 +6349,12 @@
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:5966: checking for pid_t" >&5
+echo "configure:6353: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5971 "configure"
+#line 6358 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -5995,12 +6382,12 @@
 fi
 
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:5999: checking for size_t" >&5
+echo "configure:6386: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6004 "configure"
+#line 6391 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -6028,12 +6415,12 @@
 fi
 
 echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:6032: checking for uid_t in sys/types.h" >&5
+echo "configure:6419: checking for uid_t in sys/types.h" >&5
 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6037 "configure"
+#line 6424 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 EOF
@@ -6062,12 +6449,12 @@
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:6066: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:6453: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6071 "configure"
+#line 6458 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -6076,7 +6463,7 @@
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:6080: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6467: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -6097,12 +6484,12 @@
 fi
 
 echo $ac_n "checking for ino_t""... $ac_c" 1>&6
-echo "configure:6101: checking for ino_t" >&5
+echo "configure:6488: checking for ino_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_ino_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6106 "configure"
+#line 6493 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -6130,12 +6517,12 @@
 fi
 
 echo $ac_n "checking for dev_t""... $ac_c" 1>&6
-echo "configure:6134: checking for dev_t" >&5
+echo "configure:6521: checking for dev_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_dev_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6139 "configure"
+#line 6526 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -6164,12 +6551,12 @@
 
 
 echo $ac_n "checking for rlim_t""... $ac_c" 1>&6
-echo "configure:6168: checking for rlim_t" >&5
+echo "configure:6555: checking for rlim_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_rlim_t'+set}'`\" = set"; then
   echo "$ac_t""(cached) $ac_cv_type_rlim_t" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6173 "configure"
+#line 6560 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -6201,12 +6588,12 @@
 fi
 
 echo $ac_n "checking for stack_t""... $ac_c" 1>&6
-echo "configure:6205: checking for stack_t" >&5
+echo "configure:6592: checking for stack_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_stack_t'+set}'`\" = set"; then
   echo "$ac_t""(cached) $ac_cv_type_stack_t" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6210 "configure"
+#line 6597 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -6236,9 +6623,9 @@
 fi
 
 echo $ac_n "checking whether stack_t has an ss_base field""... $ac_c" 1>&6
-echo "configure:6240: checking whether stack_t has an ss_base field" >&5
+echo "configure:6627: checking whether stack_t has an ss_base field" >&5
 cat > conftest.$ac_ext <<EOF
-#line 6242 "configure"
+#line 6629 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -6253,7 +6640,7 @@
 stack_t sigstk; sigstk.ss_base = 0; 
 ; return 0; }
 EOF
-if { (eval echo configure:6257: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6644: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SS_BASE 1
@@ -6269,7 +6656,7 @@
 
 olibs="$LIBS"
 echo $ac_n "checking --with-tlib argument""... $ac_c" 1>&6
-echo "configure:6273: checking --with-tlib argument" >&5
+echo "configure:6660: checking --with-tlib argument" >&5
 # Check whether --with-tlib or --without-tlib was given.
 if test "${with_tlib+set}" = set; then
   withval="$with_tlib"
@@ -6287,7 +6674,7 @@
   esac
   for libname in $tlibs; do
     echo $ac_n "checking for tgetent in -l${libname}""... $ac_c" 1>&6
-echo "configure:6291: checking for tgetent in -l${libname}" >&5
+echo "configure:6678: checking for tgetent in -l${libname}" >&5
 ac_lib_var=`echo ${libname}'_'tgetent | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6295,7 +6682,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-l${libname}  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6299 "configure"
+#line 6686 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6306,7 +6693,7 @@
 tgetent()
 ; return 0; }
 EOF
-if { (eval echo configure:6310: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6338,7 +6725,7 @@
   res="FAIL"
 else
   cat > conftest.$ac_ext <<EOF
-#line 6342 "configure"
+#line 6729 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -6346,7 +6733,7 @@
 #endif
 main() {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(0); }
 EOF
-if { (eval echo configure:6350: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6737: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   res="OK"
 else
@@ -6368,12 +6755,12 @@
 fi
 if test "x$olibs" != "x$LIBS"; then
   echo $ac_n "checking whether we talk terminfo""... $ac_c" 1>&6
-echo "configure:6372: checking whether we talk terminfo" >&5
+echo "configure:6759: checking whether we talk terminfo" >&5
   if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program." 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 6377 "configure"
+#line 6764 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -6382,7 +6769,7 @@
 main()
 {char *s; s=(char *)tgoto("%p1%d", 0, 1); exit(!strcmp(s==0 ? "" : s, "1")); }
 EOF
-if { (eval echo configure:6386: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""no -- we are in termcap land" 1>&6
 else
@@ -6403,12 +6790,12 @@
 
 if test "x$olibs" != "x$LIBS"; then
   echo $ac_n "checking what tgetent() returns for an unknown terminal""... $ac_c" 1>&6
-echo "configure:6407: checking what tgetent() returns for an unknown terminal" >&5
+echo "configure:6794: checking what tgetent() returns for an unknown terminal" >&5
   if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program." 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 6412 "configure"
+#line 6799 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -6417,7 +6804,7 @@
 main()
 {char s[10000]; int res = tgetent(s, "thisterminaldoesnotexist"); exit(res != 0); }
 EOF
-if { (eval echo configure:6421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6808: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""zero" 1>&6; cat >> confdefs.h <<\EOF
 #define TGETENT_ZERO_ERR 0
@@ -6435,9 +6822,9 @@
 fi
 
 echo $ac_n "checking whether termcap.h contains ospeed""... $ac_c" 1>&6
-echo "configure:6439: checking whether termcap.h contains ospeed" >&5
+echo "configure:6826: checking whether termcap.h contains ospeed" >&5
 cat > conftest.$ac_ext <<EOF
-#line 6441 "configure"
+#line 6828 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -6448,7 +6835,7 @@
 ospeed = 20000
 ; return 0; }
 EOF
-if { (eval echo configure:6452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_OSPEED 1
@@ -6460,9 +6847,9 @@
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
 	echo $ac_n "checking whether ospeed can be extern""... $ac_c" 1>&6
-echo "configure:6464: checking whether ospeed can be extern" >&5
+echo "configure:6851: checking whether ospeed can be extern" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6466 "configure"
+#line 6853 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -6474,7 +6861,7 @@
 ospeed = 20000
 ; return 0; }
 EOF
-if { (eval echo configure:6478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define OSPEED_EXTERN 1
@@ -6492,9 +6879,9 @@
 rm -f conftest*
 
 echo $ac_n "checking whether termcap.h contains UP, BC and PC""... $ac_c" 1>&6
-echo "configure:6496: checking whether termcap.h contains UP, BC and PC" >&5
+echo "configure:6883: checking whether termcap.h contains UP, BC and PC" >&5
 cat > conftest.$ac_ext <<EOF
-#line 6498 "configure"
+#line 6885 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -6505,7 +6892,7 @@
 if (UP == 0 && BC == 0) PC = 1
 ; return 0; }
 EOF
-if { (eval echo configure:6509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6896: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_UP_BC_PC 1
@@ -6517,9 +6904,9 @@
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
 	echo $ac_n "checking whether UP, BC and PC can be extern""... $ac_c" 1>&6
-echo "configure:6521: checking whether UP, BC and PC can be extern" >&5
+echo "configure:6908: checking whether UP, BC and PC can be extern" >&5
 	cat > conftest.$ac_ext <<EOF
-#line 6523 "configure"
+#line 6910 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -6531,7 +6918,7 @@
 if (UP == 0 && BC == 0) PC = 1
 ; return 0; }
 EOF
-if { (eval echo configure:6535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6922: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define UP_BC_PC_EXTERN 1
@@ -6549,9 +6936,9 @@
 rm -f conftest*
 
 echo $ac_n "checking whether tputs() uses outfuntype""... $ac_c" 1>&6
-echo "configure:6553: checking whether tputs() uses outfuntype" >&5
+echo "configure:6940: checking whether tputs() uses outfuntype" >&5
 cat > conftest.$ac_ext <<EOF
-#line 6555 "configure"
+#line 6942 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_TERMCAP_H
@@ -6562,7 +6949,7 @@
 extern int xx(); tputs("test", 1, (outfuntype)xx)
 ; return 0; }
 EOF
-if { (eval echo configure:6566: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6953: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_OUTFUNTYPE 1
@@ -6577,9 +6964,9 @@
 rm -f conftest*
 
 echo $ac_n "checking whether sys/select.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:6581: checking whether sys/select.h and sys/time.h may both be included" >&5
+echo "configure:6968: checking whether sys/select.h and sys/time.h may both be included" >&5
 cat > conftest.$ac_ext <<EOF
-#line 6583 "configure"
+#line 6970 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -6589,7 +6976,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6593: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6980: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 			cat >> confdefs.h <<\EOF
@@ -6606,7 +6993,7 @@
 
 
 echo $ac_n "checking for /dev/ptc""... $ac_c" 1>&6
-echo "configure:6610: checking for /dev/ptc" >&5
+echo "configure:6997: checking for /dev/ptc" >&5
 if test -r /dev/ptc; then
   cat >> confdefs.h <<\EOF
 #define HAVE_DEV_PTC 1
@@ -6618,17 +7005,17 @@
 fi
 
 echo $ac_n "checking for SVR4 ptys""... $ac_c" 1>&6
-echo "configure:6622: checking for SVR4 ptys" >&5
+echo "configure:7009: checking for SVR4 ptys" >&5
 if test -c /dev/ptmx ; then
   cat > conftest.$ac_ext <<EOF
-#line 6625 "configure"
+#line 7012 "configure"
 #include "confdefs.h"
 
 int main() {
 ptsname(0);grantpt(0);unlockpt(0);
 ; return 0; }
 EOF
-if { (eval echo configure:6632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7019: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SVR4_PTYS 1
@@ -6646,14 +7033,14 @@
 fi
 
 echo $ac_n "checking for ptyranges""... $ac_c" 1>&6
-echo "configure:6650: checking for ptyranges" >&5
+echo "configure:7037: checking for ptyranges" >&5
 if test -d /dev/ptym ; then
   pdir='/dev/ptym'
 else
   pdir='/dev'
 fi
 cat > conftest.$ac_ext <<EOF
-#line 6657 "configure"
+#line 7044 "configure"
 #include "confdefs.h"
 #ifdef M_UNIX
    yes;
@@ -6687,13 +7074,13 @@
 fi
 
 echo $ac_n "checking default tty permissions/group""... $ac_c" 1>&6
-echo "configure:6691: checking default tty permissions/group" >&5
+echo "configure:7078: checking default tty permissions/group" >&5
 rm -f conftest_grp
 if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 6697 "configure"
+#line 7084 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -6725,7 +7112,7 @@
 }
 
 EOF
-if { (eval echo configure:6729: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   
     if test -f conftest_grp; then
@@ -6756,12 +7143,12 @@
 
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:6760: checking return type of signal handlers" >&5
+echo "configure:7147: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6765 "configure"
+#line 7152 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -6778,7 +7165,7 @@
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:6782: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7169: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -6810,9 +7197,9 @@
 fi
 
 echo $ac_n "checking for struct sigcontext""... $ac_c" 1>&6
-echo "configure:6814: checking for struct sigcontext" >&5
+echo "configure:7201: checking for struct sigcontext" >&5
 cat > conftest.$ac_ext <<EOF
-#line 6816 "configure"
+#line 7203 "configure"
 #include "confdefs.h"
 
 #include <signal.h>
@@ -6826,7 +7213,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7217: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 		cat >> confdefs.h <<\EOF
@@ -6842,12 +7229,12 @@
 rm -f conftest*
 
 echo $ac_n "checking getcwd implementation""... $ac_c" 1>&6
-echo "configure:6846: checking getcwd implementation" >&5
+echo "configure:7233: checking getcwd implementation" >&5
 if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 6851 "configure"
+#line 7238 "configure"
 #include "confdefs.h"
 
 char *dagger[] = { "IFS=pwd", 0 };
@@ -6859,7 +7246,7 @@
   return getcwd(buffer, 500) ? 0 : 1;
 }
 EOF
-if { (eval echo configure:6863: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""it is usable" 1>&6
 else
@@ -6884,12 +7271,12 @@
 	strnicmp strpbrk strtol tgetent towlower towupper usleep utime utimes
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6888: checking for $ac_func" >&5
+echo "configure:7275: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6893 "configure"
+#line 7280 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6912,7 +7299,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6916: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6938,9 +7325,9 @@
 
 
 echo $ac_n "checking for st_blksize""... $ac_c" 1>&6
-echo "configure:6942: checking for st_blksize" >&5
+echo "configure:7329: checking for st_blksize" >&5
 cat > conftest.$ac_ext <<EOF
-#line 6944 "configure"
+#line 7331 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -6952,7 +7339,7 @@
 	n = (int)st.st_blksize;
 ; return 0; }
 EOF
-if { (eval echo configure:6956: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7343: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_ST_BLKSIZE 1
@@ -6967,18 +7354,18 @@
 rm -f conftest*
 
 echo $ac_n "checking whether stat() ignores a trailing slash""... $ac_c" 1>&6
-echo "configure:6971: checking whether stat() ignores a trailing slash" >&5
+echo "configure:7358: checking whether stat() ignores a trailing slash" >&5
 if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 6976 "configure"
+#line 7363 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 main() {struct stat st;  exit(stat("configure/", &st) != 0); }
 EOF
-if { (eval echo configure:6982: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define STAT_IGNORES_SLASH 1
@@ -6995,11 +7382,11 @@
 
 
 echo $ac_n "checking for iconv_open()""... $ac_c" 1>&6
-echo "configure:6999: checking for iconv_open()" >&5
+echo "configure:7386: checking for iconv_open()" >&5
 save_LIBS="$LIBS"
 LIBS="$LIBS -liconv"
 cat > conftest.$ac_ext <<EOF
-#line 7003 "configure"
+#line 7390 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_ICONV_H
@@ -7010,7 +7397,7 @@
 iconv_open("fr", "to");
 ; return 0; }
 EOF
-if { (eval echo configure:7014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes; with -liconv" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_ICONV 1
@@ -7022,7 +7409,7 @@
   rm -rf conftest*
   LIBS="$save_LIBS"
     cat > conftest.$ac_ext <<EOF
-#line 7026 "configure"
+#line 7413 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_ICONV_H
@@ -7033,7 +7420,7 @@
 iconv_open("fr", "to");
 ; return 0; }
 EOF
-if { (eval echo configure:7037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_ICONV 1
@@ -7051,9 +7438,9 @@
 
 
 echo $ac_n "checking for nl_langinfo(CODESET)""... $ac_c" 1>&6
-echo "configure:7055: checking for nl_langinfo(CODESET)" >&5
+echo "configure:7442: checking for nl_langinfo(CODESET)" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7057 "configure"
+#line 7444 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_LANGINFO_H
@@ -7064,7 +7451,7 @@
 char *cs = nl_langinfo(CODESET);
 ; return 0; }
 EOF
-if { (eval echo configure:7068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_NL_LANGINFO_CODESET 1
@@ -7079,7 +7466,7 @@
 rm -f conftest*
 
 echo $ac_n "checking --disable-acl argument""... $ac_c" 1>&6
-echo "configure:7083: checking --disable-acl argument" >&5
+echo "configure:7470: checking --disable-acl argument" >&5
 # Check whether --enable-acl or --disable-acl was given.
 if test "${enable_acl+set}" = set; then
   enableval="$enable_acl"
@@ -7091,7 +7478,7 @@
 if test "$enable_acl" = "yes"; then
 echo "$ac_t""no" 1>&6
 echo $ac_n "checking for acl_get_file in -lposix1e""... $ac_c" 1>&6
-echo "configure:7095: checking for acl_get_file in -lposix1e" >&5
+echo "configure:7482: checking for acl_get_file in -lposix1e" >&5
 ac_lib_var=`echo posix1e'_'acl_get_file | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7099,7 +7486,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lposix1e  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7103 "configure"
+#line 7490 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7110,7 +7497,7 @@
 acl_get_file()
 ; return 0; }
 EOF
-if { (eval echo configure:7114: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7501: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7129,7 +7516,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for acl_get_file in -lacl""... $ac_c" 1>&6
-echo "configure:7133: checking for acl_get_file in -lacl" >&5
+echo "configure:7520: checking for acl_get_file in -lacl" >&5
 ac_lib_var=`echo acl'_'acl_get_file | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7137,7 +7524,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lacl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7141 "configure"
+#line 7528 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7148,7 +7535,7 @@
 acl_get_file()
 ; return 0; }
 EOF
-if { (eval echo configure:7152: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7165,7 +7552,7 @@
   echo "$ac_t""yes" 1>&6
   LIBS="$LIBS -lacl"
 		  echo $ac_n "checking for fgetxattr in -lattr""... $ac_c" 1>&6
-echo "configure:7169: checking for fgetxattr in -lattr" >&5
+echo "configure:7556: checking for fgetxattr in -lattr" >&5
 ac_lib_var=`echo attr'_'fgetxattr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7173,7 +7560,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lattr  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7177 "configure"
+#line 7564 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7184,7 +7571,7 @@
 fgetxattr()
 ; return 0; }
 EOF
-if { (eval echo configure:7188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7212,9 +7599,9 @@
 
 
 echo $ac_n "checking for POSIX ACL support""... $ac_c" 1>&6
-echo "configure:7216: checking for POSIX ACL support" >&5
+echo "configure:7603: checking for POSIX ACL support" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7218 "configure"
+#line 7605 "configure"
 #include "confdefs.h"
 
 #include <sys/types.h>
@@ -7228,7 +7615,7 @@
 	acl_free(acl);
 ; return 0; }
 EOF
-if { (eval echo configure:7232: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_POSIX_ACL 1
@@ -7243,9 +7630,9 @@
 rm -f conftest*
 
 echo $ac_n "checking for Solaris ACL support""... $ac_c" 1>&6
-echo "configure:7247: checking for Solaris ACL support" >&5
+echo "configure:7634: checking for Solaris ACL support" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7249 "configure"
+#line 7636 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_SYS_ACL_H
@@ -7256,7 +7643,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:7260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SOLARIS_ACL 1
@@ -7271,9 +7658,9 @@
 rm -f conftest*
 
 echo $ac_n "checking for AIX ACL support""... $ac_c" 1>&6
-echo "configure:7275: checking for AIX ACL support" >&5
+echo "configure:7662: checking for AIX ACL support" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7277 "configure"
+#line 7664 "configure"
 #include "confdefs.h"
 
 #ifdef HAVE_SYS_ACL_H
@@ -7295,7 +7682,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:7299: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_AIX_ACL 1
@@ -7313,7 +7700,7 @@
 fi
 
 echo $ac_n "checking --disable-gpm argument""... $ac_c" 1>&6
-echo "configure:7317: checking --disable-gpm argument" >&5
+echo "configure:7704: checking --disable-gpm argument" >&5
 # Check whether --enable-gpm or --disable-gpm was given.
 if test "${enable_gpm+set}" = set; then
   enableval="$enable_gpm"
@@ -7326,13 +7713,13 @@
 if test "$enable_gpm" = "yes"; then
   echo "$ac_t""no" 1>&6
     echo $ac_n "checking for gpm""... $ac_c" 1>&6
-echo "configure:7330: checking for gpm" >&5
+echo "configure:7717: checking for gpm" >&5
 if eval "test \"`echo '$''{'vi_cv_have_gpm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   olibs="$LIBS" ; LIBS="-lgpm"
 	cat > conftest.$ac_ext <<EOF
-#line 7336 "configure"
+#line 7723 "configure"
 #include "confdefs.h"
 #include <gpm.h>
 	    #include <linux/keyboard.h>
@@ -7340,7 +7727,7 @@
 Gpm_GetLibVersion(NULL);
 ; return 0; }
 EOF
-if { (eval echo configure:7344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   	    	    vi_cv_have_gpm=yes
 else
@@ -7367,12 +7754,12 @@
 fi
 
 echo $ac_n "checking for vsnprintf()""... $ac_c" 1>&6
-echo "configure:7371: checking for vsnprintf()" >&5
+echo "configure:7758: checking for vsnprintf()" >&5
 if test "$cross_compiling" = yes; then
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7376 "configure"
+#line 7763 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -7393,7 +7780,7 @@
 	}
 	    
 EOF
-if { (eval echo configure:7397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cat >> confdefs.h <<\EOF
 #define HAVE_VSNPRINTF 1
@@ -7411,16 +7798,16 @@
 
 
 echo $ac_n "checking for rename""... $ac_c" 1>&6
-echo "configure:7415: checking for rename" >&5
+echo "configure:7802: checking for rename" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7417 "configure"
+#line 7804 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() {
 rename("this", "that")
 ; return 0; }
 EOF
-if { (eval echo configure:7424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_RENAME 1
@@ -7435,9 +7822,9 @@
 rm -f conftest*
 
 echo $ac_n "checking for sysctl""... $ac_c" 1>&6
-echo "configure:7439: checking for sysctl" >&5
+echo "configure:7826: checking for sysctl" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7441 "configure"
+#line 7828 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/sysctl.h>
@@ -7452,7 +7839,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:7456: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7843: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SYSCTL 1
@@ -7467,9 +7854,9 @@
 rm -f conftest*
 
 echo $ac_n "checking for sysinfo""... $ac_c" 1>&6
-echo "configure:7471: checking for sysinfo" >&5
+echo "configure:7858: checking for sysinfo" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7473 "configure"
+#line 7860 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/sysinfo.h>
@@ -7482,7 +7869,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:7486: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7873: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SYSINFO 1
@@ -7497,9 +7884,9 @@
 rm -f conftest*
 
 echo $ac_n "checking for sysconf""... $ac_c" 1>&6
-echo "configure:7501: checking for sysconf" >&5
+echo "configure:7888: checking for sysconf" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7503 "configure"
+#line 7890 "configure"
 #include "confdefs.h"
 #include <unistd.h>
 int main() {
@@ -7508,7 +7895,7 @@
 	
 ; return 0; }
 EOF
-if { (eval echo configure:7512: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7899: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_SYSCONF 1
@@ -7524,7 +7911,7 @@
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:7528: checking size of int" >&5
+echo "configure:7915: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7532,7 +7919,7 @@
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7536 "configure"
+#line 7923 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 		main()
@@ -7543,7 +7930,7 @@
 		  exit(0);
 		}
 EOF
-if { (eval echo configure:7547: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7934: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -7564,7 +7951,7 @@
 
 
 echo $ac_n "checking whether memmove/bcopy/memcpy handle overlaps""... $ac_c" 1>&6
-echo "configure:7568: checking whether memmove/bcopy/memcpy handle overlaps" >&5
+echo "configure:7955: checking whether memmove/bcopy/memcpy handle overlaps" >&5
 bcopy_test_prog='
 main() {
   char buf[10];
@@ -7584,11 +7971,11 @@
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7588 "configure"
+#line 7975 "configure"
 #include "confdefs.h"
 #define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog
 EOF
-if { (eval echo configure:7592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7979: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cat >> confdefs.h <<\EOF
 #define USEMEMMOVE 1
@@ -7602,11 +7989,11 @@
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7606 "configure"
+#line 7993 "configure"
 #include "confdefs.h"
 #define mch_memmove(s,d,l) bcopy(d,s,l) $bcopy_test_prog
 EOF
-if { (eval echo configure:7610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cat >> confdefs.h <<\EOF
 #define USEBCOPY 1
@@ -7620,11 +8007,11 @@
   { echo "configure: error: failed to compile test program" 1>&2; exit 1; }
 else
   cat > conftest.$ac_ext <<EOF
-#line 7624 "configure"
+#line 8011 "configure"
 #include "confdefs.h"
 #define mch_memmove(s,d,l) memcpy(d,s,l) $bcopy_test_prog
 EOF
-if { (eval echo configure:7628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8015: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   cat >> confdefs.h <<\EOF
 #define USEMEMCPY 1
@@ -7656,19 +8043,19 @@
     CFLAGS="$CFLAGS -I$x_includes"
     LDFLAGS="$X_LIBS $LDFLAGS -lX11"
     echo $ac_n "checking whether X_LOCALE needed""... $ac_c" 1>&6
-echo "configure:7660: checking whether X_LOCALE needed" >&5
+echo "configure:8047: checking whether X_LOCALE needed" >&5
     cat > conftest.$ac_ext <<EOF
-#line 7662 "configure"
+#line 8049 "configure"
 #include "confdefs.h"
 #include <X11/Xlocale.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7669: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 7672 "configure"
+#line 8059 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7679,7 +8066,7 @@
 _Xsetlocale()
 ; return 0; }
 EOF
-if { (eval echo configure:7683: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6
 		cat >> confdefs.h <<\EOF
@@ -7706,7 +8093,7 @@
 fi
 
 echo $ac_n "checking for _xpg4_setrunelocale in -lxpg4""... $ac_c" 1>&6
-echo "configure:7710: checking for _xpg4_setrunelocale in -lxpg4" >&5
+echo "configure:8097: checking for _xpg4_setrunelocale in -lxpg4" >&5
 ac_lib_var=`echo xpg4'_'_xpg4_setrunelocale | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7714,7 +8101,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lxpg4  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7718 "configure"
+#line 8105 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -7725,7 +8112,7 @@
 _xpg4_setrunelocale()
 ; return 0; }
 EOF
-if { (eval echo configure:7729: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8116: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7747,7 +8134,7 @@
 
 
 echo $ac_n "checking how to create tags""... $ac_c" 1>&6
-echo "configure:7751: checking how to create tags" >&5
+echo "configure:8138: checking how to create tags" >&5
 test -f tags && mv tags tags.save
 if (eval ctags --version /dev/null | grep Exuberant) < /dev/null 1>&5 2>&1; then
   TAGPRG="ctags"
@@ -7764,7 +8151,7 @@
 echo "$ac_t""$TAGPRG" 1>&6 
 
 echo $ac_n "checking how to run man with a section nr""... $ac_c" 1>&6
-echo "configure:7768: checking how to run man with a section nr" >&5
+echo "configure:8155: checking how to run man with a section nr" >&5
 MANDEF="man"
 (eval man -s 2 read) < /dev/null > /dev/null 2>&5 && MANDEF="man -s"
 echo "$ac_t""$MANDEF" 1>&6
@@ -7776,7 +8163,7 @@
 fi
 
 echo $ac_n "checking --disable-nls argument""... $ac_c" 1>&6
-echo "configure:7780: checking --disable-nls argument" >&5
+echo "configure:8167: checking --disable-nls argument" >&5
 # Check whether --enable-nls or --disable-nls was given.
 if test "${enable_nls+set}" = set; then
   enableval="$enable_nls"
@@ -7791,7 +8178,7 @@
   # Extract the first word of "msgfmt", so it can be a program name with args.
 set dummy msgfmt; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:7795: checking for $ac_word" >&5
+echo "configure:8182: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_MSGFMT'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7818,19 +8205,19 @@
 fi
 
   echo $ac_n "checking for NLS""... $ac_c" 1>&6
-echo "configure:7822: checking for NLS" >&5
+echo "configure:8209: checking for NLS" >&5
   if test -f po/Makefile; then
     have_gettext="no"
     if test -n "$MSGFMT"; then
       cat > conftest.$ac_ext <<EOF
-#line 7827 "configure"
+#line 8214 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 int main() {
 gettext("Test");
 ; return 0; }
 EOF
-if { (eval echo configure:7834: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""gettext() works" 1>&6; have_gettext="yes"
 else
@@ -7840,14 +8227,14 @@
   olibs=$LIBS
 	  LIBS="$LIBS -lintl"
 	  cat > conftest.$ac_ext <<EOF
-#line 7844 "configure"
+#line 8231 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 int main() {
 gettext("Test");
 ; return 0; }
 EOF
-if { (eval echo configure:7851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""gettext() works with -lintl" 1>&6; have_gettext="yes"
 else
@@ -7873,12 +8260,12 @@
             for ac_func in bind_textdomain_codeset
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7877: checking for $ac_func" >&5
+echo "configure:8264: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7882 "configure"
+#line 8269 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -7901,7 +8288,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:7905: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -7926,9 +8313,9 @@
 done
 
             echo $ac_n "checking for _nl_msg_cat_cntr""... $ac_c" 1>&6
-echo "configure:7930: checking for _nl_msg_cat_cntr" >&5
+echo "configure:8317: checking for _nl_msg_cat_cntr" >&5
       cat > conftest.$ac_ext <<EOF
-#line 7932 "configure"
+#line 8319 "configure"
 #include "confdefs.h"
 #include <libintl.h>
 		extern int _nl_msg_cat_cntr;
@@ -7936,7 +8323,7 @@
 ++_nl_msg_cat_cntr;
 ; return 0; }
 EOF
-if { (eval echo configure:7940: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
 #define HAVE_NL_MSG_CAT_CNTR 1
@@ -7959,17 +8346,17 @@
 
 ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:7963: checking for dlfcn.h" >&5
+echo "configure:8350: checking for dlfcn.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7968 "configure"
+#line 8355 "configure"
 #include "confdefs.h"
 #include <dlfcn.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7973: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8360: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7990,17 +8377,17 @@
   echo "$ac_t""no" 1>&6
 ac_safe=`echo "dl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for dl.h""... $ac_c" 1>&6
-echo "configure:7994: checking for dl.h" >&5
+echo "configure:8381: checking for dl.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7999 "configure"
+#line 8386 "configure"
 #include "confdefs.h"
 #include <dl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8004: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8391: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8029,9 +8416,9 @@
 EOF
 
   echo $ac_n "checking for dlopen()""... $ac_c" 1>&6
-echo "configure:8033: checking for dlopen()" >&5
+echo "configure:8420: checking for dlopen()" >&5
   cat > conftest.$ac_ext <<EOF
-#line 8035 "configure"
+#line 8422 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8041,7 +8428,7 @@
       
 ; return 0; }
 EOF
-if { (eval echo configure:8045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 	      cat >> confdefs.h <<\EOF
@@ -8054,11 +8441,11 @@
   rm -rf conftest*
   echo "$ac_t""no" 1>&6;
 	      echo $ac_n "checking for dlopen() in -ldl""... $ac_c" 1>&6
-echo "configure:8058: checking for dlopen() in -ldl" >&5
+echo "configure:8445: checking for dlopen() in -ldl" >&5
 	      olibs=$LIBS
 	      LIBS="$LIBS -ldl"
 	      cat > conftest.$ac_ext <<EOF
-#line 8062 "configure"
+#line 8449 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8068,7 +8455,7 @@
 		 
 ; return 0; }
 EOF
-if { (eval echo configure:8072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 			  cat >> confdefs.h <<\EOF
@@ -8086,9 +8473,9 @@
 fi
 rm -f conftest*
       echo $ac_n "checking for dlsym()""... $ac_c" 1>&6
-echo "configure:8090: checking for dlsym()" >&5
+echo "configure:8477: checking for dlsym()" >&5
   cat > conftest.$ac_ext <<EOF
-#line 8092 "configure"
+#line 8479 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8098,7 +8485,7 @@
       
 ; return 0; }
 EOF
-if { (eval echo configure:8102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8489: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 	      cat >> confdefs.h <<\EOF
@@ -8111,11 +8498,11 @@
   rm -rf conftest*
   echo "$ac_t""no" 1>&6;
 	      echo $ac_n "checking for dlsym() in -ldl""... $ac_c" 1>&6
-echo "configure:8115: checking for dlsym() in -ldl" >&5
+echo "configure:8502: checking for dlsym() in -ldl" >&5
 	      olibs=$LIBS
 	      LIBS="$LIBS -ldl"
 	      cat > conftest.$ac_ext <<EOF
-#line 8119 "configure"
+#line 8506 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8125,7 +8512,7 @@
 		 
 ; return 0; }
 EOF
-if { (eval echo configure:8129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 			  cat >> confdefs.h <<\EOF
@@ -8148,9 +8535,9 @@
 EOF
 
   echo $ac_n "checking for shl_load()""... $ac_c" 1>&6
-echo "configure:8152: checking for shl_load()" >&5
+echo "configure:8539: checking for shl_load()" >&5
   cat > conftest.$ac_ext <<EOF
-#line 8154 "configure"
+#line 8541 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8160,7 +8547,7 @@
      
 ; return 0; }
 EOF
-if { (eval echo configure:8164: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8551: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 	  cat >> confdefs.h <<\EOF
@@ -8173,11 +8560,11 @@
   rm -rf conftest*
   echo "$ac_t""no" 1>&6;
 	  echo $ac_n "checking for shl_load() in -ldld""... $ac_c" 1>&6
-echo "configure:8177: checking for shl_load() in -ldld" >&5
+echo "configure:8564: checking for shl_load() in -ldld" >&5
 	  olibs=$LIBS
 	  LIBS="$LIBS -ldld"
 	  cat > conftest.$ac_ext <<EOF
-#line 8181 "configure"
+#line 8568 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -8187,7 +8574,7 @@
 	     
 ; return 0; }
 EOF
-if { (eval echo configure:8191: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   echo "$ac_t""yes" 1>&6;
 		  cat >> confdefs.h <<\EOF
@@ -8209,17 +8596,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:8213: checking for $ac_hdr" >&5
+echo "configure:8600: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8218 "configure"
+#line 8605 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8223: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8256,7 +8643,7 @@
 if test "x$MACOSX" = "xyes" && test "x$CARBON" = "xyes" \
 	&& test "x$GUITYPE" != "xCARBONGUI"; then
   echo $ac_n "checking whether we need -framework Carbon""... $ac_c" 1>&6
-echo "configure:8260: checking whether we need -framework Carbon" >&5
+echo "configure:8647: checking whether we need -framework Carbon" >&5
     if test "x$enable_multibyte" = "xyes" || test "x$features" == "xbig" \
 	|| test "x$features" = "xhuge"; then
     LIBS="$LIBS -framework Carbon"
@@ -8454,6 +8841,14 @@
 s%@X_LIBS@%$X_LIBS%g
 s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g
 s%@X_LIB@%$X_LIB%g
+s%@MOC@%$MOC%g
+s%@KDE_CONFIG@%$KDE_CONFIG%g
+s%@KDE_LIBS@%$KDE_LIBS%g
+s%@KDE_INCLUDES@%$KDE_INCLUDES%g
+s%@KDE_PREFIX@%$KDE_PREFIX%g
+s%@QT_LIBS@%$QT_LIBS%g
+s%@QT_INCLUDES@%$QT_INCLUDES%g
+s%@ROOTQT@%$ROOTQT%g
 s%@GTK_CONFIG@%$GTK_CONFIG%g
 s%@GTK12_CONFIG@%$GTK12_CONFIG%g
 s%@PKG_CONFIG@%$PKG_CONFIG%g
diff --git a/src/config.h.in b/src/config.h.in
index bba2662..1c888f4 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -312,6 +312,9 @@
 /* Define if you use GTK and want GNOME support. */
 #undef FEAT_GUI_GNOME
 
+/* Define if you use KDE and want KDE Toolbar support. */
+#undef FEAT_KDETOOLBAR
+
 /* Define if GTK+ 2 is available. */
 #undef HAVE_GTK2
 
diff --git a/src/config.mk.in b/src/config.mk.in
index 0466499..b5af74b 100644
--- a/src/config.mk.in
+++ b/src/config.mk.in
@@ -124,6 +124,8 @@
 GUI_X_LIBS	= @GUI_X_LIBS@
 MOTIF_LIBNAME	= @MOTIF_LIBNAME@
 GTK_LIBNAME	= @GTK_LIBNAME@
+KDE_PREFIX	= @KDE_PREFIX@
+MOC             = @MOC@
 
 ### Any OS dependent extra source and object file
 OS_EXTRA_SRC	= @OS_EXTRA_SRC@
diff --git a/src/configure.in b/src/configure.in
index 2c23e06..1ebf82c 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -982,7 +982,7 @@
 
 AC_MSG_CHECKING(--enable-gui argument)
 AC_ARG_ENABLE(gui,
- [  --enable-gui[=OPTS]     X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/motif/athena/neXtaw/beos/photon/carbon]], , enable_gui="auto")
+ [  --enable-gui[=OPTS]     X11 GUI [default=auto] [OPTS=auto/no/gtk/gtk2/gnome/gnome2/kde/motif/athena/neXtaw/beos/photon/carbon]], , enable_gui="auto")
 
 dnl Canonicalize the --enable-gui= argument so that it can be easily compared.
 dnl Do not use character classes for portability with old tools.
@@ -1039,7 +1039,6 @@
 
 else
 
-
   case "$enable_gui_canon" in
     no|none)	AC_MSG_RESULT(no GUI support) ;;
     yes|""|auto)	AC_MSG_RESULT(yes/auto - automatic GUI support)
@@ -1050,6 +1049,8 @@
 		SKIP_ATHENA=
 		SKIP_NEXTAW=
 		SKIP_CARBON=;;
+    kde|Kde|KDE)	AC_MSG_RESULT(KDE 2.x or 3.x GUI support)
+    		SKIP_KDE=;;
     gtk)	AC_MSG_RESULT(GTK+ 1.x GUI support)
 		SKIP_GTK=;;
     gtk2)	AC_MSG_RESULT(GTK+ 2.x GUI support)
@@ -1073,6 +1074,17 @@
 
 fi
 
+if test "x$SKIP_KDE" != "xYES" -a "$enable_gui_canon" != "kde"; then
+    AC_MSG_CHECKING(whether or not to look for KDE)
+    AC_ARG_ENABLE(kde-check,
+	[  --enable-kde-check      If auto-select GUI, check for KDE [default=no]],
+	,enable_kde_check="no")
+    AC_MSG_RESULT($enable_kde_check);
+    if test "x$enable_kde_check" = "xno"; then
+       SKIP_KDE=YES
+    fi
+fi
+
 if test "x$SKIP_GTK" != "xYES" -a "$enable_gui_canon" != "gtk" -a "$enable_gui_canon" != "gtk2"; then
   AC_MSG_CHECKING(whether or not to look for GTK)
   AC_ARG_ENABLE(gtk-check,
@@ -1153,6 +1165,247 @@
   fi
 fi
 
+dnl ---------------------------------------------------------------------------
+dnl we use the kde-config script included in KDE since 2.x to check which
+dnl version of KDE, we'll use. We'll use additional args in configure to
+dnl obtain the QT directory (includes and libs) as qt does not give any
+dnl config script ! (shame on the trolls ! ;p)
+dnl ---------------------------------------------------------------------------
+
+if test -z "$SKIP_KDE"; then
+dnl ------------------
+dnl now, take care of QT
+dnl -----------------
+AC_ARG_WITH(qt-dir,
+						[  --with-qt-dir=DIR	Specify prefix of QT files],
+						[
+						 ROOTQT="$withval"
+						 MOC="$withval"/bin/moc
+						 QT_INCLUDES="$withval"/include
+						 QT_LIBS="$withval"/lib
+						 ])
+
+if test "x$ROOTQT" = "x"; then
+	if test -z "$QTDIR"; then
+	    dnl Find the Qt directory by looking for the "moc" program.
+	    dnl It's better than nothing.
+	    AC_PATH_PROG(MOC, moc, no)
+	    if text"x$MOC" = "x"; then
+		AC_MSG_ERROR(could not find Qt directory)
+	    else
+	      ROOTQT=`echo $MOC | sed 's+/bin/moc++'`
+	    fi
+	else
+		ROOTQT="$QTDIR"
+	fi
+fi
+MOC="$ROOTQT"/bin/moc
+QT_INCLUDES="$ROOTQT"/include
+QT_LIBS="$ROOTQT"/lib
+
+AC_ARG_WITH(qt-includes,
+						[  --with-qt-includes=DIR	Specify location of Qt headers],
+						[QT_INCLUDES="$withval"]
+						)
+
+AC_ARG_WITH(qt-libraries,
+						[  --with-qt-libs=DIR	Specify location of Qt libraries],
+						[QT_LIBS="$withval"]
+						)
+
+if test "x$QT_LIBS" = "x" ; then
+	QT_LIBS="$ROOTQT"/lib
+fi
+if test "x$QT_INCLUDES" = "x" ; then
+	QT_INCLUDES="$ROOTQT"/include
+fi
+dnl we should get QT's version from here and compare with what kde-config
+dnl says
+
+AC_MSG_CHECKING(whether or not to use a KDE Toolbar in KVim)
+AC_ARG_ENABLE(kde-toolbar,
+	[  --enable-kde-toolbar   if KDE GUI is selected, enable a KDE-look toolbar [default=no]],
+	, enable_kde_toolbar="no")
+if test "x$enable_kde_toolbar" != "xno"; then
+  AC_DEFINE(FEAT_KDETOOLBAR)
+fi
+AC_MSG_RESULT($enable_kde_toolbar);
+fi
+
+dnl -------------------
+dnl so, first, look up at the kde-config script
+dnl ------------------
+
+if test -z "$SKIP_KDE"; then
+AC_DEFUN(AM_PATH_KDE,
+[
+	if test "X$KDE_CONFIG" != "X"; then
+	  min_kde_version=ifelse([$1], ,2.0,[$1])
+	  AC_MSG_CHECKING(for KDE version >= $min_kde_version)
+	  no_kde=""
+	  if test "$KDE_CONFIG" = "no" ; then
+		no_kde=yes
+	  else
+		KDE_PREFIX=`$KDE_CONFIG $kde_config_args --prefix`
+		if test "x$KDE_LIBS" = "x"; then
+		  KDE_LIBS="$KDE_PREFIX/lib"
+		fi
+		if test "x$KDE_INCLUDES" = "x"; then
+			KDE_INCLUDES="$KDE_PREFIX/include"
+		fi
+		kde_major_version=`$KDE_CONFIG --version | grep KDE | \
+sed 's/KDE:\ //' | sed 's/\([[0-9]]*\).\([[0-9]]*.*\)/\1/'`
+		kde_minor_version=`$KDE_CONFIG --version | grep KDE | \
+sed 's/KDE:\ //' | sed 's/\([[0-9]]*\).\([[0-9]]*.*\)/\2/'`
+	
+		qt_major_version=`$KDE_CONFIG --version | grep Qt | sed -e \
+'s/Qt:\ //' | sed 's/\([[0-9]]*\).\([[0-9]]*.*\)/\1/'`
+		qt_minor_version=`$KDE_CONFIG --version | grep Qt | sed -e \
+'s/Qt:\ //' | sed 's/\([[0-9]]*\).\([[0-9]]*.*\)/\2/'`
+	
+		dnl maybe in a near future we'll get these ones : QT_PREFIX, QT_LIBS,
+		dnl QT_INCLUDES
+		dnl but for now we need configure options to get them ...
+		if test "x$enable-kdetest" = "xyes" ; then
+			ac_save_LIBS="$LIBS"
+			LIBS="$LIBS $KDE_LIBS"
+
+			dnl fake test
+			AC_TRY_RUN([
+#include <stdio.h>
+int
+main()
+{ return 0; }
+			],, no_kde=yes,[echo $ac_n "cross compiling KDE ? ? how can i remove that ? :)"])
+			LIBS="$ac_save_LIBS"
+		fi
+	fi
+	if test "x$no_kde" = x ; then
+	  AC_MSG_RESULT(found KDE $kde_major_version.$kde_minor_version)
+	  ifelse([$2], , :, [$2])
+	else
+	  AC_MSG_RESULT(no)
+	  KDE_LIBS=""
+	  ifelse([$3], , :, [$3])
+	fi
+else
+  AC_MSG_RESULT(no)
+  KDE_LIBS=""
+  ifelse([$3], , :, [$3])
+fi
+AC_SUBST(KDE_LIBS)
+AC_SUBST(KDE_INCLUDES)
+AC_SUBST(KDE_PREFIX)
+])
+
+dnl Check all the KDE stuff
+AC_MSG_CHECKING(--disable-rpath argument)
+AC_ARG_ENABLE(rpath,
+	[  --disable-rpath      Disable rpath.],
+	, enable_rpath="yes")
+if test "$enable_rpath" = "yes"; then
+	AC_MSG_RESULT(no)
+else
+	AC_MSG_RESULT(yes)
+fi
+
+AC_MSG_CHECKING(--with-kde-prefix argument)
+AC_ARG_WITH(kde-prefix,[  --with-kde-prefix=PFX	Prefix where KDE is installed (optional)],kde_config_prefix="$withval";
+AC_MSG_RESULT($kde_config_prefix), kde_config_prefix="";AC_MSG_RESULT(no))
+
+AC_ARG_WITH(kde-includes,
+						[  --with-kde-includes=DIR	Specify location of KDE headers],
+						[KDE_INCLUDES="$withval"]
+						)
+
+AC_ARG_WITH(kde-libraries,
+						[  --with-kde-libs=DIR	Specify location of KDE libraries],
+						[KDE_LIBS="$withval"]
+						)
+
+AC_MSG_CHECKING(--disable-kdetest argument)
+AC_ARG_ENABLE(kdetest,
+							[  --disable-kdetest	Do not try to compile and run a test KDE program],
+							enable_kdetest=yes)
+
+if test "x$enable_kdetest" = "xyes" ; then
+	AC_MSG_RESULT(kde test enabled)
+else
+	AC_MSG_RESULT(kde test disabled)
+fi
+
+if test "x$kde_config_prefix" != "x" ; then
+	kde_config_args=""
+	KDE_CONFIG=$kde_config_prefix/bin/kde-config
+fi
+
+if test "X$KDE_CONFIG" = "X"; then
+	AC_PATH_PROG(KDE_CONFIG, kde-config, no)
+else
+	AC_MSG_RESULT(Using KDE configuration program $KDE_CONFIG)
+fi
+
+if test "X$KDE_CONFIG" != "X" ; then
+	AM_PATH_KDE(2.0.0,
+							[GUI_LIB_LOC="-L$KDE_LIBS -lkdeui -lkdecore -lDCOP"
+							 GUI_INC_LOC="-I$KDE_INCLUDES"
+							 KDEDIR="$KDE_PREFIX"], )
+	if test "x$KDE_PREFIX" != "x"; then
+		AC_MSG_CHECKING(for QT version $qt_major_version.x)
+		if test "x$ROOTQT" != "x" ; then
+			GUI_INC_LOC="-I$QT_INCLUDES $GUI_INC_LOC"
+			if test $qt_major_version -lt 2; then
+				AC_MSG_ERROR(Your QT version is prior to 2.0; KDE 2.x and 3.x require at least QT 2)
+			fi
+			dnl hack for FreeBSD
+			if test "`(uname) 2>/dev/null`" = "FreeBSD"; then
+				CFLAGS="$CFLAGS -D_THREAD_SAFE"
+				CXXFLAGS="$CXXFLAGS -D_THREAD_SAFE"
+				GUI_LIB_LOC="$GUI_LIB_LOC -pthread"
+				LIBS="$LIBS -pthread"
+			fi
+
+			dnl check the version
+			if test "x$enable_rpath" = "xyes"; then
+				if test $qt_major_version = 2; then
+					GUI_LIB_LOC="-L$KDE_LIBS -lkfile -L$QT_LIBS -lqt $GUI_LIB_LOC \
+-Wl,--rpath -Wl,$KDE_LIBS -Wl,--rpath -Wl,$QT_LIBS"
+				else
+					GUI_LIB_LOC="-L$KDE_LIBS -lkio -L$QT_LIBS -lqt-mt $GUI_LIB_LOC \
+-Wl,--rpath -Wl,$KDE_LIBS -Wl,--rpath -Wl,$QT_LIBS"
+				fi
+			else
+				if test $qt_major_version = 2; then
+					GUI_LIB_LOC="-L$KDE_LIBS -lkfile -L$QT_LIBS -lqt $GUI_LIB_LOC"
+				else
+					GUI_LIB_LOC="-L$KDE_LIBS -lkio -L$QT_LIBS -lqt-mt $GUI_LIB_LOC"
+				fi
+			fi
+
+			dnl Remove "-I/usr/include " from GUI_*
+			GUI_INC_LOC="`echo $GUI_INC_LOC\ | sed 's%-I/usr/include %%'`"
+dnl			GUI_LIB_LOC="`echo $GUI_LIB_LOC\ | sed 's% -L/usr/lib%%'`"
+
+			AC_MSG_RESULT(found $qt_major_version.$qt_minor_version in $ROOTQT)
+			SKIP_GTK=YES
+			SKIP_ATHENA=YES
+			SKIP_MOTIF=YES
+			GUITYPE=KDE
+			AC_SUBST(KDE_PREFIX)
+			AC_SUBST(QT_LIBS)
+			AC_SUBST(QT_INCLUDES)
+			AC_SUBST(ROOTQT)
+			AC_SUBST(MOC)
+			AC_DEFINE(FEAT_GUI_KDE)
+		else
+			AC_MSG_ERROR(Detected QT version mismatched)
+		fi
+	else
+		AC_MSG_ERROR(Could not find KDE installation prefix)
+	fi
+fi
+fi
+
 if test "x$MACOSX" = "xyes" -a -z "$SKIP_CARBON" -a "x$CARBON" = "xyes"; then
   AC_MSG_CHECKING(for Carbon GUI)
   dnl already did this
@@ -1170,7 +1423,6 @@
   SKIP_CARBON=YES
 fi
 
-
 dnl
 dnl Get the cflags and libraries from the gtk-config script
 dnl
diff --git a/src/edit.c b/src/edit.c
index 7619a55..1adcda4 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -270,6 +270,23 @@
     ins_compl_clear();	    /* clear stuff for CTRL-X mode */
 #endif
 
+#ifdef FEAT_AUTOCMD
+    /*
+     * Trigger InsertEnter autocommands.  Do not do this for "r<CR>" or "grx".
+     */
+    if (cmdchar != 'r' && cmdchar != 'v')
+    {
+	if (cmdchar == 'R')
+	    ptr = (char_u *)"r";
+	else if (cmdchar == 'V')
+	    ptr = (char_u *)"v";
+	else
+	    ptr = (char_u *)"i";
+	set_vim_var_string(VV_INSERTMODE, ptr, 1);
+	apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf);
+    }
+#endif
+
 #ifdef FEAT_MOUSE
     /*
      * When doing a paste with the middle mouse button, Insstart is set to
@@ -725,6 +742,12 @@
 		break;
 	    }
 #endif
+#ifdef FEAT_AUTOCMD
+	    set_vim_var_string(VV_INSERTMODE,
+			   (char_u *)((State & REPLACE_FLAG) ? "i" :
+				    replaceState == VREPLACE ? "v" : "r"), 1);
+	    apply_autocmds(EVENT_INSERTCHANGE, NULL, NULL, FALSE, curbuf);
+#endif
 	    if (State & REPLACE_FLAG)
 		State = INSERT | (State & LANGMAP);
 	    else
@@ -859,7 +882,14 @@
 		o_lnum = curwin->w_cursor.lnum;
 
 	    if (ins_esc(&count, cmdchar))
+	    {
+#ifdef FEAT_AUTOCMD
+		if (cmdchar != 'r' && cmdchar != 'v')
+		    apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL,
+							       FALSE, curbuf);
+#endif
 		return (c == Ctrl_O);
+	    }
 	    continue;
 
 	/*
diff --git a/src/eval.c b/src/eval.c
index ce7bf09..5e40515 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -231,6 +231,7 @@
     {"throwpoint", sizeof("throwpoint") - 1, NULL, VAR_STRING, VV_RO},
     {"register", sizeof("register") - 1, NULL, VAR_STRING, VV_RO},
     {"cmdbang", sizeof("cmdbang") - 1, NULL, VAR_NUMBER, VV_RO},
+    {"insertmode", sizeof("insertmode") - 1, NULL, VAR_STRING, VV_RO},
 };
 
 static int eval0 __ARGS((char_u *arg,  VAR retvar, char_u **nextcmd, int evaluate));
@@ -4877,6 +4878,9 @@
 #ifdef FEAT_GUI_BEOS
 	"gui_beos",
 #endif
+#ifdef FEAT_GUI_KDE
+	"gui_kde",
+#endif
 #ifdef FEAT_GUI_GTK
 	"gui_gtk",
 # ifdef HAVE_GTK2
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 6713482..f9bd487 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -447,7 +447,13 @@
 	vim_free(q);
 	if (p == NULL)
 	    return FAIL;
-	bp->dbg_name = p;
+	if (*p != '*')
+	{
+	    bp->dbg_name = fix_fname(p);
+	    vim_free(p);
+	}
+	else
+	    bp->dbg_name = p;
 #ifdef MACOS_CLASSIC
 	if (bp->dbg_name != NULL)
 	    slash_n_colon_adjust(bp->dbg_name);
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index af8d3fc..27f4b9d 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -197,7 +197,7 @@
 #else
 # define ex_tearoff		ex_ni
 #endif
-#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU)
+#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU)
 static void	ex_popup __ARGS((exarg_T *eap));
 #else
 # define ex_popup		ex_ni
@@ -205,11 +205,11 @@
 #ifndef FEAT_GUI_MSWIN
 # define ex_simalt		ex_ni
 #endif
-#if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF)
+#if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) && !defined(FEAT_GUI_KDE)
 # define gui_mch_find_dialog	ex_ni
 # define gui_mch_replace_dialog ex_ni
 #endif
-#ifndef FEAT_GUI_GTK
+#if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_KDE)
 # define ex_helpfind		ex_ni
 #endif
 #ifndef FEAT_CSCOPE
@@ -258,7 +258,7 @@
 #else
 # define ex_wincmd	    ex_ni
 #endif
-#if defined(FEAT_GUI) || defined(UNIX) || defined(VMS)
+#if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN)
 static void	ex_winpos __ARGS((exarg_T *eap));
 #else
 # define ex_winpos	    ex_ni
@@ -6719,7 +6719,7 @@
 }
 #endif
 
-#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU)
+#if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_GTK)) && defined(FEAT_MENU)
     static void
 ex_popup(eap)
     exarg_T	*eap;
@@ -7108,7 +7108,7 @@
 }
 #endif
 
-#if defined(FEAT_GUI) || defined(UNIX) || defined(VMS)
+#if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN)
 /*
  * ":winpos".
  */
@@ -7122,8 +7122,12 @@
 
     if (*arg == NUL)
     {
-# ifdef FEAT_GUI
+# if defined(FEAT_GUI) || defined(MSWIN)
+#  ifdef FEAT_GUI
 	if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL)
+#  else
+	if (mch_get_winpos(&x, &y) != FAIL)
+#  endif
 	{
 	    sprintf((char *)IObuff, _("Window position: X %d, Y %d"), x, y);
 	    msg(IObuff);
@@ -7155,6 +7159,10 @@
 #  ifdef HAVE_TGETENT
 	else
 #  endif
+# else
+#  ifdef MSWIN
+	    mch_set_winpos(x, y);
+#  endif
 # endif
 # ifdef HAVE_TGETENT
 	if (*T_CWP)
diff --git a/src/feature.h b/src/feature.h
index 725c071..8ebe94f 100644
--- a/src/feature.h
+++ b/src/feature.h
@@ -689,13 +689,16 @@
  *			always has it).  But only if menus are enabled.
  */
 #if defined(FEAT_NORMAL) && defined(FEAT_MENU) \
-	&& (defined(FEAT_GUI_GTK) \
+	&& (defined(FEAT_GUI_KDE) \
+		|| defined(FEAT_GUI_GTK) \
 		|| defined(FEAT_GUI_MSWIN) \
 		|| ((defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \
 			&& defined(HAVE_XPM)) \
 		|| defined(FEAT_GUI_PHOTON))
 # define FEAT_TOOLBAR
 #endif
+
+
 #if defined(FEAT_TOOLBAR) && !defined(FEAT_MENU)
 # define FEAT_MENU
 #endif
@@ -706,7 +709,7 @@
  * BROWSE_CURRBUF	Open file browser in the directory of the current
  *			buffer, instead of the current directory.
  */
-#if defined(FEAT_NORMAL) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC))
+#if defined(FEAT_NORMAL) && (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC))
 # define FEAT_BROWSE
 #endif
 #if defined(FEAT_NORMAL) && defined(FEAT_GUI_MSWIN)
@@ -724,7 +727,8 @@
 	|| defined(FEAT_GUI_GTK) \
 	|| defined(FEAT_GUI_PHOTON) \
 	|| defined(FEAT_GUI_MSWIN) \
-	|| defined(FEAT_GUI_MAC)
+	|| defined(FEAT_GUI_MAC) \
+	|| defined(FEAT_GUI_KDE)
 #  define FEAT_CON_DIALOG
 #  define FEAT_GUI_DIALOG
 # else
@@ -732,13 +736,13 @@
 # endif
 #endif
 #if !defined(FEAT_GUI_DIALOG) && (defined(FEAT_GUI_MOTIF) \
-	|| defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK))
+	|| defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))
 /* need a dialog to show error messages when starting from the desktop */
 # define FEAT_GUI_DIALOG
 #endif
 #if defined(FEAT_GUI_DIALOG) && \
 	(defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA) \
-	 || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN) \
+	 || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)|| defined(FEAT_GUI_MSWIN) \
 	 || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC))
 # define FEAT_GUI_TEXTDIALOG
 #endif
@@ -931,7 +935,7 @@
  * +X11			Unix only.  Include code for xterm title saving and X
  *			clipboard.  Only works if HAVE_X11 is also defined.
  */
-#if defined(FEAT_NORMAL) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)
+#if (defined(FEAT_NORMAL) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA))
 # define WANT_X11
 #endif
 
@@ -1057,7 +1061,7 @@
 #  define MCH_CURSOR_SHAPE
 # endif
 # if defined(FEAT_GUI_W32) || defined(FEAT_GUI_W16) || defined(FEAT_GUI_MOTIF) \
-	|| defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) \
+	|| defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)\
 	|| defined(FEAT_GUI_PHOTON)
 #  define FEAT_MOUSESHAPE
 # endif
diff --git a/src/fileio.c b/src/fileio.c
index ce5ce41..92c1e98 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -6651,6 +6651,9 @@
     {"FocusLost",	EVENT_FOCUSLOST},
     {"FuncUndefined",	EVENT_FUNCUNDEFINED},
     {"GUIEnter",	EVENT_GUIENTER},
+    {"InsertChange",	EVENT_INSERTCHANGE},
+    {"InsertEnter",	EVENT_INSERTENTER},
+    {"InsertLeave",	EVENT_INSERTLEAVE},
     {"RemoteReply",	EVENT_REMOTEREPLY},
     {"StdinReadPost",	EVENT_STDINREADPOST},
     {"StdinReadPre",	EVENT_STDINREADPRE},
diff --git a/src/globals.h b/src/globals.h
index 6f53317..8a59f1c 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -722,6 +722,10 @@
 #endif /* FEAT_MBYTE */
 
 #ifdef FEAT_XIM
+# ifdef FEAT_GUI_KDE
+EXTERN colnr_T		preedit_start_col INIT(= MAXCOL);
+EXTERN char		*draw_feedback INIT(= NULL);
+# endif
 # ifdef FEAT_GUI_GTK
 #  ifdef HAVE_GTK2
 EXTERN GtkIMContext	*xic INIT(= NULL);
@@ -1112,6 +1116,10 @@
 EXTERN int	echo_wid_arg INIT(= FALSE);	/* --echo-wid argument */
 #endif
 
+#ifdef FEAT_GUI_KDE
+EXTERN int	echo_wid_arg INIT(= FALSE);
+# endif
+
 #ifdef FEAT_CLIENTSERVER
 EXTERN char_u	*serverName INIT(= NULL);	/* name of the server */
 EXTERN int	received_from_client INIT(= FALSE);	/* received text from
@@ -1321,7 +1329,7 @@
 #endif
 EXTERN char_u e_secure[]	INIT(=N_("E523: Not allowed here"));
 #if defined(AMIGA) || defined(MACOS) || defined(MSWIN) || defined(RISCOS) \
-	|| defined(UNIX) || defined(VMS)
+	|| defined(UNIX) || defined(VMS) || defined(OS2)
 EXTERN char_u e_screenmode[]	INIT(=N_("E359: Screen mode setting not supported"));
 #endif
 EXTERN char_u e_scroll[]	INIT(=N_("E49: Invalid scroll size"));
diff --git a/src/gui.c b/src/gui.c
index 3ffa225..c8930d8 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -97,7 +97,7 @@
 
     vim_free(old_term);
 
-#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
+#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_KDE)
     if (gui.in_use)
 	/* Display error messages in a dialog now. */
 	display_errors();
@@ -531,7 +531,7 @@
 	/* Our GUI can't do bidi. */
 	p_tbidi = FALSE;
 #endif
-#ifdef FEAT_GUI_GTK
+#if defined FEAT_GUI_GTK || defined FEAT_GUI_KDE
 	/* Give GTK+ a chance to put all widget's into place. */
 	gui_mch_update();
 	/* Now make sure the shell fits on the screen. */
@@ -575,7 +575,7 @@
     gui_mch_exit(rc);
 }
 
-#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_MSWIN) \
+#if defined(FEAT_GUI_KDE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_MSWIN) \
 	|| defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC) || defined(PROTO)
 /*
  * Called when the GUI shell is closed by the user.  If there are no changed
@@ -1058,7 +1058,7 @@
     void
 gui_position_menu()
 {
-# if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF)
+# if !defined(FEAT_GUI_KDE) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF)
     if (gui.menu_is_active && gui.in_use)
 	gui_mch_set_menu_pos(0, 0, gui.menu_width, gui.menu_height);
 # endif
@@ -1164,6 +1164,7 @@
     if (gui.menu_is_active)
 	base_height += gui.menu_height;
 # endif
+#ifndef FEAT_GUI_KDE
 # ifdef FEAT_TOOLBAR
     if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
 #  if defined(FEAT_GUI_MSWIN) && defined(FEAT_TOOLBAR)
@@ -1172,6 +1173,7 @@
 	base_height += gui.toolbar_height;
 #  endif
 # endif
+#endif
 # ifdef FEAT_FOOTER
     if (vim_strchr(p_go, GO_FOOTER) != NULL)
 	base_height += gui.footer_height;
@@ -1680,7 +1682,7 @@
      * We need to make sure this is cleared since Athena doesn't tell us when
      * he is done dragging.  Do the same for GTK.
      */
-#if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK)
+#if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
     gui.dragged_sb = SBAR_NONE;
 #endif
 
@@ -2071,7 +2073,7 @@
     if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC)))
 	return FAIL;
 
-#if defined(RISCOS) || defined(HAVE_GTK2)
+#if defined(RISCOS) || defined(HAVE_GTK2) || defined(FEAT_GUI_KDE)
     /* If there's no italic font, then fake it.
      * For GTK2, we don't need a different font for italic style. */
     if (hl_mask_todo & HL_ITALIC)
@@ -2141,7 +2143,7 @@
 	    /* print the string so far if it's the last character or there is
 	     * a composing character. */
 	    if (i + cl >= len || (comping && i > start) || dowide
-#  if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
+#  if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined (FEAT_GUI_KDE)
 		    || (cn > 1
 #   ifdef FEAT_XFONTSET
 			/* No fontset: At least draw char after wide char at
@@ -2173,8 +2175,9 @@
 		    start += cl;
 		}
 
-#  if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
-		/* No fontset: draw a space to fill the gap after a wide char */
+#  if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
+		/* No fontset: draw a space to fill the gap after a wide char
+		 * */
 		if (cn > 1 && (draw_flags & DRAW_TRANSP) == 0
 #   ifdef FEAT_XFONTSET
 			&& fontset == NOFONTSET
@@ -4056,8 +4059,9 @@
     if (*name == NUL)
 	return INVALCOLOR;
     t = gui_mch_get_color(name);
+
     if (t == INVALCOLOR
-#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
+#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
 	    && gui.in_use
 #endif
 	    )
@@ -4183,7 +4187,6 @@
 	add_to_input_buf(st, 8);
 	st[3] = (char_u)MOUSE_RELEASE;
 	add_to_input_buf(st, 8);
-
 #ifdef FEAT_GUI_GTK
 	/* Need to wake up the main loop */
 	if (gtk_main_level() > 0)
@@ -4301,7 +4304,7 @@
 }
 
 #if ((defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_W32) \
-	|| defined(FEAT_GUI_PHOTON)) && defined(FEAT_TOOLBAR)) || defined(PROTO)
+	|| defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_KDE)) && defined(FEAT_TOOLBAR)) || defined(PROTO)
 /*
  * This is shared between Athena, Motif and GTK.
  */
@@ -4364,7 +4367,7 @@
 # endif
 #endif
 
-#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(PROTO)
+#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_X11) || defined(PROTO)
     void
 display_errors()
 {
@@ -4410,7 +4413,7 @@
 
 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MOTIF) \
 	|| defined(MSWIN_FIND_REPLACE) || defined(FEAT_SUN_WORKSHOP) \
-	|| defined(PROTO)
+	|| defined(PROTO) || defined(FEAT_GUI_KDE)
 /*
  * Update the current window and the screen.
  */
@@ -4428,7 +4431,7 @@
 #endif
 
 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MOTIF) \
-	|| defined(MSWIN_FIND_REPLACE) || defined(PROTO)
+	|| defined(MSWIN_FIND_REPLACE) || defined(PROTO) || defined(FEAT_GUI_KDE)
 static void concat_esc __ARGS((garray_T *gap, char_u *text, int what));
 
 /*
diff --git a/src/gui.h b/src/gui.h
index 4357c46..02028f2 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -30,6 +30,23 @@
 # include "gui_beval.h"
 #endif
 
+#ifdef FEAT_GUI_KDE
+# include <X11/Intrinsic.h>
+
+/* used only as pointer to, so casting to int is ok */
+# ifdef __cplusplus
+class QScrollBar;
+class QPopupMenu;
+class QFont;
+class VimWidget;
+# else
+#  define QScrollBar int
+#  define QPopupMenu int
+#  define QFont int
+#  define VimWidget  int
+# endif
+#endif
+
 #ifdef FEAT_GUI_GTK
 # include <X11/Intrinsic.h>
 # include <gtk/gtk.h>
@@ -85,7 +102,7 @@
  * GUIs that support dropping files on a running Vim.
  */
 #if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MAC) \
-	|| defined(FEAT_GUI_BEOS) || defined(FEAT_GUI_GTK)
+	|| defined(FEAT_GUI_BEOS) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
 # define HAVE_DROP_FILE
 #endif
 
@@ -152,7 +169,7 @@
 #define DRAW_TRANSP		0x01	/* draw with transparant bg */
 #define DRAW_BOLD		0x02	/* draw bold text */
 #define DRAW_UNDERL		0x04	/* draw underline text */
-#if defined(RISCOS) || defined(HAVE_GTK2)
+#if defined(RISCOS) || defined(HAVE_GTK2) || defined (FEAT_GUI_KDE)
 # define DRAW_ITALIC		0x08	/* draw italic text */
 #endif
 #define DRAW_CURSOR		0x10	/* drawing block cursor (win32) */
@@ -171,7 +188,7 @@
 #endif
 #define TOOLBAR_BORDER_HEIGHT	12  /* room above+below buttons for MSWindows */
 
-#if defined(NO_CONSOLE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
+#if defined(NO_CONSOLE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_X11)
 # define NO_CONSOLE_INPUT	/* use no_console_input() to check if there
 				   is no console input possible */
 #endif
@@ -195,6 +212,9 @@
     int		width;		/* Current width of scroll bar in cols */
 #endif
     int		status_height;	/* Height of status line */
+#ifdef FEAT_GUI_KDE
+    QScrollBar *w;
+#endif
 #ifdef FEAT_GUI_X11
     Widget	id;		/* Id of real scroll bar */
 #endif
@@ -231,6 +251,12 @@
 				   displays there is a tiny chance this is an
 				   actual color */
 
+#ifdef FEAT_GUI_KDE
+  typedef QFont		*GuiFont;
+  typedef QFont		*GuiFontset;
+# define NOFONT		(GuiFont)NULL
+# define NOFONTSET	(GuiFontset)NULL
+#endif
 #ifdef FEAT_GUI_GTK
 # ifdef HAVE_GTK2
   typedef PangoFontDescription	*GuiFont;       /* handle for a GUI font */
@@ -254,10 +280,12 @@
 #   define NOFONT	(GuiFont)0
 #   define NOFONTSET	(GuiFontset)0
 #  else
+#   if !defined(FEAT_GUI_KDE)
   typedef long_u	GuiFont;	/* handle for a GUI font */
   typedef long_u	GuiFontset;	/* handle for a GUI fontset */
 #   define NOFONT	(GuiFont)0
 #   define NOFONTSET	(GuiFontset)0
+#   endif
 #  endif
 # endif
 #endif
@@ -375,6 +403,13 @@
     Bool	color_approx;	    /* Some color was approximated */
 #endif
 
+#ifdef FEAT_GUI_KDE
+    VimWidget   *w;                 /* Vim widget */
+    Display     *dpy;               /* X display */
+    QFont	*current_font;
+    char_u	*fontname;	    /* font name from font selection dialog */
+#endif
+
 #ifdef FEAT_GUI_GTK
     int		visibility;	    /* Is shell partially/fully obscured? */
     GdkCursor	*blank_pointer;	    /* Blank pointer */
@@ -507,7 +542,7 @@
 }
 gui_win_pos_T;
 
-#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \
+#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) \
 	|| defined(MSWIN_FIND_REPLACE)
 /*
  * Flags used to distinguish the different contexts in which the
diff --git a/src/gui_kde.cc b/src/gui_kde.cc
new file mode 100644
index 0000000..772e457
--- /dev/null
+++ b/src/gui_kde.cc
@@ -0,0 +1,587 @@
+/* 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$
+ *
+ */
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <kmenubar.h>
+#include <kfiledialog.h>
+#include <kiconloader.h>
+
+#include <qscrollbar.h>
+#include <qcursor.h>
+#include <qmessagebox.h>
+#include <qiconset.h>
+#include <qtextcodec.h>
+#include "gui_kde_widget.h"
+
+extern "C" {
+#include "vim.h"
+}
+
+#undef dbf
+#undef db
+#undef mputs
+
+#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
+
+
+#ifdef FEAT_TOOLBAR
+#ifndef FEAT_KDETOOLBAR
+/*
+ * Icons used by the toolbar code.
+ *///{{{
+#include "../pixmaps/tb_new.xpm"
+#include "../pixmaps/tb_open.xpm"
+#include "../pixmaps/tb_close.xpm"
+#include "../pixmaps/tb_save.xpm"
+#include "../pixmaps/tb_print.xpm"
+#include "../pixmaps/tb_cut.xpm"
+#include "../pixmaps/tb_copy.xpm"
+#include "../pixmaps/tb_paste.xpm"
+#include "../pixmaps/tb_find.xpm"
+#include "../pixmaps/tb_find_next.xpm"
+#include "../pixmaps/tb_find_prev.xpm"
+#include "../pixmaps/tb_find_help.xpm"
+#include "../pixmaps/tb_exit.xpm"
+#include "../pixmaps/tb_undo.xpm"
+#include "../pixmaps/tb_redo.xpm"
+#include "../pixmaps/tb_help.xpm"
+#include "../pixmaps/tb_macro.xpm"
+#include "../pixmaps/tb_make.xpm"
+#include "../pixmaps/tb_save_all.xpm"
+#include "../pixmaps/tb_jump.xpm"
+#include "../pixmaps/tb_ctags.xpm"
+#include "../pixmaps/tb_load_session.xpm"
+#include "../pixmaps/tb_save_session.xpm"
+#include "../pixmaps/tb_new_session.xpm"
+#include "../pixmaps/tb_blank.xpm"
+#include "../pixmaps/tb_maximize.xpm"
+#include "../pixmaps/tb_split.xpm"
+#include "../pixmaps/tb_minimize.xpm"
+#include "../pixmaps/tb_shell.xpm"
+#include "../pixmaps/tb_replace.xpm"
+#include "../pixmaps/tb_vsplit.xpm"
+#include "../pixmaps/tb_maxwidth.xpm"
+#include "../pixmaps/tb_minwidth.xpm"
+//}}}
+/*
+ * These are the pixmaps used for the default buttons.
+ * Order must exactly match toolbar_names[] in menu.c!
+ *///{{{
+static char **(built_in_pixmaps[]) =
+{
+	tb_new_xpm,
+	tb_open_xpm,
+	tb_save_xpm,
+	tb_undo_xpm,
+	tb_redo_xpm,
+	tb_cut_xpm,
+	tb_copy_xpm,
+	tb_paste_xpm,
+	tb_print_xpm,
+	tb_help_xpm,
+	tb_find_xpm,
+	tb_save_all_xpm,
+	tb_save_session_xpm,
+	tb_new_session_xpm,
+	tb_load_session_xpm,
+	tb_macro_xpm,
+	tb_replace_xpm,
+	tb_close_xpm,
+	tb_maximize_xpm,
+	tb_minimize_xpm,
+	tb_split_xpm,
+	tb_shell_xpm,
+	tb_find_prev_xpm,
+	tb_find_next_xpm,
+	tb_find_help_xpm,
+	tb_make_xpm,
+	tb_jump_xpm,
+	tb_ctags_xpm,
+	tb_vsplit_xpm,
+	tb_maxwidth_xpm,
+	tb_minwidth_xpm,
+	tb_exit_xpm
+};//}}}
+#else
+const char *kdeicons[] = {
+	"filenew",
+	"fileopen",
+	"filesave",
+	"undo",
+	"redo",
+	"editcut",
+	"editcopy",
+	"editpaste",
+	"fileprint",
+	"contents2",
+	"filefind",
+	"save_all",
+	"fileexport",
+	"filenew",
+	"fileimport",
+	"run",
+	"edit",
+	"fileclose",
+	"",
+	"",
+	"split",
+	"openterm",
+	"previous",
+	"next",
+	"help",
+	"make",
+	"goto",
+	"run",
+	"vsplit",
+	"maxwidth",
+	"minwidth",
+	"quit"
+};
+#endif
+/*
+ * creates a blank pixmap using tb_blank
+ */
+	QPixmap
+pixmap_create_from_xpm(char **xpm)//{{{
+{
+	return(QPixmap((const char **)xpm));
+}//}}}
+
+/*
+ * creates a pixmap by using a built-in number
+ */
+	QPixmap
+pixmap_create_by_num(int pixmap_num)//{{{
+{
+#ifdef FEAT_KDETOOLBAR
+	if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(kdeicons)
+				/ sizeof(kdeicons[0])) - 1) {
+
+		KIconLoader *il = kapp->iconLoader(); //new KIconLoader();
+		QString icon;
+		icon=QString(kdeicons[pixmap_num]);
+		return il->loadIcon(icon,KIcon::MainToolbar);
+	}
+	return QPixmap();
+#else
+	if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(built_in_pixmaps)
+				/ sizeof(built_in_pixmaps[0])) - 1)
+		return pixmap_create_from_xpm(built_in_pixmaps[pixmap_num]);
+	else return QPixmap();
+#endif
+}//}}}
+
+/*
+ * Creates a pixmap by using the pixmap "name" found in 'runtimepath'/bitmaps/
+ */
+	QPixmap
+pixmap_create_by_dir(char_u *name)//{{{
+{
+	char_u full_pathname[MAXPATHL + 1];
+
+	if (gui_find_bitmap(name, full_pathname, "xpm") == OK) {
+		return QPixmap((const char *)full_pathname);
+	}
+	else return QPixmap();
+}//}}}
+
+
+	QPixmap
+pixmap_create_from_file(char_u *file)
+{
+	return QPixmap((const char*)file);
+}
+#endif
+
+	void
+gui_mch_add_menu(vimmenu_T * menu, int idx)//{{{
+{
+#ifdef FEAT_MENU
+	QPopupMenu *me;
+	vimmenu_T *parent = menu->parent;
+
+	if (menu_is_popup(menu->name)) {
+		menu->widget = new QPopupMenu(vmw , (const char *) menu->name);
+		QObject::connect( menu->widget, SIGNAL(activated(int)), vmw, SLOT(menu_activated(int)) );
+		return;
+	}
+
+	if (!menu_is_menubar(menu->name))
+		return;
+
+	if (parent) {
+		idx++; // for tearoffs to be first in menus
+		me = new QPopupMenu(parent->widget, (const char *) menu->name);
+		parent->widget->insertItem( QString((const char *)menu->name), me, (int)me, idx);
+	} else {
+		me = new QPopupMenu(vmw->menuBar() , (const char *) menu->name);
+		vmw->menuBar()->insertItem( QString((const char *)menu->name), me , (int) me, idx);
+	}
+
+	me->setCaption((const char*)( menu->dname  ));
+	if (vmw->have_tearoff) me->insertTearOffHandle(0,0);
+	QObject::connect( me, SIGNAL(activated(int)), vmw, SLOT(menu_activated(int)) );
+	menu->widget = me;
+#endif
+}//}}}
+
+
+	void
+gui_mch_add_menu_item(vimmenu_T * menu, int idx)//{{{
+{
+#ifdef FEAT_MENU
+	vimmenu_T *parent = menu->parent;
+#ifdef FEAT_TOOLBAR
+	if (menu_is_toolbar(parent->name)) {
+		QPixmap pix;
+		if ( menu_is_separator(menu->name) )
+		{
+			vmw->toolBar()->insertSeparator();
+			return;
+		}
+		if (menu->iconfile != NULL) {
+			pix = pixmap_create_from_file(menu->iconfile);
+		}
+		if (!menu->icon_builtin) {
+			pix = pixmap_create_by_dir(menu->name);
+		}
+		if (pix.isNull() && menu->iconidx >= 0) {
+			pix = pixmap_create_by_num(menu->iconidx);
+		}
+#ifndef FEAT_KDETOOLBAR
+		if (pix.isNull()) {
+			pix = pixmap_create_from_xpm(tb_blank_xpm);
+		}
+#endif
+		if (pix.isNull()) return; // failed
+		vmw->toolBar()->insertButton (
+				pix,
+				(int) menu , // id
+				true,
+				(char *) (menu->strings[MENU_INDEX_TIP]) , // tooltip or text
+				idx
+				);
+		menu->parent=parent;
+		return;
+	}
+#endif // FEAT_TOOLBAR
+
+	idx++;
+	if ( menu_is_separator(menu->name) ) {
+		parent->widget->insertSeparator();
+		return;
+	}
+	parent->widget->insertItem(QString((const char *)menu->name), (int)menu, idx );
+#endif
+}//}}}
+
+
+	void
+gui_mch_set_text_area_pos(int x, int y, int w, int h)//{{{
+{
+	int X = 0;
+	int Y = 0;
+	if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
+#if QT_VERSION>=300
+		       	&& !vmw->menuBar()->isTopLevelMenu()
+#endif
+			)
+		Y += vmw->menuBar()->height();
+#ifdef FEAT_TOOLBAR
+	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
+			vmw->toolBar()->barPos()==KToolBar::Top)
+		Y += vmw->toolBar()->height();
+
+	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
+			vmw->toolBar()->barPos()==KToolBar::Left)
+		X += vmw->toolBar()->width();
+#endif // FEAT_TOOLBAR
+
+	gui.w->setGeometry(x+X,y+Y,w,h);
+}//}}}
+
+
+#if defined(FEAT_MENU) || defined(PROTO)
+/*
+ * Enable or disable mnemonics for the toplevel menus.
+ */
+	void
+gui_gtk_set_mnemonics(int enable)//{{{ // TO BE REMOVED
+{
+}//}}}
+
+	void
+toggle_tearoffs(vimmenu_T *menu, int enable)//{{{
+{
+	while (menu != NULL) {
+		if (!menu_is_popup(menu->name)) {
+			if (menu->widget != 0) {
+				if (enable) menu->widget->insertTearOffHandle(0,0);
+				else menu->widget->removeItem(0);
+			}
+			toggle_tearoffs(menu->children, enable);
+		}
+		menu = menu->next;
+	}
+}//}}}
+
+	void
+gui_mch_toggle_tearoffs(int enable)//{{{
+{
+	vmw->have_tearoff=enable;
+	toggle_tearoffs(root_menu, enable);
+}//}}}
+#endif
+
+
+#if defined(FEAT_MENU) || defined(PROTO)
+/*
+ * Destroy the machine specific menu widget.
+ */
+	void
+gui_mch_destroy_menu(vimmenu_T * menu)//{{{
+{
+#ifdef FEAT_TOOLBAR
+	if (menu->parent && menu_is_toolbar(menu->parent->name)) {
+		vmw->toolBar()->removeItem( (int) menu );
+		return;
+	}
+#endif
+	if(menu->parent){
+		menu->parent->widget->removeItem((int)menu );
+	}
+	if (menu->widget){
+		delete menu->widget;
+	}
+	menu->widget = 0;
+}//}}}
+#endif /* FEAT_MENU */
+
+
+/*
+ * Scrollbar stuff.
+ */
+
+	void
+gui_mch_set_scrollbar_thumb(scrollbar_T * sb, long val, long size, long max)//{{{
+{
+	if (!sb->w) return;
+
+	sb->w->setRange(0, max+1-size);
+	sb->w->setValue(val);
+
+	sb->w->setLineStep(1);
+	sb->w->setPageStep(size);
+}//}}}
+
+	void
+gui_mch_set_scrollbar_pos(scrollbar_T * sb, int x, int y, int w, int h)//{{{
+{
+	if (!sb->w) return;
+	//we add the menubar and toolbar height/width
+	int X = 0;
+	int Y = 0;
+
+	if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
+#if QT_VERSION>=300
+		       	&& !vmw->menuBar()->isTopLevelMenu()
+#endif
+			)
+		Y += vmw->menuBar()->height();
+#ifdef FEAT_TOOLBAR
+	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
+			vmw->toolBar()->barPos()==KToolBar::Top)
+		Y += vmw->toolBar()->height();
+
+	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
+			vmw->toolBar()->barPos()==KToolBar::Left)
+		X += vmw->toolBar()->width();
+#endif //FEAT_TOOLBAR
+	if (sb->w->orientation() == Qt::Vertical) {
+		bool leftscroll=gui.which_scrollbars[SBAR_LEFT];
+		bool rightscroll=gui.which_scrollbars[SBAR_RIGHT];
+		if (x<20)  leftscroll=true;
+		else rightscroll=true;
+		if (x<20) sb->w->setGeometry(X,y+Y,w,h);
+		else sb->w->setGeometry(vmw->width()-w-1+X, y+Y,w,h);
+	} else {
+		sb->w->setGeometry(x+X,y+Y,w,h);
+	}
+}//}}}
+
+/* SBAR_VERT or SBAR_HORIZ */
+	void
+gui_mch_create_scrollbar(scrollbar_T * sb, int orient)//{{{
+{
+	sbpool->create(sb,orient);
+	if (orient==SBAR_VERT)
+		gui.scrollbar_width = sb->w->sizeHint().width();
+	else
+		gui.scrollbar_height = sb->w->sizeHint().height();
+}//}}}
+
+	void
+gui_mch_destroy_scrollbar(scrollbar_T * sb)//{{{
+{
+	sbpool->destroy(sb);
+}//}}}
+
+#if defined(FEAT_BROWSE) || defined(PROTO)
+/*
+ * Implementation of the file selector related stuff
+ */
+
+/*
+ * Put up a file requester.
+ * Returns the selected name in allocated memory, or NULL for Cancel.
+ * saving,			select file to write
+ * title			title for the window
+ * dflt				default name
+ * ext				not used (extension added)
+ * initdir			initial directory, NULL for current dir
+ * filter			not used (file name filter)
+ */
+/*ARGSUSED*/
+char_u *
+gui_mch_browse(int saving,//{{{
+		char_u * title,
+		char_u * dflt,
+		char_u * ext,
+		char_u * initdir,
+		char_u * filter)
+{
+	char * filt_glob;
+	if (filter != (char_u *) 0x0 ) {
+		filter = vim_strsave(filter);
+		strtok((char *) filter, "(");
+		filt_glob = strtok(0L, ")");
+	} else
+		filt_glob = (char *) filter;
+	
+	gui_mch_mousehide(FALSE);
+
+	QString s;
+	if (! saving)
+		s = KFileDialog::getOpenFileName( (char *) initdir, (char *) filt_glob, vmw, (char *) title );
+	else
+		s = KFileDialog::getSaveFileName( );
+	
+	if (filter)
+		vim_free(filter);
+
+	if (s.isNull())
+		return NULL;
+	QCString unistring = vmw->codec->fromUnicode(s);
+	char_u * s2 = (char_u *)(const char*)unistring;
+	if (s2)
+		s2 = vim_strsave( s2 );
+
+	return s2;
+}//}}}
+
+#endif	/* FEAT_BROWSE */
+
+#ifdef FEAT_GUI_DIALOG
+
+/* ARGSUSED */
+int
+gui_mch_dialog(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)
+{
+	gui_mch_mousehide(FALSE);
+	VimDialog vd(type, title, message, buttons, def_but,textfield);
+	int ret = vd.exec();
+	return ret;
+}//}}}
+
+
+#endif	/* FEAT_GUI_DIALOG */
+
+#if defined(FEAT_MENU) || defined(PROTO)
+	void
+gui_mch_show_popupmenu(vimmenu_T * menu)//{{{
+{
+	menu->widget->popup(QCursor::pos());
+}//}}}
+
+void
+gui_make_popup (char_u *pathname) {//{{{
+	vimmenu_T *menu = gui_find_menu(pathname);
+
+	if (menu != NULL) {
+		menu->widget->popup(QCursor::pos());
+	}
+}//}}}
+#endif
+
+
+
+/* Find and Replace implementations */
+	void
+gui_mch_find_dialog(exarg_T * eap)//{{{
+{
+	// char_u* entry_text;
+	//int exact_word=FALSE;
+	//    entry_text = get_find_dialog_text(eap->arg,&exact_word);
+
+	vmw->finddlg->setCaseSensitive(true);
+
+	/*    if(entry_text!=NULL) {
+	      vmw->finddlg->setText(QString((char*)entry_text));
+	// exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
+	}*/ // Don't use it, KDE keeps old search in memory and vim give \\Csearch, which is difficult to handle
+	//   vim_free(entry_text);
+
+	vmw->finddlg->show();
+}//}}}
+
+	void
+gui_mch_replace_dialog(exarg_T * eap)//{{{
+{
+	//  char_u* entry_text;
+	//int exact_word=FALSE;
+
+	//    entry_text = get_find_dialog_text(eap->arg,&exact_word);
+
+	/*    if(entry_text!=NULL) {
+	      vmw->repldlg->setText(QString((char*)entry_text));
+	// exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
+	}*/
+	//vim_free(entry_text);
+
+	vmw->repldlg->show();
+}//}}}
+
+	void
+ex_helpfind(exarg_T *eap)//{{{
+{
+	do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp");
+}//}}}
diff --git a/src/gui_kde_widget.cc b/src/gui_kde_widget.cc
new file mode 100644
index 0000000..c2e9e7c
--- /dev/null
+++ b/src/gui_kde_widget.cc
@@ -0,0 +1,1396 @@
+/* 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")
+{
+    //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;
+}//}}}
+
+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();
+}
diff --git a/src/gui_kde_widget.h b/src/gui_kde_widget.h
new file mode 100644
index 0000000..f2e9c3f
--- /dev/null
+++ b/src/gui_kde_widget.h
@@ -0,0 +1,234 @@
+/* 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
+	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
+
+	/* cursor blinking stuff */
+	QTimer blink_timer;
+	long blink_wait_time, blink_on_time, blink_off_time;
+
+	/* wait for input */
+	QTimer	wait_timer;
+
+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
diff --git a/src/gui_kde_x11.cc b/src/gui_kde_x11.cc
new file mode 100644
index 0000000..b3f3aa1
--- /dev/null
+++ b/src/gui_kde_x11.cc
@@ -0,0 +1,1307 @@
+/* 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 <qscrollbar.h>
+#include <qcstring.h>
+#include <qdatetime.h>
+#include <qcursor.h>
+#include <qfontmetrics.h>
+#include <qpaintdevice.h>
+#include <qclipboard.h>
+#include <qregexp.h>
+#include <kaboutkde.h>
+#include <kiconloader.h>
+#include <kfontdialog.h>
+#include <kmessagebox.h>
+#include <dcopclient.h>
+#include <kwin.h>
+#include <kmenubar.h>
+#include <kconfig.h>
+#if (QT_VERSION>=300)
+#include <qnamespace.h>
+#include <ktip.h>
+#endif
+#include <qpopupmenu.h>
+#include <qpainter.h>
+#include <qtextcodec.h>
+#include <qfontmetrics.h>
+#include <qfont.h>
+
+
+#include "gui_kde_widget.h"
+
+
+extern "C" {
+#include "vim.h"
+#include "version.h"
+}
+
+#include <stdio.h>
+
+/*
+ * global variable for KDE, we can't put them in Gui, cause there are C++ types
+ */
+VimMainWindow	*vmw=0;
+SBPool		*sbpool=0;
+QString      *argServerName=0;
+
+#ifdef FEAT_MOUSESHAPE
+/* The last set mouse pointer shape is remembered, to be used when it goes
+ * from hidden to not hidden. */
+static int last_shape = 0;
+#endif
+
+/*
+ * Arguments handled by KDE internally.
+ */
+
+#if QT_VERSION>=300
+static int tip=0; // 1 no dialog, 0 use it if enabled in conf, 2 force the tip
+#endif
+static int reverse=0; // 0 bg : white, 1 : bg : black
+QString         *startfont;
+QSize           *startsize;
+static int gui_argc = 0;
+static char **gui_argv = NULL;
+
+/*
+ * Parse the GUI related command-line arguments.  Any arguments used are
+ * deleted from argv, and *argc is decremented accordingly.  This is called
+ * when vim is started, whether or not the GUI has been started.
+ */
+	void
+gui_mch_prepare(int *argc, char **argv)// {{{
+{
+	//copy args for KDE/Qt
+	gui_argc = 0;
+	//this one is not really good as all options are not for KDE/Qt ...
+	gui_argv = (char **)lalloc((long_u)(*argc * sizeof(char *)), FALSE);
+	if (gui_argv == NULL)
+	    return;
+	gui_argv[gui_argc++] = argv[0];
+
+	int found = 0;
+	for (int i = 1; i < *argc ; i++)
+	{
+		if (found!=2)
+		    found = 0;
+		else {
+		    found=0;
+		    //remove from the list of argv
+		    if (--*argc>i) {
+			mch_memmove(&argv[i], &argv[i + 1],
+				(*argc - i) * sizeof(char *));
+		    }
+		    i--;
+		    continue;
+		}
+	
+		if (strcmp(argv[i],"--servername")==0) {
+			argServerName = new QString(argv[i+1]); // to get the serverName now
+		}
+#if QT_VERSION>+300
+		if (strcmp(argv[i],"-tip")==0 ) {
+			tip=2;
+			found=1;
+		}
+		if (strcmp(argv[i],"-notip")==0 ) {
+			tip=1;
+			found=1;
+		}
+#endif
+		if (strcmp(argv[i],"-black")==0 ) {
+			reverse=1;
+			found=1;
+		}
+		/* replaced by -black */
+/*		if (strcmp(argv[i],"-rv")==0 ) {
+			reverse=1;
+			found=1;
+		}*/
+		if (strcmp(argv[i],"-font")==0 || strcmp(argv[i], "-fn")==0 ) {
+			startfont=new QString(argv[i+1]);
+			found=2;
+		}
+		if (strcmp(argv[i],"-geometry")==0 || strcmp (argv[i],"-geom")==0 ) {
+			found=2;
+			QString text(argv[i+1]);
+			QStringList list = QStringList::split(QChar('x'), text);
+			startsize = new QSize(list[0].toInt(),list[1].toInt());
+		}
+		if (strcmp (argv[i],"-display")==0 ) { //XXX: this does not work,
+							// too many -display options in main.c !
+							// ask Bram ...
+			gui_argv[gui_argc++] = strdup("--display");
+			gui_argv[gui_argc++] = argv[i+1];
+			found=0;
+		}
+		if (strcmp (argv[i],"--display")==0 ) {
+			gui_argv[gui_argc++] = argv[i];
+			gui_argv[gui_argc++] = argv[i+1];
+			found=2;
+		}
+		//KDE/Qt options with no args
+		if (strcmp(argv[i],"--help-kde")==0 || strcmp (argv[i],"--help-qt")==0
+			|| strcmp(argv[i], "--help-all")==0
+			|| strcmp(argv[i], "--reverse")==0
+			|| strcmp(argv[i], "--author")==0
+//			|| strcmp(argv[i], "--version")==0 //disabled we need these for kcmvim
+//			|| strcmp(argv[i], "-v")==0
+			|| strcmp(argv[i], "--license")==0
+			|| strcmp(argv[i], "--cmap")==0
+			|| strcmp(argv[i], "--nograb")==0
+			|| strcmp(argv[i], "--dograb")==0
+			|| strcmp(argv[i], "--sync")==0
+			|| strcmp(argv[i], "--noxim")==0
+			|| strcmp(argv[i], "--nocrashhandler")==0
+			|| strcmp(argv[i], "--waitforwm")==0
+		 ) {
+			gui_argv[gui_argc++] = argv[i];
+			found=1;
+		}
+		//this outputs KDE and Vim versions :)
+		if (strcmp(argv[i],"--version")==0
+			|| strcmp (argv[i],"-v")==0
+		) {
+			gui_argv[gui_argc++] = argv[i];
+		}
+	
+
+		//KDE/Qt options with one arg
+		if ( strcmp(argv[i],"--session")==0
+		    || strcmp(argv[i],"--ncols")==0
+		    || strcmp(argv[i],"--bg")==0
+		    || strcmp(argv[i],"--background")==0
+		    || strcmp(argv[i],"--fg")==0
+		    || strcmp(argv[i],"--foreground")==0
+		    || strcmp(argv[i],"--btn")==0
+		    || strcmp(argv[i],"--name")==0
+		    || strcmp(argv[i],"--title")==0
+		    || strcmp(argv[i],"--inputstyle")==0
+		    || strcmp(argv[i],"--im")==0
+		    || strcmp(argv[i],"--caption")==0
+		    || strcmp(argv[i],"--icon")==0
+		    || strcmp(argv[i],"--miniicon")==0
+		    || strcmp(argv[i],"--config")==0
+		    || strcmp(argv[i],"--dcopserver")==0
+		    || strcmp(argv[i],"--style")==0
+		    || strcmp(argv[i],"--geometry")==0
+		    || strcmp(argv[i],"--smkey")==0
+		    || strcmp(argv[i],"-smkey")==0
+		    || strcmp(argv[i],"-session")==0
+		 ) {
+			gui_argv[gui_argc++] = argv[i];
+			gui_argv[gui_argc++] = argv[i+1];
+			found=2;
+		}
+	
+		//remove from the list of argv
+		if (found >= 1 && --*argc>i) {
+			mch_memmove(&argv[i], &argv[i + 1],
+					(*argc - i) * sizeof(char *));
+			i--;
+		}
+	}
+	KCmdLineArgs::init( gui_argc,gui_argv,"kvim", I18N_NOOP("Vim inside KDE"),VIM_VERSION_SHORT);
+}// }}}
+
+/****************************************************************************
+ * Focus handlers:
+ */
+
+/*
+ * Initialises time intervals for the cursor blinking
+ */
+	void
+gui_mch_set_blinking(long waittime, long on, long off)//{{{
+{
+	gui.w->set_blink_time( waittime, on, off );
+}//}}}
+
+/*
+ * Stop the cursor blinking.  Show the cursor if it wasn't shown.
+ */
+	void
+gui_mch_stop_blink()//{{{
+{
+	gui.w->stop_cursor_blinking();
+}//}}}
+
+/*
+ * Start the cursor blinking.  If it was already blinking, this restarts the
+ * waiting time and shows the cursor.
+ */
+	void
+gui_mch_start_blink()//{{{
+{
+	gui.w->start_cursor_blinking();
+}//}}}
+
+/*
+ * Check if the GUI can be started.  Called before gvimrc is sourced.
+ * Return OK or FAIL.
+ */
+	int
+gui_mch_init_check(void)//{{{
+{
+	gui.dpy = qt_xdisplay();
+	return OK;
+}//}}}
+
+/*
+ * Initialise the X GUI.  Create all the windows, set up all the call-backs etc.
+ * Returns OK for success, FAIL when the GUI can't be started.
+ */
+	int
+gui_mch_init()//{{{
+{
+	(void) new KApplication();
+	KApplication::kApplication()->dcopClient()->registerAs(KApplication::kApplication()->name(),false);
+//    dbf("%s %s",KGlobal::locale()->language().latin1(),KLocale::defaultLanguage().latin1());
+
+	vmw = new VimMainWindow("KVim",0);
+	vmw->setFrameBorderWidth(0);
+	kapp->setMainWidget(vmw);
+	kapp->setTopWidget(vmw);
+
+	sbpool = new SBPool;
+
+#if QT_VERSION>=300
+	vmw->connect(kapp->clipboard(),SIGNAL(selectionChanged()),vmw,SLOT(clipboard_selection_update()));
+#endif
+	vmw->connect(kapp->clipboard(),SIGNAL(dataChanged()),vmw,SLOT(clipboard_data_update()));
+	clip_lose_selection(&clip_plus);
+	clip_lose_selection(&clip_star);
+
+	gui.in_focus = FALSE; // will be updated
+
+	if (reverse) {
+		gui.def_norm_pixel = gui_get_color((char_u *)"White");
+		gui.def_back_pixel = gui_get_color((char_u *)"Black");
+#if QT_VERSION>=300
+		gui.w->setEraseColor ( QColor(Qt::black) );
+#else
+		gui.w->setBackgroundColor ( QColor(Qt::black) );
+#endif
+	} else {
+		gui.def_norm_pixel = gui_get_color((char_u *)"Black");
+		gui.def_back_pixel = gui_get_color((char_u *)"White");
+#if QT_VERSION>=300
+		gui.w->setEraseColor ( QColor(Qt::white) );
+#else
+		gui.w->setBackgroundColor ( QColor(Qt::white) );
+#endif
+	}
+
+	gui.norm_pixel = gui.def_norm_pixel;
+	gui.back_pixel = gui.def_back_pixel;
+
+	gui.border_width  = 1;
+	gui.border_offset = 1;//gui.border_width;
+	gui.scrollbar_width=SB_DEFAULT_WIDTH;
+	gui.scrollbar_height=SB_DEFAULT_WIDTH;
+
+	//gui.menu_height=vmw->menuBar()->height()+1;
+	//gui.toolbar_height=vmw->toolBar()->height();
+
+	return OK;
+}//}}}
+
+
+/*
+ * Called when the foreground or background color has been changed.
+ */
+	void
+gui_mch_new_colors()//{{{
+{
+	QColor rgb;
+	rgb.setRgb(gui.back_pixel);
+#if QT_VERSION>=300
+	gui.w->setEraseColor(rgb);
+#else
+	gui.w->setBackgroundColor(rgb);
+#endif
+}//}}}
+
+/*
+ * Open the GUI window which was created by a call to gui_mch_init().
+ */
+	int
+gui_mch_open()//{{{
+{
+        gui.dpy=qt_xdisplay();
+	set_normal_colors();
+
+	/* Check that none of the colors are the same as the background color */
+	gui_check_colors();
+
+	/* Get the colors for the highlight groups (gui_check_colors() might have
+	 * changed them).
+	 */
+	highlight_gui_started();    /* re-init colors and fonts */
+#ifdef FEAT_MENU
+	vmw->w->menu = new QPopupMenu(vmw);
+
+#if QT_VERSION>=300
+	vmw->w->menu->insertItem(SmallIcon("ktip"), i18n("&Tip of the day..."), vmw, SLOT(showTipOfTheDay()));
+	vmw->w->menu->insertSeparator();
+#endif
+	if (vmw->have_tearoff) vmw->w->menu->insertTearOffHandle(0,0);
+	vmw->w->menu->insertItem(i18n("&Report Bug ..."), vmw, SLOT(showBugReport()));
+	vmw->w->menu->insertSeparator();
+	vmw->w->menu->insertItem(SmallIcon("kvim"), i18n("&About KVim..."), vmw, SLOT(showAboutApplication()));
+	vmw->w->menu->insertItem(SmallIcon("about_kde"), i18n("About &KDE..."), vmw, SLOT(showAboutKDE()));
+	vmw->menuBar()->insertItem("&KVim", vmw->w->menu);
+#endif
+	if (startfont!=NULL)
+	    gui_mch_init_font((char_u*)startfont->latin1(),0);
+	
+	if (startsize!=NULL)
+	    vmw->resize(startsize->width(), startsize->height());
+
+	gui_mch_update_codec();
+
+	if (kapp->isRestored())
+	    if (KMainWindow::canBeRestored(1))
+		vmw->restore(1);
+	
+	vmw->show();
+#if QT_VERSION>=300
+	if (tip==2) KTipDialog::showTip (vmw,QString::null,true);
+	else if (tip==0) KTipDialog::showTip (vmw);
+#endif
+
+	return OK;
+}//}}}
+
+	void
+gui_mch_exit(int rc)//{{{
+{
+	kapp->quit();
+}//}}}
+
+/*
+ * Get the position of the top left corner of the window.
+ */
+	int
+gui_mch_get_winpos(int *x, int *y)//{{{
+{
+	*x = vmw->x();
+	*y = vmw->y();
+	return OK;
+}//}}}
+
+/*
+ * Set the position of the top left corner of the window to the given
+ * coordinates.
+ */
+	void
+gui_mch_set_winpos(int x, int y)//{{{
+{
+	vmw->move(x,y);
+}//}}}
+
+/*
+ * Set the windows size.
+ * ->resize VimWidget
+ * ->resize vmw (block any events generated from here)
+ */
+void
+gui_mch_set_shellsize(int width, int height,//{{{
+		int min_width, int min_height,
+		int base_width, int base_height)
+{
+	//resize VimWidget
+	vmw->w->resize(width,height);
+
+	//resize vmw
+	int vheight, vwidth;
+	vheight = height;
+	vwidth = width;
+
+	if (gui.which_scrollbars[SBAR_LEFT]) vwidth+=gui.scrollbar_width;
+	if (gui.which_scrollbars[SBAR_RIGHT]) vwidth+=gui.scrollbar_width;
+	if (gui.which_scrollbars[SBAR_BOTTOM]) vheight+=gui.scrollbar_height;
+
+	if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
+#if QT_VERSION>=300
+		&& !vmw->menuBar()->isTopLevelMenu()
+#endif
+		)
+	    vheight += vmw->menuBar()->height();
+#ifdef FEAT_TOOLBAR
+	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
+		(vmw->toolBar()->barPos()==KToolBar::Top ||
+		 vmw->toolBar()->barPos()==KToolBar::Bottom))
+	    vheight += vmw->toolBar()->height();
+
+	if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() &&
+		(vmw->toolBar()->barPos()==KToolBar::Left ||
+		 vmw->toolBar()->barPos()==KToolBar::Right))
+	    vwidth += vmw->toolBar()->width();
+#endif
+	vmw->lock();
+	vmw->resize(vwidth,vheight);
+	gui_mch_update();
+	//size should be nearly perfect, update baseSize and sizeIncrement
+	vmw->setBaseSize(base_width,vmw->menuBar()->height()+1+vmw->toolBar()->height()+gui.char_height*2);
+	vmw->setSizeIncrement( ( ( int )( gui.char_width/2 )*2 ),gui.char_height);
+	vmw->unlock();
+}//}}}
+
+
+/*
+ * The screen size is used to make sure the initial window doesn't get bigger
+ * then the screen.  This subtracts some room for menubar, toolbar and window
+ * decorations.
+ */
+	void
+gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)//{{{
+{
+	*screen_w = kapp->desktop()->width();
+	*screen_h = kapp->desktop()->height();
+}//}}}
+
+#if defined(FEAT_MENU) || defined(PROTO)
+	void
+gui_mch_enable_menu(int showit)//{{{
+{
+	if (showit)
+		vmw->menuBar()->show();
+	else
+		vmw->menuBar()->hide();
+	vmw->resize(vmw->width(),vmw->height());
+}//}}}
+#endif
+
+
+#if defined(FEAT_TOOLBAR) || defined(PROTO)
+	void
+gui_mch_show_toolbar(int showit)//{{{
+{
+	if (showit)
+		vmw->toolBar()->show();
+	else
+		vmw->toolBar()->hide();
+	vmw->resize(vmw->width(),vmw->height());
+}//}}}
+#endif
+
+/*
+ * Put up a font dialog and return the selected font name in allocated memory.
+ * "oldval" is the previous value.
+ * Return NULL when cancelled.
+ */
+
+char_u *gui_mch_font_dialog (char_u *oldval)//{{{
+{
+	QFont myFont( vmw->w->font() );
+	if (gui.fontname) {
+		gui.fontname=NULL;
+	}
+	int result = KFontDialog::getFont( myFont, true );
+	if ( result != KFontDialog::Accepted ) {
+		return NULL;
+	}
+//	myFont.setFixedPitch(true);
+#if QT_VERSION>=300
+	QString n = myFont.toString();
+#else
+	QString n = KVimUtils::toString(&myFont);
+#endif
+	n.replace(QRegExp(","),"/");
+	gui.fontname = (char_u *)strdup((const char *)n);
+	n.replace(QRegExp(" "),"\\ ");
+	n=QString("To set this font as your default font for KVim, edit your ~/.gvimrc file and add the following lines : \nif has(\"gui_kde\")\nset guifont=")+n+QString("\nendif");// \n OR \n use the control center of KDE and choose the correct fixed font");
+
+	//display a message box which explains how to save your font settings
+	KMessageBox::information(vmw, n,"Font Selection", "kvimselectfont");
+
+	return vim_strsave(gui.fontname);
+}//}}}
+
+/*
+ * Initialise vim to use the font with the given name.
+ * Return FAIL if the font could not be loaded, OK otherwise.
+ */
+	int
+gui_mch_init_font(char_u * font_name, int fontset)//{{{
+{
+	QString fontname;
+	GuiFont font=NULL;
+	
+	if (font_name==NULL) {
+#if 0
+#if QT_VERSION>=300
+		KConfig *base = KGlobal::config();
+#else
+		KConfigBase *base = KGlobal::config();
+#endif
+		base->setGroup("General");
+		if(!base->hasKey("fixed")) {
+			KMessageBox::error(KApplication::kApplication()->mainWidget(),"Cannot load default fixed font\n\nConfigure fonts in KDE Control Center.\n(Just click 'Choose...', 'OK' and then 'Apply')");
+			return FAIL;
+		}
+#if QT_VERSION>=300
+		QString f = base->readEntry("fixed");
+#else
+		QFont ft = base->readFontEntry("fixed", NULL);
+		QString f = KVimUtils::toString(&ft);
+#endif
+		font_name = (char_u*)strdup(f.latin1()); //latin1 ?
+#else
+		font_name = (char_u*)strdup("misc-fixed/10/-1/5/50/0/0/0/1/0");
+#endif
+	}
+	fontname = (const char *)font_name;
+/*	fontname.replace(QRegExp("/"),",");
+	font = new QFont();
+	font->fromString( fontname );
+*/
+	gui_mch_free_font(gui.norm_font);
+#ifdef FEAT_XFONTSET
+	gui_mch_free_fontset(gui.fontset);
+	if (fontset)
+	    font = gui_mch_get_fontset(font_name,TRUE,TRUE);
+#endif
+	if (font == NULL) {
+	    font = gui_mch_get_font(font_name,FALSE);
+	    gui.norm_font = font;
+#ifdef FEAT_XFONTSET
+	    gui.fontset=NOFONTSET;
+#endif
+	}
+#ifdef FEAT_XFONTSET
+	else {
+	    gui.fontset=font;
+	    gui.norm_font=NOFONT;
+	}
+#endif
+
+	if (font == NULL)
+		return FAIL;
+
+	if (fontname.contains('*') && fontname.contains('-'))
+		return FAIL;
+
+	QFontMetrics f(*font);
+	gui.char_width  = f.maxWidth();
+	gui.char_height = f.height()+p_linespace;
+	gui.char_ascent = f.ascent()+p_linespace/2;
+	
+	//check values, just to make sure and avoid a crash
+	if (gui.char_width<=0) gui.char_width=8;
+	if (gui.char_height<=0) gui.char_height=1;
+
+	hl_set_font_name(font_name);
+
+	return OK;
+}//}}}
+
+	GuiFont
+gui_mch_get_font(char_u * name, int report_error)//{{{
+{
+	QString fontname((const char *)name);
+	if (!gui.in_use || name == NULL)
+		return NOFONT;
+	if (fontname.contains('*') && fontname.contains('-'))
+		return NOFONT; // XFLD names not allowed anymore
+	QFont *myFont = new QFont();
+	fontname.replace(QRegExp("/"),",");
+//	myFont->setRawMode(TRUE);
+
+#if QT_VERSION>=300
+	myFont->fromString(fontname);
+#else
+	KVimUtils::fromString(myFont,fontname);
+#endif
+	myFont->setFixedPitch(true);
+	if (!myFont->fixedPitch()) dbf("Non fixed-width font");
+	return (GuiFont) myFont;
+}//}}}
+
+/*
+ * Set the current text font.
+ * Since we create all GC on demand, we use just gui.current_font to
+ * indicate the desired current font.
+ */
+	void
+gui_mch_set_font(GuiFont font)//{{{
+{
+	gui.current_font=font;
+	gui.w->painter->setFont( *(gui.current_font) );
+}//}}}
+
+/*
+ * If a font is not going to be used, free its structure.
+ */
+	void
+gui_mch_free_font(GuiFont font)//{{{
+{
+    if (font)
+	delete font; // this is a QFont , we can delete it :)
+}//}}}
+
+GuiFontset gui_mch_get_fontset (char_u *name, int report_error, int fixed_width)
+{
+    return (GuiFontset)gui_mch_get_font(name,report_error);
+}
+
+void gui_mch_set_fontset (GuiFontset fontset)
+{
+    gui_mch_set_font((GuiFont)fontset);
+}
+
+void gui_mch_free_fontset (GuiFontset fontset)
+{
+    if (fontset)
+	delete fontset;
+}
+
+void gui_mch_settitle (char_u *title, char_u *icon)//{{{
+{
+	if (!gui.in_use)		/* can't do this when GUI not running */
+	    return;
+	vmw->setPlainCaption((const char *)title);
+	QPixmap p((const char *)icon);
+	vmw->setIcon(p); //FIXME
+}//}}}
+
+/*
+ * Return the Pixel value (color) for the given color name.  This routine was
+ * pretty much taken from example code in the Silicon Graphics OSF/Motif
+ * Programmer's Guide.
+ * Return -1 for error.
+ */
+	guicolor_T
+gui_mch_get_color(char_u * name)//{{{
+{
+	int i;
+	static char *(vimnames[][2]) =
+	{
+		/* A number of colors that some X11 systems don't have */
+		{"LightRed", "#FFA0A0"},
+		{"LightGreen", "#80FF80"},
+		{"LightMagenta", "#FFA0FF"},
+		{"DarkCyan", "#008080"},
+		{"DarkBlue", "#0000C0"},
+		{"DarkRed", "#C00000"},
+		{"DarkMagenta", "#C000C0"},
+		{"DarkGrey", "#C0C0C0"},
+		{NULL, NULL}
+	};
+
+	if (!gui.in_use)		/* can't do this when GUI not running */
+		return (guicolor_T)(-1);
+
+	QColor _color((const char *)name);
+
+
+	if (_color.isValid()) {
+		//return (_color.red() << 16) +  ((_color.green() << 8)) + (_color.blue());
+		return _color.rgb();
+		//return (guicolor_T) _color.pixel();
+	}
+
+	/* add a few builtin names */
+	for (i = 0;; ++i) {
+		if (vimnames[i][0] == NULL)
+			return (guicolor_T)(-1);
+		if (STRICMP(name, vimnames[i][0]) == 0) {
+			name = (char_u *) vimnames[i][1];
+			return gui_mch_get_color(name);
+		}
+	}
+
+	return (guicolor_T)(-1); // dead code, should not be reached..
+}//}}}
+
+/*
+ * Set the current text foreground color.
+ */
+	void
+gui_mch_set_fg_color(guicolor_T color)//{{{
+{
+	QColor rgb;
+	rgb.setRgb(color);
+	gui.w->painter->setPen( rgb );
+}//}}}
+
+/*
+ * Set the current text background color.
+ */
+	void
+gui_mch_set_bg_color(guicolor_T color)//{{{
+{
+	QColor rgb;
+	rgb.setRgb(color);
+	gui.w->painter->setBackgroundColor(rgb);
+}//}}}
+
+/*
+ * Use the blank mouse pointer or not.
+ *
+ * hide: TRUE = use blank ptr, FALSE = use parent ptr
+ */
+	void
+gui_mch_mousehide(int hide)//{{{
+{
+	if (hide == gui.pointer_hidden) return;
+	//#ifdef FEAT_MOUSESHAPE
+	//	if( !hide) mch_set_mouse_shape(last_shape);
+	//#else
+# if (QT_VERSION<300)
+	gui.w->setCursor((hide)?BlankCursor:ArrowCursor);
+# else
+	gui.w->setCursor((hide)?Qt::BlankCursor:Qt::ArrowCursor);
+# endif
+	//#endif
+	gui.pointer_hidden = hide;
+}//}}}
+
+	void
+gui_mch_update_codec()
+{
+#ifdef FEAT_MBYTE
+	if (!gui.in_use) return;
+	vmw->codec = QTextCodec::codecForName((const char *)p_enc);
+	if (vmw->codec==NULL)
+	    vmw->codec = QTextCodec::codecForName(KVimUtils::convertEncodingName(QString((const char*)p_enc)));
+	if (vmw->codec==NULL)
+	    vmw->codec = QTextCodec::codecForLocale();
+#else
+        vmw->codec = QTextCodec::codecForLocale();
+#endif
+	if (vmw->codec==NULL)
+	    vmw->codec = QTextCodec::codecForName("ISO-8859-1"); //fallback
+}
+
+	void
+gui_mch_draw_string(int row, int col, char_u * s, int len, int flags)//{{{
+{
+	QString text = vmw->codec->toUnicode((const char *)s,len);
+	gui.w->draw_string( TEXT_X(col), TEXT_Y(row), text, text.length(), flags );
+}//}}}
+
+#if defined(FEAT_TITLE) || defined(PROTO)
+/*
+ * Return the text window-id and display.  Only required for X-based GUI's
+ */
+	int
+gui_get_x11_windis(Window * win, Display ** dis)//{{{
+{
+	*win = /*vmw*/gui.w->winId();
+	*dis = qt_xdisplay();
+	return OK;
+}//}}}
+#endif
+
+	void
+gui_mch_beep()//{{{
+{
+	kapp->beep();
+}//}}}
+
+	void
+gui_mch_flash(int msec)//{{{
+{
+	gui.w->flash();
+}//}}}
+
+/*
+ * Invert a rectangle from row r, column c, for nr rows and nc columns.
+ */
+	void
+gui_mch_invert_rectangle(int r, int c, int nr, int nc)//{{{
+{
+	bitBlt (
+			gui.w,
+			FILL_X(c), FILL_Y(r),
+			gui.w,
+			FILL_X(c), FILL_Y(r),
+			(nc) * gui.char_width,
+			(nr) * gui.char_height,
+			Qt::NotROP,	    // raster Operation
+			true );		    // ignoreMask
+}//}}}
+
+/*
+ * Iconify the GUI window.
+ */
+	void
+gui_mch_iconify()//{{{
+{
+	vmw->showMinimized();
+}//}}}
+
+/*
+ * Draw a cursor without focus.
+ */
+	void
+gui_mch_draw_hollow_cursor(guicolor_T color)//{{{
+{
+	QPainter p(gui.w);
+	p.setPen( color );
+
+	p.drawRect(FILL_X(gui.col), FILL_Y(gui.row), gui.char_width - 1, gui.char_height - 1 );
+
+	p.end();
+}//}}}
+
+/*
+ * Draw part of a cursor, "w" pixels wide, and "h" pixels high, using
+ * color "color".
+ */
+	void
+gui_mch_draw_part_cursor(int w, int h, guicolor_T color)//{{{
+{
+	QPainter p(gui.w);
+	p.setPen( color );
+	p.fillRect(
+			FILL_X(gui.col),
+			FILL_Y(gui.row) + gui.char_height - h +1,
+			w, h-2, QColor( color, color));
+	p.drawRect(FILL_X(gui.col),FILL_Y(gui.row) + gui.char_height - h + (int)p_linespace / 2,
+			w, h - (int)p_linespace );
+
+}//}}}
+
+
+/*
+ * Catch up with any queued X11 events.  This may put keyboard input into the
+ * input buffer, call resize call-backs, trigger timers etc.  If there is
+ * nothing in the X11 event queue (& no timers pending), then we return
+ * immediately.
+ */
+	void
+gui_mch_update()//{{{
+{
+	kapp->processEvents();
+}//}}}
+
+
+/*
+ * GUI input routine called by gui_wait_for_chars().  Waits for a character
+ * from the keyboard.
+ *  wtime == -1     Wait forever.
+ *  wtime == 0      This should never happen.
+ *  wtime > 0       Wait wtime milliseconds for a character.
+ * Returns OK if a character was found to be available within the given time,
+ * or FAIL otherwise.
+ */
+	int
+gui_mch_wait_for_chars(long wtime)//{{{
+{
+	// malte@kde.org's  gift to KVim ;), thanks to him :) for this hard to find bug
+	if (wtime>0) {
+		gui.w->wait( wtime );
+		while ( vim_is_input_buf_empty() && !gui.w->wait_done )
+			kapp->processOneEvent();
+		return vim_is_input_buf_empty() ? FAIL : OK;
+	} else
+		while (vim_is_input_buf_empty() ) {
+			kapp->processOneEvent();
+		}
+
+	return OK;
+}//}}}
+
+
+/****************************************************************************
+ * Output drawing routines.
+ ****************************************************************************/
+
+
+/* Flush any output to the screen */
+	void
+gui_mch_flush()//{{{
+{
+	kapp->flushX();
+}//}}}
+
+/*
+ * Clear a rectangular region of the screen from text pos (row1, col1) to
+ * (row2, col2) inclusive.
+ */
+	void
+gui_mch_clear_block(int row1, int col1, int row2, int col2)//{{{
+{
+	gui.w->erase (FILL_X(col1), FILL_Y(row1),
+			(col2 - col1 + 1) * gui.char_width+ (col2 == Columns - 1),
+			(row2 - row1 + 1) * gui.char_height );
+}//}}}
+
+	void
+gui_mch_clear_all(void)//{{{
+{
+	gui.w->erase();
+}//}}}
+
+
+/*
+ * Delete the given number of lines from the given row, scrolling up any
+ * text further down within the scroll region.
+ */
+	void
+gui_mch_delete_lines(int row, int num_lines)//{{{
+{
+	if (num_lines <= 0)
+		return;
+
+	if (row + num_lines > gui.scroll_region_bot) {
+		/* Scrolled out of region, just blank the lines out */
+		gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right);
+	} else {
+		bitBlt (
+				gui.w,
+				FILL_X(gui.scroll_region_left), FILL_Y(row),
+				gui.w,
+				FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines),
+				gui.char_width * (gui.scroll_region_right -gui.scroll_region_left + 1) + 1,
+				gui.char_height * (gui.scroll_region_bot - row - num_lines + 1),
+				Qt::CopyROP,	    // raster Operation
+				true );		    // ignoreMask
+
+		/* Update gui.cursor_row if the cursor scrolled or copied over */
+		if (gui.cursor_row >= row) {
+			if (gui.cursor_row < row + num_lines)
+				gui.cursor_is_valid = FALSE;
+			else if (gui.cursor_row <= gui.scroll_region_bot)
+				gui.cursor_row -= num_lines;
+		}
+
+		gui_clear_block(gui.scroll_region_bot - num_lines + 1, gui.scroll_region_left,
+				gui.scroll_region_bot, gui.scroll_region_right);
+
+	}
+}//}}}
+
+/*
+ * Insert the given number of lines before the given row, scrolling down any
+ * following text within the scroll region.
+ */
+	void
+gui_mch_insert_lines(int row, int num_lines)//{{{
+{
+	if (num_lines <= 0)
+		return;
+
+	if (row + num_lines > gui.scroll_region_bot) {
+		/* Scrolled out of region, just blank the lines out */
+		gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot, gui.scroll_region_right - 1);
+	} else {
+		bitBlt (
+				gui.w,
+				FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines),
+				gui.w,
+				FILL_X(gui.scroll_region_left), FILL_Y(row),
+				gui.char_width * ( gui.scroll_region_right - gui.scroll_region_left + 1 ) + 1,
+				gui.char_height * (gui.scroll_region_bot - row - num_lines + 1),
+				Qt::CopyROP,	    // raster Operation
+				true );		    // ignoreMask
+
+		/* Update gui.cursor_row if the cursor scrolled or copied over */
+		if (gui.cursor_row >= gui.row) {
+			if (gui.cursor_row <= gui.scroll_region_bot - num_lines)
+				gui.cursor_row += num_lines;
+			else if (gui.cursor_row <= gui.scroll_region_bot)
+				gui.cursor_is_valid = FALSE;
+		}
+
+		gui_clear_block(row, gui.scroll_region_left, row + num_lines - 1, gui.scroll_region_right);
+	}
+}//}}}
+
+/*
+ * X Selection stuff, for cutting and pasting text to other windows.
+ */
+	void
+clip_mch_request_selection(VimClipboard *cbd)//{{{
+{
+#if QT_VERSION>=300
+	if (cbd==&clip_star) kapp->clipboard()->setSelectionMode(true);
+#endif
+	QString selection = kapp->clipboard()->text();
+
+	QCString unistring = vmw->codec->fromUnicode(selection);
+	clip_yank_selection(MCHAR,(char_u *)(const char*)unistring,(long) unistring.length(),cbd);
+#if QT_VERSION>=300
+	if (cbd==&clip_star) kapp->clipboard()->setSelectionMode(false);
+#endif
+}//}}}
+
+	void
+clip_mch_lose_selection(VimClipboard *cbd)//{{{
+{
+	//Don't need to do anything here
+	gui_mch_update();
+}//}}}
+
+/*
+ * Check whatever we allready own the selection.
+ */
+	int
+clip_mch_own_selection(VimClipboard *cbd)//{{{
+{
+	if (kapp->clipboard()->ownsSelection())
+	    return OK;
+	else {
+#if QT_VERSION>=300
+	    kapp->clipboard()->setSelectionMode(true);
+#endif
+	    return OK;
+	}
+}//}}}
+
+/*
+ * Send the current selection to the clipboard.
+ */
+void
+clip_mch_set_selection(VimClipboard *cbd){//{{{
+	char_u *data;
+	long_u length;
+
+	clip_get_selection(cbd);
+	if(clip_convert_selection(&data,&length,cbd)<0) return;
+
+	QString selection((const char *) data);
+	//We must turncate the string because it is not
+	// null terminated
+	selection.truncate((uint) length);
+
+#if QT_VERSION>=300
+	if (cbd==&clip_star) kapp->clipboard()->setSelectionMode(true);
+#endif
+	kapp->clipboard()->setText(selection);
+#if QT_VERSION>=300
+	kapp->clipboard()->setSelectionMode(false);
+#endif
+}//}}}
+
+
+#if defined(FEAT_MENU) || defined(PROTO)
+/*
+ * Make a menu item appear either active or not active (grey or not grey).
+ */
+	void
+gui_mch_menu_grey(vimmenu_T * menu, int grey)//{{{
+{
+	if ( !menu || !menu->parent || !menu->parent->widget ) return;
+	menu->parent->widget->setItemEnabled((int)menu, !grey);
+	gui_mch_update();
+}//}}}
+
+/*
+ * Make menu item hidden or not hidden.
+ */
+	void
+gui_mch_menu_hidden(vimmenu_T * menu, int hidden)//{{{
+{
+	//FIXME: cannot be fixed AFAIK
+	gui_mch_menu_grey(menu,hidden); // it's hard to remove an item in a QPopupMenu
+}//}}}
+
+/*
+ * This is called after setting all the menus to grey/hidden or not.
+ */
+	void
+gui_mch_draw_menubar()//{{{
+{
+	// nothing to do under kde
+}//}}}
+#endif
+
+/*
+ * Scrollbar stuff.
+ */
+	void
+gui_mch_enable_scrollbar(scrollbar_T * sb, int flag)//{{{
+{
+	if (!sb->w) return;
+	int width = gui.w->width();
+	int height = gui.w->height();
+	int neww = vmw->width();
+	int newh = vmw->height();
+
+	if (gui.which_scrollbars[SBAR_LEFT]) width += gui.scrollbar_width;
+	if (gui.which_scrollbars[SBAR_RIGHT]) width += gui.scrollbar_width;
+	if (gui.which_scrollbars[SBAR_BOTTOM]) height += gui.scrollbar_height;
+	
+	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
+	if ( abs(vmw->width() - width)>5 && (sb->type==SBAR_LEFT || sb->type==SBAR_RIGHT) )
+	    neww=width;
+	if (abs(vmw->height() - height)>5 && (sb->type==SBAR_BOTTOM) )
+	    newh=height;
+
+	if (flag)
+	    sb->w->show();
+	else
+	    sb->w->hide();
+	gui_mch_update();
+	vmw->lock();
+	vmw->resize(neww,newh);
+	vmw->unlock();
+	gui_mch_update();
+}//}}}
+
+/*
+ * Return the RGB value of a pixel as "#RRGGBB".
+ */
+	long_u
+gui_mch_get_rgb(guicolor_T pixel)//{{{
+{
+//	QColor c(pixel,pixel);
+//	return (c.red() << 16) +  ((c.green() << 8)) + (c.blue());
+	return pixel; // funny no ? it looks like with Qt we can always use directly the rgb value (i hope i don't break colors again ;p)
+}//}}}
+
+/*
+ * Get current y mouse coordinate in text window.
+ * Return -1 when unknown.
+ */
+	int
+gui_mch_get_mouse_x(void)//{{{
+{
+	return vmw->mapFromGlobal( QCursor::pos() ).x();
+}//}}}
+
+	int
+gui_mch_get_mouse_y(void)//{{{
+{
+	return vmw->mapFromGlobal( QCursor::pos() ).y();
+}//}}}
+
+	void
+gui_mch_setmouse(int x, int y)//{{{
+{
+	QCursor::setPos( vmw->mapToGlobal( QPoint(x,y)) );
+}//}}}
+
+#if defined(FEAT_MOUSESHAPE) || defined(PROTO)
+#if QT_VERSION>=300
+static int mshape_ids[] = {//{{{
+	Qt::ArrowCursor,		/* arrow */
+	Qt::BlankCursor,		/* blank */
+	Qt::IbeamCursor,		/* beam */
+	Qt::SizeVerCursor,		/* updown */
+	Qt::SplitHCursor,		/* udsizing */
+	Qt::SizeHorCursor,		/* leftright */
+	Qt::SizeHorCursor,		/* lrsizing */
+	Qt::WaitCursor,		/* busy */
+	Qt::ForbiddenCursor,	/* no */
+	Qt::CrossCursor,		/* crosshair */
+	Qt::PointingHandCursor,	/* hand1 */
+	Qt::PointingHandCursor,	/* hand2 */
+	Qt::ArrowCursor,		/* pencil */
+	Qt::WhatsThisCursor,	/* question */
+	Qt::ArrowCursor,		/* right-arrow */
+	Qt::UpArrowCursor,		/* up-arrow */
+	Qt::ArrowCursor		/* last one */
+};//}}}
+#else
+static int mshape_ids[] = {//{{{
+	ArrowCursor,		/* arrow */
+	BlankCursor,		/* blank */
+	IbeamCursor,		/* beam */
+	SizeVerCursor,		/* updown */
+	SplitHCursor,		/* udsizing */
+	SizeHorCursor,		/* leftright */
+	SizeHorCursor,		/* lrsizing */
+	WaitCursor,			/* busy */
+	ForbiddenCursor,		/* no */
+	CrossCursor,		/* crosshair */
+	PointingHandCursor,		/* hand1 */
+	PointingHandCursor,		/* hand2 */
+	ArrowCursor,		/* pencil */
+	ArrowCursor,		/* question */
+	ArrowCursor,		/* right-arrow */
+	UpArrowCursor,		/* up-arrow */
+	ArrowCursor			/* last one */
+};//}}}
+#endif
+
+	void
+mch_set_mouse_shape (int shape)//{{{
+{
+	int		   id;
+
+	if (shape == MSHAPE_HIDE || gui.pointer_hidden)
+#if QT_VERSION>=300
+		gui.w->setCursor(Qt::BlankCursor);
+#else
+		gui.w->setCursor(BlankCursor);
+#endif
+	else
+	{
+		if (shape >= MSHAPE_NUMBERED)
+		{
+			id = shape - MSHAPE_NUMBERED;
+			/*		if (id >= GDK_NUM_GLYPHS)
+					id = GDK_LEFT_PTR;
+					else
+					id &= ~1;*/	/* they are always even (why?) */
+			id &= -1;
+		}
+		else
+			id = mshape_ids[shape];
+
+		gui.w->setCursor(id);
+	}
+	if (shape != MSHAPE_HIDE)
+		last_shape = shape;
+}//}}}
+#endif
+
+	int
+gui_mch_adjust_charsize ()//{{{
+{
+	QFont f(*(gui.current_font));
+	QFontMetrics fm (f);
+	gui.char_height = fm.height() + p_linespace;
+	//gui.char_height = fm.ascent() + fm.descent() + p_linespace;
+	gui.char_ascent = fm.ascent() + p_linespace/2;
+
+	return OK;
+}//}}}
+
+	void
+gui_mch_set_foreground ()//{{{
+{
+	KWin::setActiveWindow(vmw->winId());
+}//}}}
+
+
+
diff --git a/src/kvim_iface.h b/src/kvim_iface.h
new file mode 100644
index 0000000..1084bc2
--- /dev/null
+++ b/src/kvim_iface.h
@@ -0,0 +1,19 @@
+#ifndef KVIM_IFACE
+#define KVIM_IFACE
+
+#include <dcopobject.h>
+
+class KVim : virtual public DCOPObject
+{
+	K_DCOP
+public:
+
+k_dcop:
+	virtual void execInsert(QString command)=0;
+	virtual void execNormal(QString command)=0;
+	virtual void execRaw(QString command)=0;
+	virtual void execCmd(QString command)=0;
+	virtual QString eval(QString expr)=0;
+};
+
+#endif
diff --git a/src/main.c b/src/main.c
index 91854bf..5fd8339 100644
--- a/src/main.c
+++ b/src/main.c
@@ -259,7 +259,7 @@
 	    break;
 # ifdef FEAT_XCLIPBOARD
 	else if (STRICMP(argv[i], "-display") == 0
-#  ifdef FEAT_GUI_GTK
+#  if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
 		|| STRICMP(argv[i], "--display") == 0
 #  endif
 		)
@@ -442,7 +442,7 @@
 	++initstr;
     }
 
-    if (TOLOWER_ASC(initstr[0]) == 'g')
+    if (TOLOWER_ASC(initstr[0]) == 'g' || initstr[0] == 'k')
     {
 	main_start_gui();
 #ifdef FEAT_GUI
@@ -1087,7 +1087,7 @@
 #ifdef ALWAYS_USE_GUI
     gui.starting = TRUE;
 #else
-# if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
+# if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
     /*
      * Check if the GUI can be started.  Reset gui.starting if not.
      * Don't know about other systems, stay on the safe side and don't check.
@@ -1170,7 +1170,7 @@
      * For GTK we can't be sure, but when started from the desktop it doesn't
      * make sense to try using a terminal.
      */
-#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
+#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
     if (gui.starting
 # ifdef FEAT_GUI_GTK
 	    && !isatty(2)
@@ -2614,6 +2614,17 @@
 # endif
     main_msg(_("--socketid <xid>\tOpen Vim inside another GTK widget"));
 #endif
+#ifdef FEAT_GUI_KDE
+    mch_msg(_("\nArguments recognised by kvim (KDE version):\n"));
+    main_msg(_("-black\t\tUse reverse video"));
+#if QT_VERSION>=300
+    main_msg(_("-tip\t\t\tDisplay the tip dialog on startup"));
+    main_msg(_("-notip\t\tDisable the tip dialog"));
+#endif
+    main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)"));
+    main_msg(_("-geometry <geom>\tUse <geom> for initial geometry (also: -geom)"));
+    main_msg(_("--display <display>\tRun vim on <display>"));
+#endif
 #ifdef FEAT_GUI_W32
     main_msg(_("-P <parent title>\tOpen Vim inside parent application"));
 #endif
diff --git a/src/mbyte.c b/src/mbyte.c
index 699316d..db7c652 100644
--- a/src/mbyte.c
+++ b/src/mbyte.c
@@ -690,6 +690,11 @@
     apply_autocmds(EVENT_ENCODINGCHANGED, NULL, (char_u *)"", FALSE, curbuf);
 #endif
 
+#ifdef FEAT_GUI_KDE
+    if (gui.in_use)
+	gui_mch_update_codec();
+#endif
+
     return NULL;
 }
 
@@ -3976,7 +3981,7 @@
 # endif
 #endif
 
-#if defined(FEAT_GUI_GTK) || defined(PROTO)
+#if defined(FEAT_GUI_GTK) || defined(PROTO) || defined(FEAT_GUI_KDE)
 static int	preedit_buf_len = 0;
 static int	xim_can_preediting INIT(= FALSE);	/* XIM in showmode() */
 static int	xim_input_style;
@@ -4112,7 +4117,7 @@
     /* If 'imdisable' is set, XIM is never active. */
     if (p_imdisable)
 	active = FALSE;
-#ifndef FEAT_GUI_GTK
+#if !defined (FEAT_GUI_GTK) && !defined (FEAT_GUI_KDE)
     else if (input_style & XIMPreeditPosition)
 	/* There is a problem in switching XIM off when preediting is used,
 	 * and it is not clear how this can be solved.  For now, keep XIM on
@@ -4386,6 +4391,8 @@
 	    gdk_ic_set_attr(xic, attr, (GdkICAttributesType)attrmask);
     }
 #else /* FEAT_GUI_GTK */
+# ifdef FEAT_GUI_KDE
+# else
     {
 	XVaNestedList attr_list;
 	XRectangle spot_area;
@@ -4432,6 +4439,7 @@
 	    XFree(attr_list);
 	}
     }
+# endif /* FEAT_GUI_KDE */
 #endif /* FEAT_GUI_GTK */
 }
 
@@ -4485,6 +4493,8 @@
     }
 # endif
 #else
+# ifdef FEAT_GUI_KDE
+# else
     {
 	XVaNestedList preedit_list = 0, status_list = 0, list = 0;
 	XRectangle pre_area, status_area;
@@ -4576,6 +4586,7 @@
 	if (preedit_list)
 	    XFree(preedit_list);
     }
+# endif /* FEAT_GUI_KDE */
 #endif
 }
 
@@ -5350,6 +5361,8 @@
 #ifdef FEAT_GUI_GTK
     if (xim_input_style & (int)GDK_IM_STATUS_AREA)
 	return gui.char_height;
+#elif defined FEAT_GUI_KDE
+#warning FIXME
 #else
     if (status_area_enabled)
 	return gui.char_height;
diff --git a/src/menu.c b/src/menu.c
index 052910f..fc8411f 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -96,7 +96,7 @@
     char_u	*arg;
     char_u	*p;
     int		i;
-#if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK)
+#if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_KDE)
     int		old_menu_height;
 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_W16)
     int		old_toolbar_height;
@@ -320,7 +320,7 @@
 	EMSG(_(e_trailing));
 	goto theend;
     }
-#if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON))
+#if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) || defined(FEAT_GUI_PHOTON))
     old_menu_height = gui.menu_height;
 # if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_W16)
     old_toolbar_height = gui.toolbar_height;
@@ -437,7 +437,7 @@
 	vim_free(map_buf);
     }
 
-#if defined(FEAT_GUI) && !defined(FEAT_GUI_GTK)
+#if defined(FEAT_GUI) && !(defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))
     /* If the menubar height changed, resize the window */
     if (gui.in_use
 	    && (gui.menu_height != old_menu_height
@@ -1843,7 +1843,7 @@
     }
 }
 
-#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \
+#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) \
     || defined(FEAT_GUI_PHOTON) || defined(PROTO)
 /*
  * Check if a key is used as a mnemonic for a toplevel menu.
@@ -2174,6 +2174,7 @@
 }
 
 #if defined(FEAT_GUI_MSWIN) \
+	|| (defined(FEAT_GUI_KDE) && defined(FEAT_MENU)) \
 	|| (defined(FEAT_GUI_GTK) && defined(FEAT_MENU)) \
 	|| defined(FEAT_BEVAL_TIP) || defined(PROTO)
 /*
diff --git a/src/misc1.c b/src/misc1.c
index 6c5cb6a..6330110 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -4055,7 +4055,7 @@
 
 #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
 	|| defined(FEAT_SESSION) || defined(MSWIN) \
-	|| (defined(FEAT_GUI_GTK) \
+	|| ((defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) \
 			    && (defined(FEAT_WINDOWS) || defined(FEAT_DND))) \
 	|| defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \
 	|| defined(PROTO)
diff --git a/src/misc2.c b/src/misc2.c
index 55c44a8..3678947 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2668,8 +2668,8 @@
 }
 
 #if defined(FEAT_SESSION) || defined(MSWIN) || defined(FEAT_GUI_MAC) \
-	|| (defined(FEAT_GUI_GTK) \
-			    && (defined(FEAT_WINDOWS) || defined(FEAT_DND))) \
+	|| ((defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)) \
+			&& ( defined(FEAT_WINDOWS) || defined(FEAT_DND)) ) \
 	|| defined(FEAT_SUN_WORKSHOP) || defined(FEAT_NETBEANS_INTG) \
 	|| defined(PROTO)
 /*
diff --git a/src/normal.c b/src/normal.c
index 222e475..8fb8c02 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -2357,7 +2357,7 @@
 	     * NOTE: Ignore right button down and drag mouse events.
 	     * Windows only shows the popup menu on the button up event.
 	     */
-#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON)
+#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_KDE)
 	    if (!is_click)
 		return FALSE;
 #endif
@@ -2365,7 +2365,7 @@
 	    if (is_click || is_drag)
 		return FALSE;
 #endif
-#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \
+#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) \
 	    || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \
 	    || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_PHOTON)
 	    if (gui.in_use)
diff --git a/src/option.c b/src/option.c
index fcbddea..948018d 100644
--- a/src/option.c
+++ b/src/option.c
@@ -1019,14 +1019,14 @@
 #endif
 				    },
     {"guiheadroom", "ghr",  P_NUM|P_VI_DEF,
-#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
+#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_KDE)
 			    (char_u *)&p_ghr, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
 #endif
 			    {(char_u *)50L, (char_u *)0L}},
     {"guioptions",  "go",   P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
-#if defined(FEAT_GUI)
+#if defined(FEAT_GUI) || defined(FEAT_GUI_KDE)
 			    (char_u *)&p_go, PV_NONE,
 # if defined(UNIX) && !defined(MACOS)
 			    {(char_u *)"agimrLtT", (char_u *)0L}
@@ -1112,7 +1112,7 @@
 			    (char_u *)&p_ic, PV_NONE,
 			    {(char_u *)FALSE, (char_u *)0L}},
     {"imactivatekey","imak",P_STRING|P_VI_DEF,
-#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
+#if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))
 			    (char_u *)&p_imak, PV_NONE,
 #else
 			    (char_u *)NULL, PV_NONE,
@@ -4906,7 +4906,7 @@
     }
 #endif
 
-#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
+#if defined(FEAT_XIM) && ( defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) )
     else if (varp == &p_imak)
     {
 	if (gui.in_use && !im_xim_isvalid_imactivate())
@@ -5163,7 +5163,7 @@
 	if (gui.in_use)
 	{
 	    p = p_guifont;
-# ifdef FEAT_GUI_GTK
+# if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
 	    /*
 	     * Put up a font dialog and let the user select a new value.
 	     * If this is cancelled go back to the old value but don't
diff --git a/src/option.h b/src/option.h
index 1d2b83c..7e04190 100644
--- a/src/option.h
+++ b/src/option.h
@@ -466,7 +466,7 @@
 # endif
 EXTERN int	p_guipty;	/* 'guipty' */
 #endif
-#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
+#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_KDE)
 EXTERN long	p_ghr;		/* 'guiheadroom' */
 #endif
 #ifdef CURSOR_SHAPE
@@ -512,7 +512,7 @@
 EXTERN char_u	*p_iconstring;	/* 'iconstring' */
 #endif
 EXTERN int	p_ic;		/* 'ignorecase' */
-#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
+#if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))
 EXTERN char_u	*p_imak;	/* 'imactivatekey' */
 #endif
 #ifdef USE_IM_CONTROL
@@ -773,7 +773,7 @@
 EXTERN long	p_verbose;	/* 'verbose' */
 EXTERN int	p_warn;		/* 'warn' */
 #if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MOTIF) || defined(LINT) \
-	|| defined (FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON)
+	|| defined (FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_KDE)
 #define FEAT_WAK
 EXTERN char_u	*p_wak;		/* 'winaltkeys' */
 #endif
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 97803a8..d199f3e 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -155,12 +155,7 @@
 #ifdef FEAT_GUI
 extern HWND s_hwnd;
 #else
-# if (defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT)) \
-	|| defined(FEAT_CLIENTSERVER) \
-	|| (defined(FEAT_EVAL) && !defined(FEAT_GUI))
-#  define HAVE_GETCONSOLEHWND
 static HWND s_hwnd = 0;	    /* console window handle, set by GetConsoleHwnd() */
-# endif
 #endif
 
 extern int WSInitialized;
@@ -1537,7 +1532,7 @@
 
 #endif //_DEBUG
 
-#ifdef HAVE_GETCONSOLEHWND
+#if !defined(FEAT_GUI) || defined(PROTO)
 # if defined(FEAT_TITLE) && defined(WIN3264)
 extern HWND g_hWnd;	/* This is in os_win32.c. */
 # endif
@@ -1580,6 +1575,32 @@
 
     SetConsoleTitle(pszOldWindowTitle);
 }
+
+/*
+ * Console implementation of ":winpos".
+ */
+    int
+mch_get_winpos(int *x, int *y)
+{
+    RECT  rect;
+
+    GetConsoleHwnd();
+    GetWindowRect(s_hwnd, &rect);
+    *x = rect.left;
+    *y = rect.top;
+    return OK;
+}
+
+/*
+ * Console implementation of ":winpos x y".
+ */
+    void
+mch_set_winpos(int x, int y)
+{
+    GetConsoleHwnd();
+    SetWindowPos(s_hwnd, NULL, x, y, 0, 0,
+		 SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
+}
 #endif
 
 #if (defined(FEAT_PRINTER) && !defined(FEAT_POSTSCRIPT)) || defined(PROTO)
diff --git a/src/os_unix.c b/src/os_unix.c
index b59d8ff..597ca3d 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1222,6 +1222,13 @@
     Display	*dpy;
     XErrorEvent	*error_event;
 {
+    /* KDE sometimes produces X error that we want to ignore */
+#if defined(FEAT_GUI_KDE)
+    XGetErrorText(dpy, error_event->error_code, (char *)IObuff, IOSIZE);
+    STRCAT(IObuff, "\nVim: Got X error but we continue...\n");
+    fprintf(stderr, IObuff);
+    return 0;
+#else
     XGetErrorText(dpy, error_event->error_code, (char *)IObuff, IOSIZE);
     STRCAT(IObuff, _("\nVim: Got X error\n"));
 
@@ -1231,6 +1238,7 @@
     preserve_exit();		    /* preserve files and exit */
 
     return 0;		/* NOTREACHED */
+#endif
 }
 
 /*
@@ -1371,7 +1379,7 @@
 	did_set_error_handler = TRUE;
     }
 
-#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
+#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE)
     if (gui.in_use)
     {
 	/*
@@ -1798,7 +1806,10 @@
      * Note: if "t_TS" is set, title is set with escape sequence rather
      *	     than x11 calls, because the x11 calls don't always work
      */
-
+#ifdef FEAT_GUI_KDE
+    /* dont know why but KDE needs this one as we don't go through the next function... */
+    gui_mch_settitle(title, icon);
+#endif
     if ((type || *T_TS != NUL) && title != NULL)
     {
 	if (oldtitle == NULL
diff --git a/src/os_unixx.h b/src/os_unixx.h
index 9f4f7eb..abed14d 100644
--- a/src/os_unixx.h
+++ b/src/os_unixx.h
@@ -92,6 +92,12 @@
 # if defined(HAVE_LIMITS_H) && !defined(_LIMITS_H)
 #  include <limits.h>		/* for SYS_NMLN (Sinix 5.41 / Unix SysV.4) */
 # endif
+
+/* Define SYS_NMLN ourselves if it still isn't defined (for CrayT3E). */
+# ifndef SYS_NMLN
+#  define SYS_NMLN 32
+# endif
+
 # include <sys/systeminfo.h>	/* for sysinfo */
 #endif
 
diff --git a/src/proto.h b/src/proto.h
index d89c847..2471bb6 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -20,7 +20,7 @@
  * Machine-dependent routines.
  */
 /* avoid errors in function prototypes */
-# if !defined(FEAT_X11) && !defined(FEAT_GUI_GTK)
+# if !defined(FEAT_X11) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_KDE)
 #  define Display int
 #  define Widget int
 # endif
@@ -180,6 +180,10 @@
 #  ifdef FEAT_GUI_W32
 #   include "gui_w32.pro"
 #  endif
+#  ifdef FEAT_GUI_KDE
+#   include "gui_kde.pro"
+#   include "gui_kde_x11.pro"
+#  endif
 #  ifdef FEAT_GUI_GTK
 #   include "gui_gtk.pro"
 #   include "gui_gtk_x11.pro"
diff --git a/src/proto/gui_kde.pro b/src/proto/gui_kde.pro
new file mode 100644
index 0000000..3a52fa7
--- /dev/null
+++ b/src/proto/gui_kde.pro
@@ -0,0 +1,19 @@
+/* gui_kde.c */
+void gui_mch_add_menu __ARGS((vimmenu_T *menu, int idx));
+void gui_mch_add_menu_item __ARGS((vimmenu_T *menu, int idx));
+void gui_mch_set_text_area_pos __ARGS((int x, int y, int w, int h));
+void gui_gtk_set_mnemonics __ARGS((int enable));
+void gui_mch_toggle_tearoffs __ARGS((int enable));
+void gui_mch_destroy_menu __ARGS((vimmenu_T *menu));
+void gui_mch_set_scrollbar_thumb __ARGS((scrollbar_T *sb, long val, long size, long max));
+void gui_mch_set_scrollbar_pos __ARGS((scrollbar_T *sb, int x, int y, int w, int h));
+void gui_mch_create_scrollbar __ARGS((scrollbar_T *sb, int orient));
+void gui_mch_destroy_scrollbar __ARGS((scrollbar_T *sb));
+char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter));
+int gui_mch_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int def_but, char_u *textfield));
+void gui_mch_show_popupmenu __ARGS((vimmenu_T *menu));
+void gui_mch_find_dialog __ARGS((exarg_T *eap));
+void gui_mch_replace_dialog __ARGS((exarg_T *eap));
+void ex_helpfind __ARGS((exarg_T *eap));
+void gui_make_popup __ARGS((char_u *path_name));
+/* vim: set ft=c : */
diff --git a/src/proto/gui_kde_x11.pro b/src/proto/gui_kde_x11.pro
new file mode 100644
index 0000000..7d968d9
--- /dev/null
+++ b/src/proto/gui_kde_x11.pro
@@ -0,0 +1,62 @@
+/* gui_kde_x11.c */
+void gui_mch_prepare __ARGS((int *argc, char **argv));
+void gui_mch_set_blinking __ARGS((long waittime, long on, long off));
+void gui_mch_stop_blink __ARGS((void));
+void gui_mch_start_blink __ARGS((void));
+int gui_mch_init_check __ARGS((void));
+int gui_mch_init __ARGS((void));
+void gui_mch_new_colors __ARGS((void));
+int gui_mch_open __ARGS((void));
+void gui_mch_exit __ARGS((int rc));
+int gui_mch_get_winpos __ARGS((int *x, int *y));
+void gui_mch_set_winpos __ARGS((int x, int y));
+void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height));
+void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h));
+void gui_mch_enable_menu __ARGS((int flag));
+void gui_mch_show_toolbar __ARGS((int showit));
+int gui_mch_adjust_charsize __ARGS((void));
+GuiFontset gui_mch_get_fontset __ARGS((char_u *name, int report_error, int fixed_width));
+int gui_mch_init_font __ARGS((char_u *font_name, int fontset));
+GuiFont gui_mch_get_font __ARGS((char_u *name, int report_error));
+void gui_mch_set_font __ARGS((GuiFont font));
+void gui_mch_set_fontset __ARGS((GuiFontset fontset));
+void gui_mch_free_font __ARGS((GuiFont font));
+void gui_mch_free_fontset __ARGS((GuiFontset fontset));
+guicolor_T gui_mch_get_color __ARGS((char_u *name));
+void gui_mch_set_fg_color __ARGS((guicolor_T color));
+void gui_mch_set_bg_color __ARGS((guicolor_T color));
+void gui_mch_draw_string __ARGS((int row, int col, char_u *s, int len, int flags));
+int gui_mch_haskey __ARGS((char_u *name));
+int gui_get_x11_windis __ARGS((Window *win, Display **dis));
+void gui_mch_beep __ARGS((void));
+void gui_mch_flash __ARGS((int msec));
+void gui_mch_invert_rectangle __ARGS((int r, int c, int nr, int nc));
+void gui_mch_iconify __ARGS((void));
+void gui_mch_set_foreground __ARGS((void));
+void gui_mch_draw_hollow_cursor __ARGS((guicolor_T color));
+void gui_mch_draw_part_cursor __ARGS((int w, int h, guicolor_T color));
+void gui_mch_update __ARGS((void));
+int gui_mch_wait_for_chars __ARGS((long wtime));
+void gui_mch_flush __ARGS((void));
+void gui_mch_clear_block __ARGS((int row1, int col1, int row2, int col2));
+void gui_mch_clear_all __ARGS((void));
+void gui_mch_delete_lines __ARGS((int row, int num_lines));
+void gui_mch_insert_lines __ARGS((int row, int num_lines));
+void clip_mch_request_selection __ARGS((VimClipboard *cbd));
+void clip_mch_lose_selection __ARGS((VimClipboard *cbd));
+int clip_mch_own_selection __ARGS((VimClipboard *cbd));
+void clip_mch_set_selection __ARGS((VimClipboard *cbd));
+void gui_mch_menu_grey __ARGS((vimmenu_T *menu, int grey));
+void gui_mch_menu_hidden __ARGS((vimmenu_T *menu, int hidden));
+void gui_mch_draw_menubar __ARGS((void));
+void gui_mch_enable_scrollbar __ARGS((scrollbar_T *sb, int flag));
+long_u gui_mch_get_rgb __ARGS((guicolor_T pixel));
+int gui_mch_get_mouse_x __ARGS((void));
+int gui_mch_get_mouse_y __ARGS((void));
+void gui_mch_setmouse __ARGS((int x, int y));
+void gui_mch_mousehide __ARGS((int hide));
+void mch_set_mouse_shape __ARGS((int shape));
+char_u *gui_mch_font_dialog __ARGS((char_u *oldval));
+void gui_mch_settitle __ARGS((char_u *title,char_u *icon));
+void gui_mch_update_codec __ARGS((void));
+/* vim: set ft=c : */
diff --git a/src/proto/misc2.pro b/src/proto/misc2.pro
index cbe2af7..899018b 100644
--- a/src/proto/misc2.pro
+++ b/src/proto/misc2.pro
@@ -17,7 +17,9 @@
 void adjust_cursor_col __ARGS((void));
 int leftcol_changed __ARGS((void));
 void vim_mem_profile_dump __ARGS((void));
+#ifndef __cplusplus
 char_u *alloc __ARGS((unsigned size));
+#endif
 char_u *alloc_clear __ARGS((unsigned size));
 char_u *alloc_check __ARGS((unsigned size));
 char_u *lalloc_clear __ARGS((long_u size, int message));
diff --git a/src/proto/os_mswin.pro b/src/proto/os_mswin.pro
index b4612f0..c9e495d 100644
--- a/src/proto/os_mswin.pro
+++ b/src/proto/os_mswin.pro
@@ -33,6 +33,8 @@
 void clip_mch_request_selection __ARGS((VimClipboard *cbd));
 void clip_mch_set_selection __ARGS((VimClipboard *cbd));
 void DumpPutS __ARGS((const char *psz));
+int mch_get_winpos __ARGS((int *x, int *y));
+void mch_set_winpos __ARGS((int x, int y));
 void mch_print_cleanup __ARGS((void));
 int mch_print_init __ARGS((prt_settings_T *psettings, char_u *jobname, int forceit));
 int mch_print_begin __ARGS((prt_settings_T *psettings));
diff --git a/src/screen.c b/src/screen.c
index 594c424..8a5b421 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -2594,7 +2594,7 @@
 #endif
 #define WL_LINE		WL_SBR + 1	/* text in the line */
     int		draw_state = WL_START;	/* what to draw next */
-#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
+#if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))
     int		feedback_col = 0;
     int		feedback_old_attr = -1;
 #endif
@@ -3785,7 +3785,7 @@
 		&& (search_attr == 0 || char_attr != search_attr))
 	    char_attr = extra_attr;
 
-#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
+#if defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))
 	/* XIM don't send preedit_start and preedit_end, but they send
 	 * preedit_changed and commit.  Thus Vim can't set "im_is_active", use
 	 * im_is_preediting() here. */
diff --git a/src/structs.h b/src/structs.h
index 0edd729..9e6d4e2 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1751,6 +1751,9 @@
     Widget	id;		    /* Manage this to enable item */
     Widget	submenu_id;	    /* If this is submenu, add children here */
 #endif
+#ifdef FEAT_GUI_KDE
+    QPopupMenu *widget;
+#endif
 #ifdef FEAT_GUI_GTK
     GtkWidget	*id;		    /* Manage this to enable item */
     GtkWidget	*submenu_id;	    /* If this is submenu, add children here */
diff --git a/src/ui.c b/src/ui.c
index ebbf85d..47ff80e 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -1511,7 +1511,7 @@
 }
 #endif
 
-#if defined(FEAT_GUI_GTK) || defined(PROTO)
+#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE) || defined(PROTO)
     int
 vim_used_in_input_buf()
 {
@@ -1593,7 +1593,7 @@
 }
 #endif
 
-#if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) \
+#if (defined(FEAT_XIM) && (defined(FEAT_GUI_GTK) || defined(FEAT_GUI_KDE))) \
 	|| (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) \
 	|| defined(PROTO)
 /*
@@ -2876,7 +2876,7 @@
 }
 #endif
 
-#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined (FEAT_GUI_MAC) \
+#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined (FEAT_GUI_MAC) || defined (FEAT_GUI_KDE) \
 	|| defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \
 	|| defined(FEAT_GUI_PHOTON) || defined(PROTO)
 /*
diff --git a/src/version.c b/src/version.c
index 0129343..a51550f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -859,6 +859,10 @@
 #	 else
 #	  if defined (MACOS)
     MSG_PUTS(_("with (classic) GUI."));
+#	   else
+#	    ifdef FEAT_GUI_KDE
+    MSG_PUTS(_("with KDE GUI."));
+#          endif
 #	  endif
 #	 endif
 #	endif
diff --git a/src/version.h b/src/version.h
index 2d98d28..5799d9c 100644
--- a/src/version.h
+++ b/src/version.h
@@ -36,5 +36,5 @@
 #define VIM_VERSION_NODOT	"vim70aa"
 #define VIM_VERSION_SHORT	"7.0aa"
 #define VIM_VERSION_MEDIUM	"7.0aa ALPHA"
-#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0aa ALPHA (2004 June 7)"
-#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2004 June 7, compiled "
+#define VIM_VERSION_LONG	"VIM - Vi IMproved 7.0aa ALPHA (2004 June 30)"
+#define VIM_VERSION_LONG_DATE	"VIM - Vi IMproved 7.0aa ALPHA (2004 June 30, compiled "
diff --git a/src/vim.h b/src/vim.h
index c348201..d196688 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -88,7 +88,8 @@
     || defined(FEAT_GUI_W16) \
     || defined(FEAT_GUI_BEOS) \
     || defined(FEAT_GUI_AMIGA) \
-    || defined(FEAT_GUI_PHOTON)
+    || defined(FEAT_GUI_PHOTON) \
+    || defined(FEAT_GUI_KDE)
 # ifndef FEAT_GUI
 #  define FEAT_GUI
 # endif
@@ -212,7 +213,15 @@
 # define __PARMS(x) __ARGS(x)
 #endif
 
-#if defined(UNIX) && !defined(MACOS_X) /* MACOS_X doesn't yet support osdef.h */
+/* if we're compiling in C++ (currently only KVim), the system
+ * headers must have the correct prototypes or nothing will build.
+ * conversely, our prototypes might clash due to throw() specifiers and
+ * cause compilation failures even though the headers are correct.  for
+ * a concrete example, gcc-3.2 enforces exception specifications, and
+ * glibc-2.2.5 has them in their system headers.
+ */
+#if !defined(__cplusplus) && defined(UNIX) \
+  && !defined(MACOS_X) /* MACOS_X doesn't yet support osdef.h */
 # include "auto/osdef.h"	/* bring missing declarations in */
 #endif
 
@@ -1022,6 +1031,9 @@
     EVENT_FOCUSGAINED,		/* got the focus */
     EVENT_FOCUSLOST,		/* lost the focus to another app */
     EVENT_GUIENTER,		/* after starting the GUI */
+    EVENT_INSERTCHANGE,		/* when changing Insert/Replace mode */
+    EVENT_INSERTENTER,		/* when entering Insert mode */
+    EVENT_INSERTLEAVE,		/* when leaving Insert mode */
     EVENT_STDINREADPOST,	/* after reading from stdin */
     EVENT_STDINREADPRE,		/* before reading from stdin */
     EVENT_SYNTAX,		/* syntax selected */
@@ -1473,7 +1485,8 @@
 #define VV_THROWPOINT	30
 #define VV_REG		31
 #define VV_CMDBANG	32
-#define VV_LEN		33	/* number of v: vars */
+#define VV_INSERTMODE	33
+#define VV_LEN		34	/* number of v: vars */
 
 #ifdef FEAT_CLIPBOARD
 
@@ -1572,7 +1585,7 @@
  * been seen at that stage.  But it must be before globals.h, where error_ga
  * is declared. */
 #if !defined(FEAT_GUI_W32) && !defined(FEAT_GUI_X11) \
-	&& !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MAC)
+	&& !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_KDE) && !defined(FEAT_GUI_MAC)
 # define mch_errmsg(str)	fprintf(stderr, "%s", (str))
 # define display_errors()	fflush(stderr)
 # define mch_msg(str)		printf("%s", (str))