changeset 2210:8c6a66e2b3cc vim73

Add :nbstart and :nbclose.
author Bram Moolenaar <bram@vim.org>
date Sat, 22 May 2010 21:34:09 +0200
parents d0ddf7ba1630
children dded7e33d0a9
files runtime/doc/eval.txt runtime/doc/index.txt runtime/doc/netbeans.txt runtime/doc/tags runtime/doc/todo.txt runtime/doc/version7.txt src/Makefile src/buffer.c src/edit.c src/eval.c src/ex_cmds.c src/ex_cmds.h src/ex_docmd.c src/fileio.c src/getchar.c src/globals.h src/gui.c src/gui_gtk_x11.c src/gui_w32.c src/gui_w48.c src/gui_x11.c src/main.c src/memline.c src/misc1.c src/move.c src/netbeans.c src/normal.c src/ops.c src/os_unix.c src/proto/gui_w32.pro src/proto/netbeans.pro src/screen.c src/ui.c src/undo.c
diffstat 34 files changed, 631 insertions(+), 442 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -6047,7 +6047,7 @@ multi_byte_ime		Compiled with support fo
 multi_lang		Compiled with support for multiple languages.
 mzscheme		Compiled with MzScheme interface |mzscheme|.
 netbeans_intg		Compiled with support for |netbeans|.
-netbeans_enabled	Compiled with support for |netbeans| and it's used.
+netbeans_enabled	Compiled with support for |netbeans| and connected.
 ole			Compiled with OLE automation support for Win32.
 os2			OS/2 version of Vim.
 osfiletype		Compiled with support for osfiletypes |+osfiletype|
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -1321,7 +1321,9 @@ The commands are sorted on the non-optio
 |:mode|		:mod[e]		show or change the screen mode
 |:mzscheme|	:mz[scheme]	execute MzScheme command
 |:mzfile|	:mzf[ile]	execute MzScheme script file
+|:nbclose|	:nbc[lose]	close the current Netbeans session
 |:nbkey|	:nb[key]	pass a key to Netbeans
+|:nbstart|	:nbs[art]	start a new Netbeans session
 |:next|		:n[ext]		go to next file in the argument list
 |:new|		:new		create a new empty window
 |:nmap|		:nm[ap]		like ":map" but for Normal mode
--- a/runtime/doc/netbeans.txt
+++ b/runtime/doc/netbeans.txt
@@ -14,7 +14,7 @@ 3.  Configuring Vim for NetBeans		|netbe
 4.  Error Messages				|netbeans-messages|
 5.  Running Vim in NetBeans mode		|netbeans-run|
 6.  NetBeans protocol				|netbeans-protocol|
-7.  NetBeans key				|netbeans-key|
+7.  NetBeans commands				|netbeans-commands|
 8.  Known problems				|netbeans-problems|
 9.  Debugging NetBeans protocol			|netbeans-debugging|
 10. NetBeans External Editor
@@ -48,6 +48,8 @@ Current projects using the NetBeans prot
 	http://www.a-a-p.org
 - Clewn, a gdb integration into Vim, written in C:
 	http://clewn.sourceforge.net/
+- Pyclewn, a gdb integration into Vim, written in Python:
+	http://pyclewn.sourceforge.net/
 - VimPlugin, integration of Vim inside Eclipse:
 	http://vimplugin.sourceforge.net/wiki/pmwiki.php
 - PIDA, IDE written in Python integrating Vim:
@@ -186,25 +188,37 @@ Read-only file
 ==============================================================================
 5. Running Vim in NetBeans mode				*netbeans-run*
 
-Vim must be started with the |-nb| argument.  Three forms can be used, that
-differ in the way the information for the connection is specified:
+There are two different ways to run Vim in NetBeans mode:
+
+	+ an IDE may start Vim with the|-nb|command line argument
+	+ NetBeans can be started from within Vim with the|:nbstart|command
+
+							*netbeans-parameters*
+Three forms can be used to setup the NetBeans connection parameters.
+When started from the command line, the|-nb|command line argument may be:
 
 	-nb={fname}				from a file
 	-nb:{hostname}:{addr}:{password}	directly
 	-nb					from a file or environment
 
+When started from within Vim, the|:nbstart|optional argument may be:
+
+	={fname}				from a file
+	:{hostname}:{addr}:{password}	        directly
+	<MISSING ARGUMENT>			from a file or environment
+
 							*E660* *E668*
-For security reasons, the best method is to write the information in a file
-readable only by the user.  The name of the file can be passed with the
-"-nb={fname}" argument or, when "-nb" is used without a parameter, the
-environment variable "__NETBEANS_CONINFO".  The file must contain these three
-lines, in any order:
+When NetBeans is started from the command line, for security reasons, the best
+method is to write the information in a file readable only by the user.  The
+name of the file can be passed with the "-nb={fname}" argument or, when "-nb"
+is used without a parameter, the environment variable "__NETBEANS_CONINFO".
+The file must contain these three lines, in any order:
 
 	host={hostname}
 	port={addr}
 	auth={password}
 
-Other lines are ignored.  The caller of Vim is responsible for deleting the
+Other lines are ignored.  The Vim Controller is responsible for deleting the
 file afterwards.
 
 {hostname} is the name of the machine where Vim Controller is running.  When
@@ -803,10 +817,22 @@ These errors occur when a message violat
 
 
 ==============================================================================
-7. NetBeans key						*netbeans-key*
+7. NetBeans commands					*netbeans-commands*
+
+							*:nbstart* *E511*
+:nbs[tart] {connection}	Start a new Netbeans session with {connection} as the
+			socket connection parameters.  The format of
+			{connection} is described in|netbeans-parameters|.
+			At any time, one may check if the netbeans socket is
+			connected by running the command:
+			':echo has("netbeans_enabled")'
+
+							*:nbclose*
+:nbc[lose]		Close the current NetBeans session. Remove all placed
+			signs.
 
 							*:nbkey*
