aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorEli Zaretskii2017-05-19 11:51:16 +0300
committerEli Zaretskii2017-05-19 11:51:16 +0300
commit7430617d3d84dc111e1a28f4f3884bf827d4fec9 (patch)
tree94d971a5e3865716b282e84e8b7f4e782cccd38b /lib-src
parentbb5c6614eb171eef8c08474e0f949fe18ef4b230 (diff)
downloademacs-7430617d3d84dc111e1a28f4f3884bf827d4fec9.tar.gz
emacs-7430617d3d84dc111e1a28f4f3884bf827d4fec9.zip
Support remote editing in emacsclient via Tramp
* lib-src/emacsclient.c (main, decode_options) (print_help_and_exit, longopts): New option '--tramp' / '-T' which specifies how emacs should use tramp to find remote files. * doc/emacs/misc.texi (TCP Emacs server): New subsection describing the various knobs to tune server.el for TCP opereation. (emacsclient Options): Reference "TCP Emacs server" from description of --server-file. Document the new '--tramp' / '-T' options. * doc/emacs/emacs.texi (Top): Update the top-level menu. * etc/NEWS: Mention the new option.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsclient.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 7b735dfb05d..c21ee6bd395 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -149,6 +149,9 @@ const char *socket_name = NULL;
149/* If non-NULL, the filename of the authentication file. */ 149/* If non-NULL, the filename of the authentication file. */
150const char *server_file = NULL; 150const char *server_file = NULL;
151 151
152/* If non-NULL, the tramp prefix emacs must use to find the files. */
153const char *tramp_prefix = NULL;
154
152/* PID of the Emacs server process. */ 155/* PID of the Emacs server process. */
153int emacs_pid = 0; 156int emacs_pid = 0;
154 157
@@ -178,6 +181,7 @@ struct option longopts[] =
178 { "server-file", required_argument, NULL, 'f' }, 181 { "server-file", required_argument, NULL, 'f' },
179 { "display", required_argument, NULL, 'd' }, 182 { "display", required_argument, NULL, 'd' },
180 { "parent-id", required_argument, NULL, 'p' }, 183 { "parent-id", required_argument, NULL, 'p' },
184 { "tramp", required_argument, NULL, 'T' },
181 { 0, 0, 0, 0 } 185 { 0, 0, 0, 0 }
182}; 186};
183 187
@@ -468,14 +472,15 @@ static void
468decode_options (int argc, char **argv) 472decode_options (int argc, char **argv)
469{ 473{
470 alternate_editor = egetenv ("ALTERNATE_EDITOR"); 474 alternate_editor = egetenv ("ALTERNATE_EDITOR");
475 tramp_prefix = egetenv ("EMACSCLIENT_TRAMP");
471 476
472 while (1) 477 while (1)
473 { 478 {
474 int opt = getopt_long_only (argc, argv, 479 int opt = getopt_long_only (argc, argv,
475#ifndef NO_SOCKETS_IN_FILE_SYSTEM 480#ifndef NO_SOCKETS_IN_FILE_SYSTEM
476 "VHnequa:s:f:d:F:tc", 481 "VHnequa:s:f:d:F:tcT:",
477#else 482#else
478 "VHnequa:f:d:F:tc", 483 "VHnequa:f:d:F:tcT:",
479#endif 484#endif
480 longopts, 0); 485 longopts, 0);
481 486
@@ -554,6 +559,10 @@ decode_options (int argc, char **argv)
554 frame_parameters = optarg; 559 frame_parameters = optarg;
555 break; 560 break;
556 561
562 case 'T':
563 tramp_prefix = optarg;
564 break;
565
557 default: 566 default:
558 message (true, "Try '%s --help' for more information\n", progname); 567 message (true, "Try '%s --help' for more information\n", progname);
559 exit (EXIT_FAILURE); 568 exit (EXIT_FAILURE);
@@ -654,6 +663,9 @@ The following OPTIONS are accepted:\n\
654 Editor to fallback to if the server is not running\n" 663 Editor to fallback to if the server is not running\n"
655" If EDITOR is the empty string, start Emacs in daemon\n\ 664" If EDITOR is the empty string, start Emacs in daemon\n\
656 mode and try connecting again\n" 665 mode and try connecting again\n"
666"-T PREFIX, --tramp=PREFIX\n\
667 PREFIX to prepend to filenames sent by emacsclient\n\
668 for locating files remotely via Tramp\n"
657"\n\ 669"\n\
658Report bugs with M-x report-emacs-bug.\n"); 670Report bugs with M-x report-emacs-bug.\n");
659 exit (EXIT_SUCCESS); 671 exit (EXIT_SUCCESS);
@@ -1687,6 +1699,8 @@ main (int argc, char **argv)
1687 } 1699 }
1688 } 1700 }
1689 send_to_emacs (emacs_socket, "-dir "); 1701 send_to_emacs (emacs_socket, "-dir ");
1702 if (tramp_prefix)
1703 quote_argument (emacs_socket, tramp_prefix);
1690 quote_argument (emacs_socket, cwd); 1704 quote_argument (emacs_socket, cwd);
1691 send_to_emacs (emacs_socket, "/"); 1705 send_to_emacs (emacs_socket, "/");
1692 send_to_emacs (emacs_socket, " "); 1706 send_to_emacs (emacs_socket, " ");
@@ -1791,6 +1805,8 @@ main (int argc, char **argv)
1791#endif 1805#endif
1792 1806
1793 send_to_emacs (emacs_socket, "-file "); 1807 send_to_emacs (emacs_socket, "-file ");
1808 if (tramp_prefix && file_name_absolute_p (argv[i]))
1809 quote_argument (emacs_socket, tramp_prefix);
1794 quote_argument (emacs_socket, argv[i]); 1810 quote_argument (emacs_socket, argv[i]);
1795 send_to_emacs (emacs_socket, " "); 1811 send_to_emacs (emacs_socket, " ");
1796 } 1812 }