Index: src/netbeans.c
===================================================================
--- src/netbeans.c	(revision 1011)
+++ src/netbeans.c	(working copy)
@@ -749,8 +749,11 @@
 	return; /* don't try to parse it */
     }
 
-    /* Parse the messages, but avoid recursion. */
-    if (level == 1)
+    /* Parse the messages, but avoid recursion
+     * and do not process messages when the use
+     * of vim functions is restricted within callbacks.
+     */
+    if (level == 1 && ! callback_restricted)
 	nb_parse_messages();
 
     --level;
Index: src/main.c
===================================================================
--- src/main.c	(revision 1011)
+++ src/main.c	(working copy)
@@ -1178,7 +1178,19 @@
 	    do_exmode(exmode_active == EXMODE_VIM);
 	}
 	else
+	{
+#ifdef FEAT_NETBEANS_INTG
+	    /* Allow full use of vim functions in callbacks,
+	     * but not within the command-line window or in
+	     * ":global/path/visual" commands.*/
+	    if (!cmdwin && !noexmode)
+		callback_restricted = FALSE;
+#endif
 	    normal_cmd(&oa, TRUE);
+#ifdef FEAT_NETBEANS_INTG
+	    callback_restricted = TRUE;
+#endif
+	}
     }
 }
 
Index: src/globals.h
===================================================================
--- src/globals.h	(revision 1011)
+++ src/globals.h	(working copy)
@@ -1008,6 +1008,11 @@
 					    /* set after swap write error msg */
 EXTERN int	undo_off INIT(= FALSE);	    /* undo switched off for now */
 EXTERN int	global_busy INIT(= 0);	    /* set when :global is executing */
+#ifdef FEAT_NETBEANS_INTG
+EXTERN int	callback_restricted INIT(= TRUE);/* callbacks have a restricted
+                                                  * use of vim functions when
+						  * this flag is set */
+#endif
 EXTERN int	listcmd_busy INIT(= FALSE); /* set when :argdo, :windo or
 					       :bufdo is executing */
 EXTERN int	need_start_insertmode INIT(= FALSE);