-:nbkey key		Pass the key to the Vim Controller for processing
+:nb[key] {key}		Pass the {key} to the Vim Controller for processing
 
 When a hot-key has been installed with the specialKeys command, this command
 can be used to generate a hotkey messages to the Vim Controller. The events
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -2417,7 +2417,9 @@ 90.5	usr_90.txt	/*90.5*
 :mzfile	if_mzsch.txt	/*:mzfile*
 :mzscheme	if_mzsch.txt	/*:mzscheme*
 :n	editing.txt	/*:n*
+:nbclose	netbeans.txt	/*:nbclose*
 :nbkey	netbeans.txt	/*:nbkey*
+:nbstart	netbeans.txt	/*:nbstart*
 :ne	editing.txt	/*:ne*
 :new	windows.txt	/*:new*
 :next	editing.txt	/*:next*
@@ -3805,6 +3807,7 @@ E508	editing.txt	/*E508*
 E509	editing.txt	/*E509*
 E51	pattern.txt	/*E51*
 E510	editing.txt	/*E510*
+E511	netbeans.txt	/*E511*
 E512	editing.txt	/*E512*
 E513	options.txt	/*E513*
 E514	editing.txt	/*E514*
@@ -6541,14 +6544,15 @@ nb-special	netbeans.txt	/*nb-special*
 nb-terms	netbeans.txt	/*nb-terms*
 ncf.vim	syntax.txt	/*ncf.vim*
 netbeans	netbeans.txt	/*netbeans*
+netbeans-commands	netbeans.txt	/*netbeans-commands*
 netbeans-configure	netbeans.txt	/*netbeans-configure*
 netbeans-debugging	netbeans.txt	/*netbeans-debugging*
 netbeans-download	netbeans.txt	/*netbeans-download*
 netbeans-integration	netbeans.txt	/*netbeans-integration*
 netbeans-intro	netbeans.txt	/*netbeans-intro*
-netbeans-key	netbeans.txt	/*netbeans-key*
 netbeans-keybindings	netbeans.txt	/*netbeans-keybindings*
 netbeans-messages	netbeans.txt	/*netbeans-messages*
+netbeans-parameters	netbeans.txt	/*netbeans-parameters*
 netbeans-preparation	netbeans.txt	/*netbeans-preparation*
 netbeans-problems	netbeans.txt	/*netbeans-problems*
 netbeans-protocol	netbeans.txt	/*netbeans-protocol*
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1082,12 +1082,6 @@ restored. (Luc St-Louis)
 
 Vim 7.3:
 Patches to include:
-- nbstart command patch (Xavier de Gaye)
-    Keep nbkey as the first command in ex_cmds.h
-    NETBEANS_CLOSED -> NETBEANS_OPEN
-    netbeans_closed() -> netbeans_active()
-    do check netbeans_active() when calling netbeans_removed() et al.
-
 - Include conceal patch?
   http://vince.negri.googlepages.com/
   http://vim.wikia.com/wiki/Patch_to_conceal_parts_of_lines
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -7175,7 +7175,8 @@ Added the 'relativenumber' option. (Mark
 Support for Blowfish encryption.  Added the 'cryptmethod' option.
 Mostly by Moshin Ahmed.
 
-Added support for NetBeans in a terminal. (Xavier de Gaye)
+Added support for NetBeans in a terminal.  Added |:nbstart| and |:nbclose|.
+(Xavier de Gaye)
 
 More floating point functions: acos(), asin(), atan2(), cosh(), exp(), fmod(),
 log(), sinh(), tan(), tanh().  (Bill McCarthy)
--- a/src/Makefile
+++ b/src/Makefile
@@ -1305,8 +1305,9 @@ SHELL = /bin/sh
 
 PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS)
 POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(TCL_CFLAGS) $(RUBY_CFLAGS) $(EXTRA_DEFS)
-
-ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS)
+NOPROTO_DEFS = $(PYTHON_NOPROTO)
+
+ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS) $(NOPROTO_DEFS)
 
 # Exclude $CFLAGS for osdef.sh, for Mac 10.4 some flags don't work together
 # with "-E".
@@ -2678,313 +2679,321 @@ bundle-language: bundle-dir
 ###############################################################################
 ### (automatically generated by 'make depend')
 ### Dependencies:
+objects/blowfish.o: blowfish.c vim.h auto/config.h feature.h os_unix.h \
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/buffer.o: buffer.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h version.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h version.h
 objects/charset.o: charset.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/diff.o: diff.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/digraph.o: digraph.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/edit.o: edit.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/eval.o: eval.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h version.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h version.h
 objects/ex_cmds.o: ex_cmds.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h version.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h version.h
 objects/ex_cmds2.o: ex_cmds2.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h version.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
 objects/ex_docmd.o: ex_docmd.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/ex_eval.o: ex_eval.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/ex_getln.o: ex_getln.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/fileio.o: fileio.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/fold.o: fold.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/getchar.o: getchar.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/hardcopy.o: hardcopy.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h version.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
 objects/hashtab.o: hashtab.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/if_cscope.o: if_cscope.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h if_cscope.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h if_cscope.h
 objects/if_xcmdsrv.o: if_xcmdsrv.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h version.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
 objects/main.o: main.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h farsi.c arabic.c
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h farsi.c arabic.c
 objects/mark.o: mark.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/memfile.o: memfile.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/memline.o: memline.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/menu.o: menu.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/message.o: message.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/misc1.o: misc1.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h version.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h version.h
 objects/misc2.o: misc2.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/move.o: move.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/mbyte.o: mbyte.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/normal.o: normal.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/ops.o: ops.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h \
-  keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
-  proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
+ keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
+ proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
 objects/option.o: option.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/os_unix.o: os_unix.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h os_unixx.h
-objects/pathdef.o: auto/pathdef.c ./vim.h ./auto/config.h ./feature.h ./os_unix.h \
-  ./auto/osdef.h ./ascii.h ./keymap.h ./term.h ./macros.h ./option.h \
-  ./structs.h ./regexp.h ./gui.h ./gui_beval.h proto/gui_beval.pro \
-  ./ex_cmds.h ./proto.h ./globals.h ./farsi.h ./arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h if_mzsch.h os_unixx.h
+objects/pathdef.o: auto/pathdef.c vim.h auto/config.h feature.h os_unix.h \
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/popupmnu.o: popupmnu.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/quickfix.o: quickfix.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/regexp.o: regexp.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/screen.o: screen.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/search.o: search.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
+objects/sha256.o: sha256.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/spell.o: spell.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/syntax.o: syntax.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/tag.o: tag.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h \
-  keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
-  proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
+ keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
+ proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
 objects/term.o: term.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/ui.o: ui.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h \
-  keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
-  proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
+ keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
+ proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
 objects/undo.o: undo.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/version.o: version.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h version.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h version.h
 objects/window.o: window.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/gui.o: gui.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h \
-  keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
-  proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
+ keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
+ proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
 objects/gui_gtk.o: gui_gtk.c gui_gtk_f.h vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h ../pixmaps/stock_icons.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h ../pixmaps/stock_icons.h
 objects/gui_gtk_f.o: gui_gtk_f.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h gui_gtk_f.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_gtk_f.h
 objects/gui_motif.o: gui_motif.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h gui_xmebw.h ../pixmaps/alert.xpm \
-  ../pixmaps/error.xpm ../pixmaps/generic.xpm ../pixmaps/info.xpm \
-  ../pixmaps/quest.xpm gui_x11_pm.h ../pixmaps/tb_new.xpm \
-  ../pixmaps/tb_open.xpm ../pixmaps/tb_close.xpm ../pixmaps/tb_save.xpm \
-  ../pixmaps/tb_print.xpm ../pixmaps/tb_cut.xpm ../pixmaps/tb_copy.xpm \
-  ../pixmaps/tb_paste.xpm ../pixmaps/tb_find.xpm \
-  ../pixmaps/tb_find_next.xpm ../pixmaps/tb_find_prev.xpm \
-  ../pixmaps/tb_find_help.xpm ../pixmaps/tb_exit.xpm \
-  ../pixmaps/tb_undo.xpm ../pixmaps/tb_redo.xpm ../pixmaps/tb_help.xpm \
-  ../pixmaps/tb_macro.xpm ../pixmaps/tb_make.xpm \
-  ../pixmaps/tb_save_all.xpm ../pixmaps/tb_jump.xpm \
-  ../pixmaps/tb_ctags.xpm ../pixmaps/tb_load_session.xpm \
-  ../pixmaps/tb_save_session.xpm ../pixmaps/tb_new_session.xpm \
-  ../pixmaps/tb_blank.xpm ../pixmaps/tb_maximize.xpm \
-  ../pixmaps/tb_split.xpm ../pixmaps/tb_minimize.xpm \
-  ../pixmaps/tb_shell.xpm ../pixmaps/tb_replace.xpm \
-  ../pixmaps/tb_vsplit.xpm ../pixmaps/tb_maxwidth.xpm \
-  ../pixmaps/tb_minwidth.xpm
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_xmebw.h ../pixmaps/alert.xpm \
+ ../pixmaps/error.xpm ../pixmaps/generic.xpm ../pixmaps/info.xpm \
+ ../pixmaps/quest.xpm gui_x11_pm.h ../pixmaps/tb_new.xpm \
+ ../pixmaps/tb_open.xpm ../pixmaps/tb_close.xpm ../pixmaps/tb_save.xpm \
+ ../pixmaps/tb_print.xpm ../pixmaps/tb_cut.xpm ../pixmaps/tb_copy.xpm \
+ ../pixmaps/tb_paste.xpm ../pixmaps/tb_find.xpm \
+ ../pixmaps/tb_find_next.xpm ../pixmaps/tb_find_prev.xpm \
+ ../pixmaps/tb_find_help.xpm ../pixmaps/tb_exit.xpm \
+ ../pixmaps/tb_undo.xpm ../pixmaps/tb_redo.xpm ../pixmaps/tb_help.xpm \
+ ../pixmaps/tb_macro.xpm ../pixmaps/tb_make.xpm \
+ ../pixmaps/tb_save_all.xpm ../pixmaps/tb_jump.xpm \
+ ../pixmaps/tb_ctags.xpm ../pixmaps/tb_load_session.xpm \
+ ../pixmaps/tb_save_session.xpm ../pixmaps/tb_new_session.xpm \
+ ../pixmaps/tb_blank.xpm ../pixmaps/tb_maximize.xpm \
+ ../pixmaps/tb_split.xpm ../pixmaps/tb_minimize.xpm \
+ ../pixmaps/tb_shell.xpm ../pixmaps/tb_replace.xpm \
+ ../pixmaps/tb_vsplit.xpm ../pixmaps/tb_maxwidth.xpm \
+ ../pixmaps/tb_minwidth.xpm
 objects/gui_xmdlg.o: gui_xmdlg.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/gui_xmebw.o: gui_xmebw.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h gui_xmebwp.h gui_xmebw.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_xmebwp.h gui_xmebw.h
 objects/gui_athena.o: gui_athena.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h gui_at_sb.h gui_x11_pm.h \
-  ../pixmaps/tb_new.xpm ../pixmaps/tb_open.xpm ../pixmaps/tb_close.xpm \
-  ../pixmaps/tb_save.xpm ../pixmaps/tb_print.xpm ../pixmaps/tb_cut.xpm \
-  ../pixmaps/tb_copy.xpm ../pixmaps/tb_paste.xpm ../pixmaps/tb_find.xpm \
-  ../pixmaps/tb_find_next.xpm ../pixmaps/tb_find_prev.xpm \
-  ../pixmaps/tb_find_help.xpm ../pixmaps/tb_exit.xpm \
-  ../pixmaps/tb_undo.xpm ../pixmaps/tb_redo.xpm ../pixmaps/tb_help.xpm \
-  ../pixmaps/tb_macro.xpm ../pixmaps/tb_make.xpm \
-  ../pixmaps/tb_save_all.xpm ../pixmaps/tb_jump.xpm \
-  ../pixmaps/tb_ctags.xpm ../pixmaps/tb_load_session.xpm \
-  ../pixmaps/tb_save_session.xpm ../pixmaps/tb_new_session.xpm \
-  ../pixmaps/tb_blank.xpm ../pixmaps/tb_maximize.xpm \
-  ../pixmaps/tb_split.xpm ../pixmaps/tb_minimize.xpm \
-  ../pixmaps/tb_shell.xpm ../pixmaps/tb_replace.xpm \
-  ../pixmaps/tb_vsplit.xpm ../pixmaps/tb_maxwidth.xpm \
-  ../pixmaps/tb_minwidth.xpm
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_at_sb.h gui_x11_pm.h \
+ ../pixmaps/tb_new.xpm ../pixmaps/tb_open.xpm ../pixmaps/tb_close.xpm \
+ ../pixmaps/tb_save.xpm ../pixmaps/tb_print.xpm ../pixmaps/tb_cut.xpm \
+ ../pixmaps/tb_copy.xpm ../pixmaps/tb_paste.xpm ../pixmaps/tb_find.xpm \
+ ../pixmaps/tb_find_next.xpm ../pixmaps/tb_find_prev.xpm \
+ ../pixmaps/tb_find_help.xpm ../pixmaps/tb_exit.xpm \
+ ../pixmaps/tb_undo.xpm ../pixmaps/tb_redo.xpm ../pixmaps/tb_help.xpm \
+ ../pixmaps/tb_macro.xpm ../pixmaps/tb_make.xpm \
+ ../pixmaps/tb_save_all.xpm ../pixmaps/tb_jump.xpm \
+ ../pixmaps/tb_ctags.xpm ../pixmaps/tb_load_session.xpm \
+ ../pixmaps/tb_save_session.xpm ../pixmaps/tb_new_session.xpm \
+ ../pixmaps/tb_blank.xpm ../pixmaps/tb_maximize.xpm \
+ ../pixmaps/tb_split.xpm ../pixmaps/tb_minimize.xpm \
+ ../pixmaps/tb_shell.xpm ../pixmaps/tb_replace.xpm \
+ ../pixmaps/tb_vsplit.xpm ../pixmaps/tb_maxwidth.xpm \
+ ../pixmaps/tb_minwidth.xpm
 objects/gui_gtk_x11.o: gui_gtk_x11.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h gui_gtk_f.h ../runtime/vim32x32.xpm \
-  ../runtime/vim16x16.xpm ../runtime/vim48x48.xpm
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_gtk_f.h ../runtime/vim32x32.xpm \
+ ../runtime/vim16x16.xpm ../runtime/vim48x48.xpm
 objects/gui_x11.o: gui_x11.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h ../runtime/vim32x32.xpm ../runtime/vim16x16.xpm \
-  ../runtime/vim48x48.xpm
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h ../runtime/vim32x32.xpm ../runtime/vim16x16.xpm \
+ ../runtime/vim48x48.xpm
 objects/gui_at_sb.o: gui_at_sb.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h gui_at_sb.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_at_sb.h
 objects/gui_at_fs.o: gui_at_fs.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h gui_at_sb.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h gui_at_sb.h
 objects/pty.o: pty.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h ascii.h \
-  keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
-  proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.h
+ keymap.h term.h macros.h option.h structs.h regexp.h gui.h gui_beval.h \
+ proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h arabic.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 option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/if_mzsch.o: if_mzsch.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h if_mzsch.h
-objects/if_perl.o: auto/if_perl.c ./vim.h ./auto/config.h ./feature.h ./os_unix.h \
-  ./auto/osdef.h ./ascii.h ./keymap.h ./term.h ./macros.h ./option.h \
-  ./structs.h ./regexp.h ./gui.h ./gui_beval.h proto/gui_beval.pro \
-  ./ex_cmds.h ./proto.h ./globals.h ./farsi.h ./arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h if_mzsch.h mzscheme_base.c
+objects/if_perl.o: auto/if_perl.c vim.h auto/config.h feature.h os_unix.h \
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/if_perlsfio.o: if_perlsfio.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/if_python.o: if_python.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/if_tcl.o: if_tcl.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h
 objects/if_ruby.o: if_ruby.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
-  ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
-  gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
-  arabic.h version.h
+ ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
+ gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \
+ arabic.h version.h
 objects/if_sniff.o: if_sniff.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h os_unixx.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h os_unixx.h
 objects/gui_beval.o: gui_beval.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h
 objects/workshop.o: workshop.c auto/config.h integration.h vim.h feature.h \
-  os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h \
-  structs.h regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h \
-  proto.h globals.h farsi.h arabic.h version.h workshop.h
+ os_unix.h auto/osdef.h ascii.h keymap.h term.h macros.h option.h \
+ structs.h regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h \
+ proto.h globals.h farsi.h arabic.h version.h workshop.h
 objects/wsdebug.o: wsdebug.c
 objects/integration.o: integration.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h integration.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h integration.h
 objects/netbeans.o: netbeans.c vim.h auto/config.h feature.h os_unix.h \
-  auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
-  regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
-  globals.h farsi.h arabic.h version.h
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
+ globals.h farsi.h arabic.h version.h
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -636,8 +636,7 @@ free_buffer_stuff(buf, free_options)
     buf_delete_signs(buf);		/* delete any signs */
 #endif
 #ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
