Index: emacs/lib-src/emacsclient.c =================================================================== RCS file: /cvsroot/emacs/emacs/lib-src/emacsclient.c,v retrieving revision 1.93 diff -c -r1.93 emacsclient.c *** emacs/lib-src/emacsclient.c 23 Nov 2006 01:50:59 -0000 1.93 --- emacs/lib-src/emacsclient.c 24 Nov 2006 07:05:18 -0000 *************** *** 86,91 **** --- 86,92 ---- #define SEND_STRING(data) (send_to_emacs (s, (data))) #define SEND_QUOTED(data) (quote_file_name (s, (data))) + #define SEND_FILENM(cwd, filen) (send_file_name (s, (cwd), (filen))) #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 *************** *** 129,134 **** --- 130,139 ---- /* If non-NULL, the filename of the authentication file. */ char *server_file = NULL; + /* If non-NULL, the Tramp prefix to access the local file from a + remote Emacs */ + char *tramp_prefix = NULL; + void print_help_and_exit () NO_RETURN; struct option longopts[] = *************** *** 142,147 **** --- 147,153 ---- { "socket-name", required_argument, NULL, 's' }, #endif { "server-file", required_argument, NULL, 'f' }, + { "tramp-prefix", required_argument, NULL, 'p' }, { "display", required_argument, NULL, 'd' }, { 0, 0, 0, 0 } }; *************** *** 210,220 **** { int opt = getopt_long (argc, argv, #ifndef NO_SOCKETS_IN_FILE_SYSTEM ! "VHnea:s:f:d:", #else ! "VHnea:f:d:", #endif ! longopts, 0); if (opt == EOF) break; --- 216,226 ---- { int opt = getopt_long (argc, argv, #ifndef NO_SOCKETS_IN_FILE_SYSTEM ! "VHnea:s:f:p:d:", #else ! "VHnea:f:p:d:", #endif ! longopts, 0); if (opt == EOF) break; *************** *** 240,245 **** --- 246,255 ---- server_file = optarg; break; + case 'p': + tramp_prefix = optarg; + break; + case 'd': display = optarg; break; *************** *** 290,295 **** --- 300,307 ---- #endif "-f, --server-file=FILENAME\n\ Set filename of the TCP authentication file\n\ + -p, --tramp-prefix=PREFIX\n\ + Tramp prefix to address local files by a remote Emacs\n \ -a, --alternate-editor=EDITOR\n\ Editor to fallback to if server is not running\n\ \n\ *************** *** 462,467 **** --- 474,501 ---- return FALSE; } + void + send_file_name (s, cwd, filename) + HSOCKET s; + const unsigned char *cwd; + const unsigned char *filename; + { + if (! filename || filename[0] == 0) return; + + /* Send tramp prefix */ + SEND_QUOTED (tramp_prefix); + + /* Make the filename absolute if it isn't already */ + if (! file_name_absolute_p (filename)) + { + SEND_QUOTED (cwd); + SEND_STRING ("/"); + } + + /* Send the filename */ + SEND_QUOTED (filename); + } + #ifdef WINDOWSNT /* Wrapper to make WSACleanup a cdecl, as required by atexit(). */ void *************** *** 858,863 **** --- 892,900 ---- if ((s = set_socket ()) == INVALID_SOCKET) fail (argc, argv); + if (! tramp_prefix) + tramp_prefix = getenv ("EMACS_TRAMP_PREFIX"); + #ifdef HAVE_GETCWD cwd = getcwd (string, sizeof string); #else *************** *** 893,916 **** for (i = optind; i < argc; i++) { if (eval) ! ; /* Don't prepend any cwd or anything like that. */ else if (*argv[i] == '+') { char *p = argv[i] + 1; while (isdigit ((unsigned char) *p) || *p == ':') p++; ! if (*p != 0) ! { ! SEND_QUOTED (cwd); ! SEND_STRING ("/"); ! } ! } ! else if (! file_name_absolute_p (argv[i])) ! { ! SEND_QUOTED (cwd); ! SEND_STRING ("/"); } - SEND_QUOTED (argv[i]); SEND_STRING (" "); } } --- 930,949 ---- for (i = optind; i < argc; i++) { if (eval) ! { ! /* Don't prepend any cwd or anything like that. */ ! SEND_QUOTED (argv[i]); ! } else if (*argv[i] == '+') { char *p = argv[i] + 1; while (isdigit ((unsigned char) *p) || *p == ':') p++; ! ! SEND_FILENM (cwd, p); } + else + SEND_FILENM (cwd, argv[i]); SEND_STRING (" "); } }