To: vim-dev@vim.org Subject: Patch 6.0.165 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.165 Problem: Using --remote and executing locally gives unavoidable error messages. Solution: Add --remote-silent and --remote-wait-silent to silently execute locally. For Win32 there was no error message when a server didn't exist. Files: src/eval.c, src/if_xcmdsrv.c, src/main.c, src/os_mswin.c, src/proto/if_xcmdsrv.pro, src/proto/os_mswin.pro *** ../vim60.164/src/eval.c Wed Jan 9 16:29:27 2002 --- src/eval.c Sun Feb 3 16:19:57 2002 *************** *** 5662,5673 **** server_name = get_var_string(&argvars[0]); keys = get_var_string_buf(&argvars[1], buf); # ifdef WIN32 ! if (serverSendToVim(server_name, keys, &r, &w, expr) < 0) # else ! if (serverSendToVim(X_DISPLAY, server_name, keys, &r, &w, expr, 0) < 0) # endif { ! EMSG2(_("E241: Unable to send to %s"), server_name); return; } --- 5662,5677 ---- server_name = get_var_string(&argvars[0]); keys = get_var_string_buf(&argvars[1], buf); # ifdef WIN32 ! if (serverSendToVim(server_name, keys, &r, &w, expr, TRUE) < 0) # else ! if (serverSendToVim(X_DISPLAY, server_name, keys, &r, &w, expr, 0, TRUE) ! < 0) # endif { ! if (r != NULL) ! EMSG(r); /* sending worked but evaluation failed */ ! else ! EMSG2(_("E241: Unable to send to %s"), server_name); return; } *** ../vim60.164/src/if_xcmdsrv.c Sun Feb 3 12:42:13 2002 --- src/if_xcmdsrv.c Sun Feb 3 16:13:20 2002 *************** *** 348,354 **** * Returns 0 for OK, negative for an error. */ int ! serverSendToVim(dpy, name, cmd, result, server, asExpr, localLoop) Display *dpy; /* Where to send. */ char_u *name; /* Where to send. */ char_u *cmd; /* What to send. */ --- 348,354 ---- * Returns 0 for OK, negative for an error. */ int ! serverSendToVim(dpy, name, cmd, result, server, asExpr, localLoop, silent) Display *dpy; /* Where to send. */ char_u *name; /* Where to send. */ char_u *cmd; /* What to send. */ *************** *** 356,361 **** --- 356,362 ---- Window *server; /* Actual ID of receiving app */ Bool asExpr; /* Interpret as keystrokes or expr ? */ Bool localLoop; /* Throw away everything but result */ + int silent; /* don't complain about no server */ { Window w; char_u *property; *************** *** 429,435 **** } if (w == None) { ! EMSG2(_("E247: no registered server named \"%s\""), name); return -1; } else if (loosename != NULL) --- 430,437 ---- } if (w == None) { ! if (!silent) ! EMSG2(_("E247: no registered server named \"%s\""), name); return -1; } else if (loosename != NULL) *** ../vim60.164/src/main.c Sun Feb 3 12:42:13 2002 --- src/main.c Sun Feb 3 16:20:19 2002 *************** *** 264,272 **** else if (STRICMP(argv[i], "--serverlist") == 0 || STRICMP(argv[i], "--remote-send") == 0 || STRICMP(argv[i], "--remote-expr") == 0 ! || STRICMP(argv[i], "--remote") == 0 ) serverArg = TRUE; ! else if (STRICMP(argv[i], "--remote-wait") == 0) { serverArg = TRUE; #ifdef FEAT_GUI --- 264,274 ---- else if (STRICMP(argv[i], "--serverlist") == 0 || STRICMP(argv[i], "--remote-send") == 0 || STRICMP(argv[i], "--remote-expr") == 0 ! || STRICMP(argv[i], "--remote") == 0 ! || STRICMP(argv[i], "--remote-silent") == 0) serverArg = TRUE; ! else if (STRICMP(argv[i], "--remote-wait") == 0 ! || STRICMP(argv[i], "--remote-wait-silent") == 0) { serverArg = TRUE; #ifdef FEAT_GUI *************** *** 2514,2519 **** --- 2516,2522 ---- #define ARGTYPE_EDIT 1 #define ARGTYPE_EDIT_WAIT 2 #define ARGTYPE_SEND 3 + int silent = FALSE; # ifndef FEAT_X11 HWND srv; # else *************** *** 2549,2556 **** --- 2552,2569 ---- if (STRICMP(argv[i], "--remote") == 0) argtype = ARGTYPE_EDIT; + else if (STRICMP(argv[i], "--remote-silent") == 0) + { + argtype = ARGTYPE_EDIT; + silent = TRUE; + } else if (STRICMP(argv[i], "--remote-wait") == 0) argtype = ARGTYPE_EDIT_WAIT; + else if (STRICMP(argv[i], "--remote-wait-silent") == 0) + { + argtype = ARGTYPE_EDIT_WAIT; + silent = TRUE; + } else if (STRICMP(argv[i], "--remote-send") == 0) argtype = ARGTYPE_SEND; else *************** *** 2572,2580 **** } # ifdef FEAT_X11 ret = serverSendToVim(xterm_dpy, sname, *serverStr, ! NULL, &srv, 0, 0); # else ! ret = serverSendToVim(sname, *serverStr, NULL, &srv, 0); # endif if (ret < 0) { --- 2585,2593 ---- } # ifdef FEAT_X11 ret = serverSendToVim(xterm_dpy, sname, *serverStr, ! NULL, &srv, 0, 0, silent); # else ! ret = serverSendToVim(sname, *serverStr, NULL, &srv, 0, silent); # endif if (ret < 0) { *************** *** 2584,2590 **** mch_errmsg(_("\nSend failed.\n")); didone = TRUE; } ! else /* Let vim start normally. */ mch_errmsg(_("\nSend failed. Trying to execute locally\n")); break; --- 2597,2603 ---- mch_errmsg(_("\nSend failed.\n")); didone = TRUE; } ! else if (!silent) /* Let vim start normally. */ mch_errmsg(_("\nSend failed. Trying to execute locally\n")); break; *************** *** 2658,2667 **** mainerr_arg_missing((char_u *)argv[i]); # ifdef WIN32 if (serverSendToVim(sname, (char_u *)argv[i + 1], ! &res, NULL, 1) < 0) # else if (serverSendToVim(xterm_dpy, sname, (char_u *)argv[i + 1], ! &res, NULL, 1, 1) < 0) # endif mch_errmsg(_("Send expression failed.\n")); } --- 2671,2680 ---- mainerr_arg_missing((char_u *)argv[i]); # ifdef WIN32 if (serverSendToVim(sname, (char_u *)argv[i + 1], ! &res, NULL, 1, FALSE) < 0) # else if (serverSendToVim(xterm_dpy, sname, (char_u *)argv[i + 1], ! &res, NULL, 1, 1, FALSE) < 0) # endif mch_errmsg(_("Send expression failed.\n")); } *** ../vim60.164/src/os_mswin.c Sun Feb 3 12:42:13 2002 --- src/os_mswin.c Sun Feb 3 16:18:50 2002 *************** *** 2072,2088 **** } int ! serverSendToVim(name, cmd, result, ptarget, asExpr) char_u *name; /* Where to send. */ char_u *cmd; /* What to send. */ char_u **result; /* Result of eval'ed expression */ void *ptarget; /* HWND of server */ int asExpr; /* Expression or keys? */ { HWND target = findServer(name); COPYDATASTRUCT data; char_u *retval = NULL; int retcode = 0; if (ptarget) *(HWND *)ptarget = target; --- 2072,2096 ---- } int ! serverSendToVim(name, cmd, result, ptarget, asExpr, silent) char_u *name; /* Where to send. */ char_u *cmd; /* What to send. */ char_u **result; /* Result of eval'ed expression */ void *ptarget; /* HWND of server */ int asExpr; /* Expression or keys? */ + int silent; /* don't complain about no server */ { HWND target = findServer(name); COPYDATASTRUCT data; char_u *retval = NULL; int retcode = 0; + + if (target == 0) + { + if (!silent) + EMSG2(_("E247: no registered server named \"%s\""), name); + return -1; + } if (ptarget) *(HWND *)ptarget = target; *** ../vim60.164/src/proto/if_xcmdsrv.pro Tue Sep 25 21:49:16 2001 --- src/proto/if_xcmdsrv.pro Sun Feb 3 16:21:38 2002 *************** *** 1,7 **** /* if_xcmdsrv.c */ int serverRegisterName __ARGS((Display *dpy, char_u *name)); void serverChangeRegisteredWindow __ARGS((Display *dpy, Window newwin)); ! int serverSendToVim __ARGS((Display *dpy, char_u *name, char_u *cmd, char_u **result, Window *server, int asExpr, int localLoop)); char_u *serverGetVimNames __ARGS((Display *dpy)); Window serverStrToWin __ARGS((char_u *str)); int serverSendReply __ARGS((char_u *name, char_u *str)); --- 1,7 ---- /* if_xcmdsrv.c */ int serverRegisterName __ARGS((Display *dpy, char_u *name)); void serverChangeRegisteredWindow __ARGS((Display *dpy, Window newwin)); ! int serverSendToVim __ARGS((Display *dpy, char_u *name, char_u *cmd, char_u **result, Window *server, int asExpr, int localLoop, int silent)); char_u *serverGetVimNames __ARGS((Display *dpy)); Window serverStrToWin __ARGS((char_u *str)); int serverSendReply __ARGS((char_u *name, char_u *str)); *** ../vim60.164/src/proto/os_mswin.pro Sun Feb 3 12:42:13 2002 --- src/proto/os_mswin.pro Sun Feb 3 16:21:43 2002 *************** *** 45,51 **** void serverSetName __ARGS((char_u *name)); char_u *serverGetVimNames __ARGS((void)); int serverSendReply __ARGS((char_u *name, char_u *reply)); ! int serverSendToVim __ARGS((char_u *name, char_u *cmd, char_u **result, void *ptarget, int asExpr)); void serverForeground __ARGS((char_u *name)); char_u *serverGetReply __ARGS((HWND server, int *expr_res, int remove, int wait)); void serverProcessPendingMessages __ARGS((void)); --- 45,51 ---- void serverSetName __ARGS((char_u *name)); char_u *serverGetVimNames __ARGS((void)); int serverSendReply __ARGS((char_u *name, char_u *reply)); ! int serverSendToVim __ARGS((char_u *name, char_u *cmd, char_u **result, void *ptarget, int asExpr, int silent)); void serverForeground __ARGS((char_u *name)); char_u *serverGetReply __ARGS((HWND server, int *expr_res, int remove, int wait)); void serverProcessPendingMessages __ARGS((void)); *** ../vim60.164/src/version.c Sun Feb 3 15:45:39 2002 --- src/version.c Sun Feb 3 16:25:52 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 165, /**/ -- "Hit any key to continue" it said, but nothing happened after F sharp. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///