-        netbeans_file_killed(buf);
+    netbeans_file_killed(buf);
 #endif
 #ifdef FEAT_LOCALMAP
     map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE);  /* clear local mappings */
@@ -1447,8 +1446,7 @@ enter_buffer(buf)
 
 #ifdef FEAT_NETBEANS_INTG
     /* Send fileOpened event because we've changed buffers. */
-    if (usingNetbeans && isNetbeansBuffer(curbuf))
-	netbeans_file_activated(curbuf);
+    netbeans_file_activated(curbuf);
 #endif
 
     /* Change directories when the 'acd' option is set. */
--- a/src/edit.c
+++ b/src/edit.c
@@ -6267,7 +6267,7 @@ comp_textwidth(ff)
 #ifdef FEAT_SIGNS
 	if (curwin->w_buffer->b_signlist != NULL
 # ifdef FEAT_NETBEANS_INTG
-			    || usingNetbeans
+			    || netbeans_active()
 # endif
 		    )
 	    textwidth -= 1;
@@ -9431,7 +9431,7 @@ ins_tab()
 			replace_join(repl_off);
 	    }
 #ifdef FEAT_NETBEANS_INTG
-	    if (usingNetbeans)
+	    if (netbeans_active())
 	    {
 		netbeans_removed(curbuf, fpos.lnum, cursor->col, (long)(i + 1));
 		netbeans_inserted(curbuf, fpos.lnum, cursor->col,
--- a/src/eval.c
+++ b/src/eval.c
@@ -12093,7 +12093,7 @@ f_has(argvars, rettv)
 #endif
 #ifdef FEAT_NETBEANS_INTG
 	else if (STRICMP(name, "netbeans_enabled") == 0)
-	    n = usingNetbeans;
+	    n = netbeans_active();
 #endif
     }
 
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -3822,7 +3822,7 @@ do_ecmd(fnum, ffname, sfname, eap, newln
 	    workshop_file_opened((char *)curbuf->b_ffname, curbuf->b_p_ro);
 # endif
 # ifdef FEAT_NETBEANS_INTG
-	if (usingNetbeans && ((flags & ECMD_SET_HELP) != ECMD_SET_HELP))
+	if ((flags & ECMD_SET_HELP) != ECMD_SET_HELP)
 	    netbeans_file_opened(curbuf);
 # endif
     }
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -621,6 +621,10 @@ EX(CMD_next,		"next",		ex_next,
 			RANGE|NOTADR|BANG|FILES|EDITCMD|ARGOPT|TRLBAR),
 EX(CMD_nbkey,		"nbkey",	ex_nbkey,
 			EXTRA|NOTADR|NEEDARG),
+EX(CMD_nbclose,		"nbclose",	ex_nbclose,
+			TRLBAR|CMDWIN),
+EX(CMD_nbstart,		"nbstart",	ex_nbstart,
+			WORD1|TRLBAR|CMDWIN),
 EX(CMD_new,		"new",		ex_splitview,
 			BANG|FILE1|RANGE|NOTADR|EDITCMD|ARGOPT|TRLBAR),
 EX(CMD_nmap,		"nmap",		ex_map,
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -439,7 +439,9 @@ static void	ex_folddo __ARGS((exarg_T *e
 # define ex_wsverb		ex_ni
 #endif
 #ifndef FEAT_NETBEANS_INTG
+# define ex_nbclose		ex_ni
 # define ex_nbkey		ex_ni
+# define ex_nbstart		ex_ni
 #endif
 
 #ifndef FEAT_EVAL
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3309,7 +3309,7 @@ buf_write(buf, fname, sfname, start, end
 #endif
 
 #ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans && isNetbeansBuffer(buf))
+    if (netbeans_active() && isNetbeansBuffer(buf))
     {
 	if (whole)
 	{
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -2941,8 +2941,7 @@ inchar(buf, maxlen, wait_time, tb_change
 
 #if defined(FEAT_NETBEANS_INTG)
 	/* Process the queued netbeans messages. */
-	if (usingNetbeans)
-	    netbeans_parse_messages();
+        netbeans_parse_messages();
 #endif
 
 	if (got_int || (script_char = getc(scriptin[curscript])) < 0)
--- a/src/globals.h
+++ b/src/globals.h
@@ -1369,7 +1369,6 @@ EXTERN int netbeansFireChanges INIT(= 1)
 EXTERN int netbeansForcedQuit INIT(= 0);/* don't write modified files */
 EXTERN int netbeansReadFile INIT(= 1);	/* OK to read from disk if != 0 */
 EXTERN int netbeansSuppressNoLines INIT(= 0); /* skip "No lines in buffer" */
-EXTERN int usingNetbeans INIT(= 0);	/* set if -nb flag is used */
 #endif
 
 /*
--- a/src/gui.c
+++ b/src/gui.c
@@ -4781,8 +4781,7 @@ ex_gui(eap)
 	msg_clr_eos_force();
 	gui_start();
 #ifdef FEAT_NETBEANS_INTG
-	if (usingNetbeans)
-	    netbeans_gui_register();
+	netbeans_gui_register();
 #endif
     }
     if (!ends_excmd(*eap->arg))
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -567,7 +567,6 @@ gui_mch_prepare(int *argc, char **argv)
 #endif
 #ifdef FEAT_NETBEANS_INTG
 		case ARG_NETBEANS:
-		    ++usingNetbeans;
 		    gui.dofork = FALSE; /* don't fork() when starting GUI */
 		    netbeansArg = argv[i];
 		    break;
@@ -6596,8 +6595,7 @@ gui_mch_wait_for_chars(long wtime)
 
 #if defined(FEAT_NETBEANS_INTG)
 	/* Process the queued netbeans messages. */
-	if (usingNetbeans)
-	    netbeans_parse_messages();
+        netbeans_parse_messages();
 #endif
 
 	/*
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -1278,24 +1278,12 @@ gui_mch_prepare(int *argc, char **argv)
 	for (arg = 1; arg < *argc; arg++)
 	    if (strncmp("-nb", argv[arg], 3) == 0)
 	    {
-		usingNetbeans++;
 		netbeansArg = argv[arg];
 		mch_memmove(&argv[arg], &argv[arg + 1],
 					    (--*argc - arg) * sizeof(char *));
 		argv[*argc] = NULL;
 		break;	/* enough? */
 	    }
-
-	if (usingNetbeans)
-	{
-	    WSADATA wsaData;
-	    int wsaerr;
-
-	    /* Init WinSock */
-	    wsaerr = WSAStartup(MAKEWORD(2, 2), &wsaData);
-	    if (wsaerr == 0)
-		WSInitialized = TRUE;
-	}
     }
 #endif
 
@@ -4840,6 +4828,9 @@ netbeans_draw_multisign_indicator(int ro
     int y;
     int x;
 
+    if (!netbeans_active())
+        return;
+
     x = 0;
     y = TEXT_Y(row);
 
@@ -4854,4 +4845,21 @@ netbeans_draw_multisign_indicator(int ro
     SetPixel(s_hdc, x+3, y++, gui.currFgColor);
     SetPixel(s_hdc, x+2, y, gui.currFgColor);
 }
+
+/*
+ * Initialize the Winsock dll.
+ */
+    void
+netbeans_init_winsock()
+{
+    WSADATA wsaData;
+    int wsaerr;
+
+    if (WSInitialized)
+        return;
+
+    wsaerr = WSAStartup(MAKEWORD(2, 2), &wsaData);
+    if (wsaerr == 0)
+        WSInitialized = TRUE;
+}
 #endif
--- a/src/gui_w48.c
+++ b/src/gui_w48.c
@@ -1999,8 +1999,7 @@ gui_mch_wait_for_chars(int wtime)
 
 #ifdef FEAT_NETBEANS_INTG
 	/* Process the queued netbeans messages. */
-	if (usingNetbeans)
-	    netbeans_parse_messages();
+        netbeans_parse_messages();
 #endif
 
 	/*
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -710,7 +710,7 @@ gui_x11_resize_window_cb(w, dud, event, 
     }
 #endif
 #if defined(FEAT_NETBEANS_INTG) && defined(FEAT_GUI_MOTIF)
-    if (usingNetbeans)
+    if (netbeans_active())
     {
 	XRectangle  rec;
 
@@ -1253,7 +1253,6 @@ gui_mch_prepare(argc, argv)
 #ifdef FEAT_NETBEANS_INTG
 	    if (strncmp("-nb", argv[arg], 3) == 0)
 	{
-	    usingNetbeans++;
 	    gui.dofork = FALSE;	/* don't fork() when starting GUI */
 	    netbeansArg = argv[arg];
 	    mch_memmove(&argv[arg], &argv[arg + 1],
--- a/src/main.c
+++ b/src/main.c
@@ -932,7 +932,7 @@ main
 	stuffcharReadbuff(K_NOP);
 
 #ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
+    if (netbeansArg != NULL && strncmp("-nb", netbeansArg, 3) == 0)
     {
 # ifdef FEAT_GUI
 #  if !defined(FEAT_GUI_MOTIF) && !defined(FEAT_GUI_GTK)  \
@@ -945,7 +945,7 @@ main
 #  endif
 # endif
 	/* Tell the client that it can start sending commands. */
-	netbeans_startup_done();
+	netbeans_open(netbeansArg + 3, TRUE);
     }
 #endif
 
@@ -1891,7 +1891,6 @@ command_line_scan(parmp)
 		/* checking for "-nb", netbeans parameters */
 		if (argv[0][argv_idx] == 'b')
 		{
-		    ++usingNetbeans;
 		    netbeansArg = argv[0];
 		    argv_idx = -1;	    /* skip to next argument */
 		}
@@ -2385,7 +2384,7 @@ check_tty(parmp)
 	 * input buffer so fast I can't even kill the process in under 2
 	 * minutes (and it beeps continuously the whole time :-)
 	 */
-	if (usingNetbeans && (!parmp->stdout_isatty || !input_isatty))
+	if (netbeans_active() && (!parmp->stdout_isatty || !input_isatty))
 	{
 	    mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n"));
 	    exit(1);
--- a/src/memline.c
+++ b/src/memline.c
@@ -2753,7 +2753,7 @@ ml_append_int(buf, lnum, line, len, newf
     ml_updatechunk(buf, lnum + 1, (long)len, ML_CHNK_ADDLINE);
 #endif
 #ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
+    if (netbeans_active())
     {
 	if (STRLEN(line) > 0)
 	    netbeans_inserted(buf, lnum+1, (colnr_T)0, line, (int)STRLEN(line));
@@ -2791,7 +2791,7 @@ ml_replace(lnum, line, copy)
     if (copy && (line = vim_strsave(line)) == NULL) /* allocate memory */
 	return FAIL;
 #ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
+    if (netbeans_active())
     {
 	netbeans_removed(curbuf, lnum, 0, (long)STRLEN(ml_get(lnum)));
 	netbeans_inserted(curbuf, lnum, 0, line, (int)STRLEN(line));
@@ -2896,7 +2896,7 @@ ml_delete_int(buf, lnum, message)
 	line_size = ((dp->db_index[idx - 1]) & DB_INDEX_MASK) - line_start;
 
 #ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
+    if (netbeans_active())
 	netbeans_removed(buf, lnum, 0, (long)line_size);
 #endif
 
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -2277,7 +2277,7 @@ del_bytes(count, fixpos_arg, use_delcomb
      * care of notifiying Netbeans.
      */
 #ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
+    if (netbeans_active())
 	was_alloced = FALSE;
     else
 #endif
--- a/src/move.c
+++ b/src/move.c
@@ -933,8 +933,8 @@ win_col_off(wp)
 #ifdef FEAT_SIGNS
 	    + (
 # ifdef FEAT_NETBEANS_INTG
-		/* always show glyph gutter in netbeans */
-		usingNetbeans ||
+		/* show glyph gutter in netbeans */
+		netbeans_active() ||
 # endif
 		wp->w_buffer->b_signlist != NULL ? 2 : 0)
 #endif
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -24,6 +24,9 @@
 
 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
 
+/* TODO: when should this not be defined? */
+#define INET_SOCKETS
+
 /* Note: when making changes here also adjust configure.in. */
 #ifdef WIN32
 # ifdef DEBUG
@@ -43,8 +46,13 @@
 # define sock_close(sd) closesocket(sd)
 # define sleep(t) Sleep(t*1000) /* WinAPI Sleep() accepts milliseconds */
 #else
-# include <netdb.h>
-# include <netinet/in.h>
+# ifdef INET_SOCKETS
+#  include <netdb.h>
+#  include <netinet/in.h>
+# else
+#  include <sys/un.h>
+# endif
+
 # include <sys/socket.h>
 # ifdef HAVE_LIBGEN_H
 #  include <libgen.h>
@@ -57,8 +65,6 @@
 
 #include "version.h"
 
-#define INET_SOCKETS
-
 #define GUARDED		10000 /* typenr for "guarded" annotation */
 #define GUARDEDOFFSET 1000000 /* base for "guarded" sign id's */
 #define MAX_COLOR_LENGTH 32 /* max length of color name in defineAnnoType */
@@ -75,7 +81,7 @@ static int netbeans_keystring __ARGS((ch
 static void postpone_keycommand __ARGS((char_u *keystr));
 static void special_keys __ARGS((char_u *args));
 
-static void netbeans_connect __ARGS((void));
+static int netbeans_connect __ARGS((char *, int));
 static int getConnInfo __ARGS((char *file, char **host, char **port, char **password));
 
 static void nb_init_graphics __ARGS((void));
@@ -90,6 +96,7 @@ static void messageFromNetbeans __ARGS((
 static void nb_parse_cmd __ARGS((char_u *));
 static int  nb_do_cmd __ARGS((int, char_u *, int, int, char_u *));
 static void nb_send __ARGS((char *buf, char *fun));
+static void nb_free __ARGS((void));
 
 /* TRUE when netbeans is running with a GUI. */
 #ifdef FEAT_GUI
@@ -102,20 +109,20 @@ typedef __int64 NBSOCK;
 typedef int NBSOCK;
 #endif
 
-static NBSOCK sd = -1;			/* socket fd for Netbeans connection */
+static NBSOCK nbsock = -1;		/* socket fd for Netbeans connection */
+#define NETBEANS_OPEN (nbsock != -1)
+
 #ifdef FEAT_GUI_MOTIF
-static XtInputId inputHandler;		/* Cookie for input */
+static XtInputId inputHandler = (XtInputId)NULL;  /* Cookie for input */
 #endif
 #ifdef FEAT_GUI_GTK
-static gint inputHandler;		/* Cookie for input */
+static gint inputHandler = 0;		/* Cookie for input */
 #endif
 #ifdef FEAT_GUI_W32
 static int  inputHandler = -1;		/* simply ret.value of WSAAsyncSelect() */
 extern HWND s_hwnd;			/* Gvim's Window handle */
 #endif
 static int r_cmdno;			/* current command number for reply */
-static int haveConnection = FALSE;	/* socket is connected and
-					   initialization is done */
 static int dosetvisible = FALSE;
 
 /*
@@ -125,10 +132,17 @@ static int dosetvisible = FALSE;
 # include "nbdebug.c"
 #endif
 
-/* Connect back to Netbeans process */
+static int needupdate = 0;
+static int inAtomic = 0;
+
     static void
-netbeans_disconnect(void)
+netbeans_close(void)
 {
+    if (!NETBEANS_OPEN)
+	return;
+
+    netbeans_send_disconnect();
+
 #ifdef FEAT_GUI_MOTIF
     if (inputHandler != (XtInputId)NULL)
     {
@@ -146,26 +160,42 @@ netbeans_disconnect(void)
 #  ifdef FEAT_GUI_W32
     if (inputHandler == 0)
     {
-	WSAAsyncSelect(sd, s_hwnd, 0, 0);
+	WSAAsyncSelect(nbsock, s_hwnd, 0, 0);
 	inputHandler = -1;
     }
 #  endif
 # endif
 #endif
 
-    sd = -1;
-    haveConnection = FALSE;
 #ifdef FEAT_BEVAL
     bevalServers &= ~BEVAL_NETBEANS;
 #endif
+
+    sock_close(nbsock);
+    nbsock = -1;
+
+    needupdate = 0;
+    inAtomic = 0;
+    nb_free();
+
+    /* remove all signs and update the screen after gutter removal */
+    coloncmd(":sign unplace *");
+    changed_window_setting();
+    update_screen(CLEAR);
+    setcursor();
+    out_flush();
+#ifdef FEAT_GUI
+    gui_update_cursor(TRUE, FALSE);
+    gui_mch_flush();
+#endif
 }
 
 #define NB_DEF_HOST "localhost"
 #define NB_DEF_ADDR "3219"
 #define NB_DEF_PASS "changeme"
 
-    static void
-netbeans_connect(void)
+    static int
+netbeans_connect(char *params, int abort)
 {
 #ifdef INET_SOCKETS
     struct sockaddr_in	server;
@@ -178,6 +208,7 @@ netbeans_connect(void)
 #else
     struct sockaddr_un	server;
 #endif
+    int		sd;
     char	buf[32];
     char	*hostname = NULL;
     char	*address = NULL;
@@ -185,29 +216,29 @@ netbeans_connect(void)
     char	*fname;
     char	*arg = NULL;
 
-    if (netbeansArg[3] == '=')
+    if (*params == '=')
     {
-	/* "-nb=fname": Read info from specified file. */
-	if (getConnInfo(netbeansArg + 4, &hostname, &address, &password)
+	/* "=fname": Read info from specified file. */
+	if (getConnInfo(params + 1, &hostname, &address, &password)
 								      == FAIL)
-	    return;
+	    return FAIL;
     }
     else
     {
-	if (netbeansArg[3] == ':')
-	    /* "-nb:<host>:<addr>:<password>": get info from argument */
-	    arg = netbeansArg + 4;
+	if (*params == ':')
+	    /* ":<host>:<addr>:<password>": get info from argument */
+	    arg = params + 1;
 	if (arg == NULL && (fname = getenv("__NETBEANS_CONINFO")) != NULL)
 	{
-	    /* "-nb": get info from file specified in environment */
+	    /* "": get info from file specified in environment */
 	    if (getConnInfo(fname, &hostname, &address, &password) == FAIL)
-		return;
+		return FAIL;
 	}
 	else
 	{
 	    if (arg != NULL)
 	    {
-		/* "-nb:<host>:<addr>:<password>": get info from argument */
+		/* ":<host>:<addr>:<password>": get info from argument */
 		hostname = arg;
 		address = strchr(hostname, ':');
 		if (address != NULL)
@@ -256,6 +287,10 @@ netbeans_connect(void)
     if (hostname == NULL || address == NULL || password == NULL)
 	goto theend;	    /* out of memory */
 
+#ifdef FEAT_GUI_W32
+    netbeans_init_winsock();
+#endif
+
 #ifdef INET_SOCKETS
     port = atoi(address);
 
@@ -281,7 +316,6 @@ netbeans_connect(void)
 	}
 	nbdebug(("error in gethostbyname() in netbeans_connect()\n"));
 	PERROR("gethostbyname() in netbeans_connect()");
-	sd = -1;
 	goto theend;
     }
     memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
@@ -327,6 +361,15 @@ netbeans_connect(void)
 		{
 		    nbdebug(("retrying...\n"));
 		    sleep(5);
+		    if (!abort)
+		    {
+			ui_breakcheck();
+			if (got_int)
+			{
+			    sock_errno = EINTR;
+			    break;
+			}
+		    }
 		    if (connect(sd, (struct sockaddr *)&server,
 				sizeof(server)) == 0)
 		    {
@@ -339,7 +382,9 @@ netbeans_connect(void)
 		    /* Get here when the server can't be found. */
 		    nbdebug(("Cannot connect to Netbeans #2\n"));
 		    PERROR(_("Cannot connect to Netbeans #2"));
-		    getout(1);
+		    if (abort)
+			getout(1);
+		    goto theend;
 		}
 	    }
 
@@ -348,25 +393,24 @@ netbeans_connect(void)
 	{
 	    nbdebug(("Cannot connect to Netbeans\n"));
 	    PERROR(_("Cannot connect to Netbeans"));
-	    getout(1);
+	    if (abort)
+		getout(1);
+	    goto theend;
 	}
     }
 
+    nbsock = sd;
     vim_snprintf(buf, sizeof(buf), "AUTH %s\n", password);
     nb_send(buf, "netbeans_connect");
 
     sprintf(buf, "0:version=0 \"%s\"\n", ExtEdProtocolVersion);
     nb_send(buf, "externaleditor_version");
 
-/*    nb_init_graphics();  delay until needed */
-
-    haveConnection = TRUE;
-
 theend:
     vim_free(hostname);
     vim_free(address);
     vim_free(password);
-    return;
+    return NETBEANS_OPEN ? OK : FAIL;
 }
 
 /*
@@ -580,6 +624,9 @@ netbeans_parse_messages(void)
     char_u	*p;
     queue_T	*node;
 
+    if (!NETBEANS_OPEN)
+	return;
+
     while (head.next != NULL && head.next != &head)
     {
 	node = head.next;
@@ -683,7 +730,7 @@ netbeans_read()
 # endif
 #endif
 
-    if (sd < 0)
+    if (!NETBEANS_OPEN)
     {
 	nbdebug(("messageFromNetbeans() called without a socket\n"));
 	return;
@@ -711,20 +758,20 @@ netbeans_read()
     {
 #ifdef HAVE_SELECT
 	FD_ZERO(&rfds);
-	FD_SET(sd, &rfds);
+	FD_SET(nbsock, &rfds);
 	tval.tv_sec = 0;
 	tval.tv_usec = 0;
-	if (select(sd + 1, &rfds, NULL, NULL, &tval) <= 0)
+	if (select(nbsock + 1, &rfds, NULL, NULL, &tval) <= 0)
 	    break;
 #else
 # ifdef HAVE_POLL
-	fds.fd = sd;
+	fds.fd = nbsock;
 	fds.events = POLLIN;
 	if (poll(&fds, 1, 0) <= 0)
 	    break;
 # endif
 #endif
-	len = sock_read(sd, buf, MAXMSGSIZE);
+	len = sock_read(nbsock, buf, MAXMSGSIZE);
 	if (len <= 0)
 	    break;	/* error or nothing more to read */
 
@@ -738,7 +785,7 @@ netbeans_read()
     if (readlen <= 0)
     {
 	/* read error or didn't read anything */
-	netbeans_disconnect();
+	netbeans_close();
 	nbdebug(("messageFromNetbeans: Error in read() from socket\n"));
 	if (len < 0)
 	{
@@ -793,11 +840,9 @@ nb_parse_cmd(char_u *cmd)
     if (STRCMP(cmd, "DISCONNECT") == 0)
     {
 	/* We assume the server knows that we can safely exit! */
-	if (sd >= 0)
-	    sock_close(sd);
 	/* Disconnect before exiting, Motif hangs in a Select error
 	 * message otherwise. */
-	netbeans_disconnect();
+	netbeans_close();
 	getout(0);
 	/* NOTREACHED */
     }
@@ -805,9 +850,7 @@ nb_parse_cmd(char_u *cmd)
     if (STRCMP(cmd, "DETACH") == 0)
     {
 	/* The IDE is breaking the connection. */
-	if (sd >= 0)
-	    sock_close(sd);
-	netbeans_disconnect();
+	netbeans_close();
 	return;
     }
 
@@ -878,13 +921,13 @@ struct nbbuf_struct
 
 typedef struct nbbuf_struct nbbuf_T;
 
-static nbbuf_T *buf_list = 0;
+static nbbuf_T *buf_list = NULL;
 static int buf_list_size = 0;	/* size of buf_list */
 static int buf_list_used = 0;	/* nr of entries in buf_list actually in use */
 
-static char **globalsignmap;
-static int globalsignmaplen;
-static int globalsignmapused;
+static char **globalsignmap = NULL;
+static int globalsignmaplen = 0;
+static int globalsignmapused = 0;
 
 static int  mapsigntype __ARGS((nbbuf_T *, int localsigntype));
 static void addsigntype __ARGS((nbbuf_T *, int localsigntype, char_u *typeName,
@@ -896,6 +939,66 @@ static void print_save_msg __ARGS((nbbuf
 static int curPCtype = -1;
 
 /*
+ * Free netbeans resources.
+ */
+    static void
+nb_free()
+{
+    keyQ_T *key_node = keyHead.next;
+    queue_T *cmd_node = head.next;
+    nbbuf_T buf;
+    buf_T *bufp;
+    int i;
+
+    /* free the netbeans buffer list */
+    for (i = 0; i < buf_list_used; i++)
+    {
+	buf = buf_list[i];
+	vim_free(buf.displayname);
+	vim_free(buf.signmap);
+	if ((bufp=buf.bufp) != NULL)
+	{
+	    buf.bufp->b_netbeans_file = FALSE;
+	    buf.bufp->b_was_netbeans_file = FALSE;
+	}
+    }
+    vim_free(buf_list);
+    buf_list = NULL;
+    buf_list_size = 0;
+    buf_list_used = 0;
+
+    /* free the queued key commands */
+    while(key_node != NULL && key_node != &keyHead)
+    {
+	keyQ_T *next = key_node->next;
+	vim_free(key_node->keystr);
+	vim_free(key_node);
+	if (next == &keyHead)
+	{
+	    keyHead.next = &keyHead;
+	    keyHead.prev = &keyHead;
+	    break;
+	}
+	key_node = next;
+    }
+
+    /* free the queued netbeans commands */
+    while(cmd_node != NULL && cmd_node != &head)
+    {
+	queue_T *next = cmd_node->next;
+	vim_free(cmd_node->buffer);
+	vim_free(cmd_node);
+	if (next == &head)
+	{
+	    head.next = &head;
+	    head.prev = &head;
+	    break;
+	}
+	cmd_node = next;
+    }
+}
+
+/*
  * Get the Netbeans buffer number for the specified buffer.
  */
     static int
@@ -915,7 +1018,7 @@ nb_getbufno(buf_T *bufp)
     int
 isNetbeansBuffer(buf_T *bufp)
 {
-    return usingNetbeans && bufp->b_netbeans_file;
+    return NETBEANS_OPEN && bufp->b_netbeans_file;
 }
 
 /*
@@ -930,7 +1033,7 @@ isNetbeansBuffer(buf_T *bufp)
     int
 isNetbeansModified(buf_T *bufp)
 {
-    if (usingNetbeans && bufp->b_netbeans_file)
+    if (isNetbeansBuffer(bufp))
     {
 	int bufno = nb_getbufno(bufp);
 
@@ -1010,7 +1113,7 @@ netbeans_end(void)
     int i;
     static char buf[128];
 
-    if (!haveConnection)
+    if (!NETBEANS_OPEN)
 	return;
 
     for (i = 0; i < buf_list_used; i++)
@@ -1026,9 +1129,8 @@ netbeans_end(void)
 	}
 	sprintf(buf, "%d:killed=%d\n", i, r_cmdno);
 	nbdebug(("EVT: %s", buf));
-/*	nb_send(buf, "netbeans_end");    avoid "write failed" messages */
-	if (sd >= 0)
-	    ignored = sock_write(sd, buf, (int)STRLEN(buf));
+	/* nb_send(buf, "netbeans_end");    avoid "write failed" messages */
+	ignored = sock_write(nbsock, buf, (int)STRLEN(buf));
     }
 }
 
@@ -1042,7 +1144,7 @@ nb_send(char *buf, char *fun)
      * exited, only mention the first error until the connection works again. */
     static int did_error = FALSE;
 
-    if (sd < 0)
+    if (!NETBEANS_OPEN)
     {
 	if (!did_error)
 	{
@@ -1051,7 +1153,7 @@ nb_send(char *buf, char *fun)
 	}
 	did_error = TRUE;
     }
-    else if (sock_write(sd, buf, (int)STRLEN(buf)) != (int)STRLEN(buf))
+    else if (sock_write(nbsock, buf, (int)STRLEN(buf)) != (int)STRLEN(buf))
     {
 	if (!did_error)
 	{
@@ -1073,9 +1175,6 @@ nb_reply_nil(int cmdno)
 {
     char reply[32];
 
-    if (!haveConnection)
-	return;
-
     nbdebug(("REP %d: <none>\n", cmdno));
 
     sprintf(reply, "%d\n", cmdno);
@@ -1092,9 +1191,6 @@ nb_reply_text(int cmdno, char_u *result)
 {
     char_u *reply;
 
-    if (!haveConnection)
-	return;
-
     nbdebug(("REP %d: %s\n", cmdno, (char *)result));
 
     reply = alloc((unsigned)STRLEN(result) + 32);
@@ -1113,9 +1209,6 @@ nb_reply_nr(int cmdno, long result)
 {
     char reply[32];
 
-    if (!haveConnection)
-	return;
-
     nbdebug(("REP %d: %ld\n", cmdno, result));
 
     sprintf(reply, "%d %ld\n", cmdno, result);
@@ -1272,8 +1365,6 @@ nb_joinlines(linenr_T first, linenr_T ot
 
 #define SKIP_STOP 2
 #define streq(a,b) (strcmp(a,b) == 0)
-static int needupdate = 0;
-static int inAtomic = 0;
 
 /*
  * Do the actual processing of a single netbeans command or function.
@@ -2648,6 +2739,12 @@ special_keys(char_u *args)
     vim_free(save_str);
 }
 
+    void
+ex_nbclose(eap)
+    exarg_T	*eap UNUSED;
+{
+    netbeans_close();
+}
 
     void
 ex_nbkey(eap)
@@ -2656,6 +2753,12 @@ ex_nbkey(eap)
     (void)netbeans_keystring(eap->arg);
 }
 
+    void
+ex_nbstart(eap)
+    exarg_T	*eap;
+{
+    netbeans_open((char *)eap->arg, FALSE);
+}
 
 /*
  * Initialize highlights and signs for use by netbeans  (mostly obsolete)
@@ -2766,7 +2869,7 @@ netbeans_beval_cb(
 
     /* Don't do anything when 'ballooneval' is off, messages scrolled the
      * windows up or we have no connection. */
-    if (!p_beval || msg_scrolled > 0 || !haveConnection)
+    if (!p_beval || msg_scrolled > 0 || !NETBEANS_OPEN)
 	return;
 
     if (get_beval_info(beval, TRUE, &wp, &lnum, &text, &col) == OK)
@@ -2791,12 +2894,21 @@ netbeans_beval_cb(
 #endif
 
 /*
+ * Return TRUE when the netbeans connection is closed.
+ */
+    int
+netbeans_active(void)
+{
+    return NETBEANS_OPEN;
+}
+
+/*
  * Return netbeans file descriptor.
  */
     int
-netbeans_filedesc (void)
+netbeans_filedesc(void)
 {
-    return sd;
+    return nbsock;
 }
 
 #if defined(FEAT_GUI) || defined(PROTO)
@@ -2806,41 +2918,38 @@ netbeans_filedesc (void)
     void
 netbeans_gui_register(void)
 {
-    if (!NB_HAS_GUI)
+    if (!NB_HAS_GUI || !NETBEANS_OPEN)
 	return;
 
-    if (sd > 0)
-    {
 # ifdef FEAT_GUI_MOTIF
-	/* tell notifier we are interested in being called
-	 * when there is input on the editor connection socket
-	 */
-	if (inputHandler == (XtInputId)NULL)
-	    inputHandler = XtAppAddInput((XtAppContext)app_context, sd,
-			     (XtPointer)(XtInputReadMask + XtInputExceptMask),
-						   messageFromNetbeans, NULL);
+    /* tell notifier we are interested in being called
+     * when there is input on the editor connection socket
+     */
+    if (inputHandler == (XtInputId)NULL)
+	inputHandler = XtAppAddInput((XtAppContext)app_context, nbsock,
+			 (XtPointer)(XtInputReadMask + XtInputExceptMask),
+					       messageFromNetbeans, NULL);
 # else
 #  ifdef FEAT_GUI_GTK
-	/*
-	 * Tell gdk we are interested in being called when there
-	 * is input on the editor connection socket
-	 */
-	if (inputHandler == 0)
-	    inputHandler = gdk_input_add((gint)sd, (GdkInputCondition)
-		((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION),
-						   messageFromNetbeans, NULL);
+    /*
+     * Tell gdk we are interested in being called when there
+     * is input on the editor connection socket
+     */
+    if (inputHandler == 0)
+	inputHandler = gdk_input_add((gint)nbsock, (GdkInputCondition)
+	    ((int)GDK_INPUT_READ + (int)GDK_INPUT_EXCEPTION),
+					       messageFromNetbeans, NULL);
 #  else
 #   ifdef FEAT_GUI_W32
-	/*
-	 * Tell Windows we are interested in receiving message when there
-	 * is input on the editor connection socket
-	 */
-	if (inputHandler == -1)
-	    inputHandler = WSAAsyncSelect(sd, s_hwnd, WM_NETBEANS, FD_READ);
+    /*
+     * Tell Windows we are interested in receiving message when there
+     * is input on the editor connection socket
+     */
+    if (inputHandler == -1)
+	inputHandler = WSAAsyncSelect(nbsock, s_hwnd, WM_NETBEANS, FD_READ);
 #   endif
 #  endif
 # endif
-    }
 
 # ifdef FEAT_BEVAL
     bevalServers |= BEVAL_NETBEANS;
@@ -2852,15 +2961,17 @@ netbeans_gui_register(void)
  * Tell netbeans that the window was opened, ready for commands.
  */
     void
-netbeans_startup_done(void)
+netbeans_open(char *params, int abort)
 {
     char *cmd = "0:startupDone=0\n";
 
-    if (!usingNetbeans)
+    if (NETBEANS_OPEN)
+    {
+	EMSG(_("E511: netbeans already connected"));
 	return;
-
-    netbeans_connect();
-    if (!haveConnection)
+    }
+
+    if (netbeans_connect(params, abort) != OK)
 	return;
 #ifdef FEAT_GUI
     netbeans_gui_register();
@@ -2868,6 +2979,16 @@ netbeans_startup_done(void)
 
     nbdebug(("EVT: %s", cmd));
     nb_send(cmd, "netbeans_startup_done");
+
+    /* update the screen after having added the gutter */
+    changed_window_setting();
+    update_screen(CLEAR);
+    setcursor();
+    out_flush();
+#ifdef FEAT_GUI
+    gui_update_cursor(TRUE, FALSE);
+    gui_mch_flush();
+#endif
 }
 
 /*
@@ -2879,7 +3000,7 @@ netbeans_send_disconnect()
 {
     char buf[128];
 
-    if (haveConnection)
+    if (NETBEANS_OPEN)
     {
 	sprintf(buf, "0:disconnect=%d\n", r_cmdno);
 	nbdebug(("EVT: %s", buf));
@@ -2896,7 +3017,7 @@ netbeans_frame_moved(int new_x, int new_
 {
     char buf[128];
 
-    if (!haveConnection)
+    if (!NETBEANS_OPEN)
 	return;
 
     sprintf(buf, "0:geometry=%d %d %d %d %d\n",
@@ -2917,7 +3038,7 @@ netbeans_file_activated(buf_T *bufp)
     char    buffer[2*MAXPATHL];
     char_u  *q;
 
-    if (!haveConnection || dosetvisible)
+    if (!NETBEANS_OPEN || !bufp->b_netbeans_file || dosetvisible)
 	return;
 
     q = nb_quote(bufp->b_ffname);
@@ -2949,7 +3070,7 @@ netbeans_file_opened(buf_T *bufp)
     nbbuf_T *bp = nb_get_buf(nb_getbufno(bufp));
     int	    bnum;
 
-    if (!haveConnection)
+    if (!NETBEANS_OPEN)
 	return;
 
     q = nb_quote(bufp->b_ffname);
@@ -2985,7 +3106,7 @@ netbeans_file_killed(buf_T *bufp)
     nbbuf_T	*nbbuf = nb_get_buf(bufno);
     char	buffer[2*MAXPATHL];
 
-    if (!haveConnection || bufno == -1)
+    if (!NETBEANS_OPEN || bufno == -1)
 	return;
 
     nbdebug(("netbeans_file_killed:\n"));
@@ -3012,7 +3133,7 @@ nb_bufp2nbbuf_fire(buf_T *bufp, int *buf
     int		bufno;
     nbbuf_T	*nbbuf;
 
-    if (!haveConnection || !netbeansFireChanges)
+    if (!NETBEANS_OPEN || !netbeansFireChanges)
 	return NULL;		/* changes are not reported at all */
 
     bufno = nb_getbufno(bufp);
@@ -3046,6 +3167,9 @@ netbeans_inserted(
     char_u	*p;
     char_u	*newtxt;
 
+    if (!NETBEANS_OPEN)
+	return;
+
     nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
     if (nbbuf == NULL)
 	return;
@@ -3091,6 +3215,9 @@ netbeans_removed(
     pos_T	pos;
     long	off;
 
+    if (!NETBEANS_OPEN)
+	return;
+
     nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
     if (nbbuf == NULL)
 	return;
@@ -3119,6 +3246,9 @@ netbeans_removed(
     void
 netbeans_unmodified(buf_T *bufp UNUSED)
 {
+    if (!NETBEANS_OPEN)
+	return;
+
 #if 0
     char_u	buf[128];
     int		bufno;
@@ -3148,6 +3278,9 @@ netbeans_button_release(int button)
     char	buf[128];
     int		bufno;
 
+    if (!NETBEANS_OPEN)
+	return;
+
     bufno = nb_getbufno(curbuf);
 
     if (bufno >= 0 && curwin != NULL && curwin->w_buffer == curbuf)
@@ -3199,10 +3332,9 @@ netbeans_keystring(char_u *keyName)
     long	off;
     char_u	*q;
 
-    if (!haveConnection)
+    if (!NETBEANS_OPEN)
 	return TRUE;
 
-
     if (bufno == -1)
     {
 	nbdebug(("got keycommand for non-NetBeans buffer, opening...\n"));
@@ -3260,6 +3392,9 @@ netbeans_save_buffer(buf_T *bufp)
     int		bufno;
     nbbuf_T	*nbbuf;
 
+    if (!NETBEANS_OPEN)
+	return;
+
     nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
     if (nbbuf == NULL)
 	return;
@@ -3282,6 +3417,9 @@ netbeans_deleted_all_lines(buf_T *bufp)
     int		bufno;
     nbbuf_T	*nbbuf;
 
+    if (!NETBEANS_OPEN)
+	return;
+
     nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno);
     if (nbbuf == NULL)
 	return;
@@ -3307,6 +3445,9 @@ netbeans_is_guarded(linenr_T top, linenr
     signlist_T	*p;
     int		lnum;
 
+    if (!NETBEANS_OPEN)
+	return FALSE;
+
     for (p = curbuf->b_signlist; p != NULL; p = p->next)
 	if (p->id >= GUARDEDOFFSET)
 	    for (lnum = top + 1; lnum < bot; lnum++)
@@ -3328,6 +3469,9 @@ netbeans_draw_multisign_indicator(int ro
     int y;
     int x;
 
+    if (!NETBEANS_OPEN)
+	return;
+
     x = 0;
     y = row * gui.char_height + 2;
 
@@ -3357,6 +3501,9 @@ netbeans_draw_multisign_indicator(int ro
     int x;
     GdkDrawable *drawable = gui.drawarea->window;
 
+    if (!NETBEANS_OPEN)
+	return;
+
     x = 0;
     y = row * gui.char_height + 2;
 
@@ -3382,6 +3529,9 @@ netbeans_gutter_click(linenr_T lnum)
 {
     signlist_T	*p;
 
+    if (!NETBEANS_OPEN)
+	return;
+
     for (p = curbuf->b_signlist; p != NULL; p = p->next)
     {
 	if (p->lnum == lnum && p->next && p->next->lnum == lnum)
--- a/src/normal.c
+++ b/src/normal.c
@@ -2730,7 +2730,7 @@ do_mouse(oap, c, dir, count, fixindent)
 #endif
 
 #ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans && isNetbeansBuffer(curbuf)
+    if (isNetbeansBuffer(curbuf)
 			    && !(jump_flags & (IN_STATUS_LINE | IN_SEP_LINE)))
     {
 	int key = KEY2TERMCAP1(c);
@@ -6914,12 +6914,12 @@ nv_replace(cap)
 		++curwin->w_cursor.col;
 	    }
 #ifdef FEAT_NETBEANS_INTG
-	    if (usingNetbeans)
+	    if (netbeans_active())
 	    {
-		colnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1);
+		colnr_T  start = (colnr_T)(curwin->w_cursor.col - cap->count1);
 
 		netbeans_removed(curbuf, curwin->w_cursor.lnum, start,
-							    (long)cap->count1);
+							   (long)cap->count1);
 		netbeans_inserted(curbuf, curwin->w_cursor.lnum, start,
 					       &ptr[start], (int)cap->count1);
 	    }
@@ -7110,7 +7110,7 @@ n_swapchar(cap)
 		    && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
 	    {
 #ifdef FEAT_NETBEANS_INTG
-		if (usingNetbeans)
+		if (netbeans_active())
 		{
 		    if (did_change)
 		    {
@@ -7139,7 +7139,7 @@ n_swapchar(cap)
 	}
     }
 #ifdef FEAT_NETBEANS_INTG
-    if (did_change && usingNetbeans)
+    if (did_change && netbeans_active())
     {
 	ptr = ml_get(pos.lnum);
 	count = curwin->w_cursor.col - pos.col;
--- a/src/ops.c
+++ b/src/ops.c
@@ -2249,14 +2249,14 @@ op_tilde(oap)
 	    did_change |= one_change;
 
 # ifdef FEAT_NETBEANS_INTG
-	    if (usingNetbeans && one_change)
+	    if (netbeans_active() && one_change)
 	    {
 		char_u *ptr = ml_get_buf(curbuf, pos.lnum, FALSE);
 
 		netbeans_removed(curbuf, pos.lnum, bd.textcol,
 							    (long)bd.textlen);
 		netbeans_inserted(curbuf, pos.lnum, bd.textcol,
-				    &ptr[bd.textcol], bd.textlen);
+						&ptr[bd.textcol], bd.textlen);
 	    }
 # endif
 	}
@@ -2294,7 +2294,7 @@ op_tilde(oap)
 	    changed_lines(oap->start.lnum, oap->start.col, oap->end.lnum + 1,
 									  0L);
 #ifdef FEAT_NETBEANS_INTG
-	    if (usingNetbeans && did_change)
+	    if (netbeans_active() && did_change)
 	    {
 		char_u *ptr;
 		int count;
@@ -2306,7 +2306,7 @@ op_tilde(oap)
 		    count = (int)STRLEN(ptr) - pos.col;
 		    netbeans_removed(curbuf, pos.lnum, pos.col, (long)count);
 		    netbeans_inserted(curbuf, pos.lnum, pos.col,
-						 &ptr[pos.col], count);
+							&ptr[pos.col], count);
 		    pos.col = 0;
 		    pos.lnum++;
 		}
@@ -2314,7 +2314,7 @@ op_tilde(oap)
 		count = oap->end.col - pos.col + 1;
 		netbeans_removed(curbuf, pos.lnum, pos.col, (long)count);
 		netbeans_inserted(curbuf, pos.lnum, pos.col,
-						 &ptr[pos.col], count);
+							&ptr[pos.col], count);
 	    }
 #endif
 	}
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -368,8 +368,7 @@ mch_inchar(buf, maxlen, wtime, tb_change
 
 #ifdef FEAT_NETBEANS_INTG
     /* Process the queued netbeans messages. */
-    if (usingNetbeans)
-	netbeans_parse_messages();
+    netbeans_parse_messages();
 #endif
 
     /* Check if window changed size while we were busy, perhaps the ":set
@@ -386,8 +385,7 @@ mch_inchar(buf, maxlen, wtime, tb_change
 	    handle_resize();
 #ifdef FEAT_NETBEANS_INTG
 	    /* Process the queued netbeans messages. */
-	    if (usingNetbeans)
-		netbeans_parse_messages();
+            netbeans_parse_messages();
 #endif
 	}
     }
@@ -421,8 +419,7 @@ mch_inchar(buf, maxlen, wtime, tb_change
 
 #ifdef FEAT_NETBEANS_INTG
 	/* Process the queued netbeans messages. */
-	if (usingNetbeans)
-	    netbeans_parse_messages();
+        netbeans_parse_messages();
 #endif
 	/*
 	 * we want to be interrupted by the winch signal
@@ -3108,8 +3105,7 @@ mch_exit(r)
 #endif
 
 #ifdef FEAT_NETBEANS_INTG
-    if (usingNetbeans)
-	netbeans_send_disconnect();
+    netbeans_send_disconnect();
 #endif
 
 #ifdef EXITFREE
@@ -4788,7 +4784,7 @@ RealWaitForChar(fd, msec, check_for_gpm)
 {
     int		ret;
 #ifdef FEAT_NETBEANS_INTG
-    int		nb_fd = (usingNetbeans ? netbeans_filedesc() : -1);
+    int		nb_fd = netbeans_filedesc();
 #endif
 #if defined(FEAT_XCLIPBOARD) || defined(USE_XSMP) || defined(FEAT_MZSCHEME)
     static int	busy = FALSE;
--- a/src/proto/gui_w32.pro
+++ b/src/proto/gui_w32.pro
@@ -93,4 +93,5 @@ void gui_mch_post_balloon __ARGS((Balloo
 BalloonEval *gui_mch_create_beval_area __ARGS((void *target, char_u *mesg, void (*mesgCB)(BalloonEval *, int), void *clientData));
 void gui_mch_destroy_beval_area __ARGS((BalloonEval *beval));
 void netbeans_draw_multisign_indicator __ARGS((int row));
+void netbeans_init_winsock __ARGS((void));
 /* vim: set ft=c : */
--- a/src/proto/netbeans.pro
+++ b/src/proto/netbeans.pro
@@ -4,11 +4,14 @@ void netbeans_read __ARGS((void));
 int isNetbeansBuffer __ARGS((buf_T *bufp));
 int isNetbeansModified __ARGS((buf_T *bufp));
 void netbeans_end __ARGS((void));
+void ex_nbclose __ARGS((exarg_T *eap));
 void ex_nbkey __ARGS((exarg_T *eap));
+void ex_nbstart __ARGS((exarg_T *eap));
 void netbeans_beval_cb __ARGS((BalloonEval *beval, int state));
+int netbeans_active __ARGS((void));
 int netbeans_filedesc __ARGS((void));
 void netbeans_gui_register __ARGS((void));
-void netbeans_startup_done __ARGS((void));
+void netbeans_open __ARGS((char *params, int abort));
 void netbeans_send_disconnect __ARGS((void));
 void netbeans_frame_moved __ARGS((int new_x, int new_y));
 void netbeans_file_activated __ARGS((buf_T *bufp));
--- a/src/screen.c
+++ b/src/screen.c
@@ -1981,7 +1981,7 @@ draw_signcolumn(wp)
 {
     return (wp->w_buffer->b_signlist != NULL
 # ifdef FEAT_NETBEANS_INTG
-			    || usingNetbeans
+			    || netbeans_active()
 # endif
 		    );
 }
--- a/src/ui.c
+++ b/src/ui.c
@@ -2935,8 +2935,7 @@ mouse_comp_pos(win, rowp, colp, lnump)
     if (col < 0)
     {
 #ifdef FEAT_NETBEANS_INTG
-	if (usingNetbeans)
-	    netbeans_gutter_click(lnum);
+        netbeans_gutter_click(lnum);
 #endif
 	col = 0;
     }
--- a/src/undo.c
+++ b/src/undo.c
@@ -346,7 +346,7 @@ u_savecommon(top, bot, newbot)
      * Netbeans defines areas that cannot be modified.  Bail out here when
      * trying to change text in a guarded area.
      */
-    if (usingNetbeans)
+    if (netbeans_active())
     {
 	if (netbeans_is_guarded(top, bot))
 	{