aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorEli Zaretskii2017-05-19 11:51:16 +0300
committerEli Zaretskii2017-05-19 11:51:16 +0300
commit7430617d3d84dc111e1a28f4f3884bf827d4fec9 (patch)
tree94d971a5e3865716b282e84e8b7f4e782cccd38b /doc
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 'doc')
-rw-r--r--doc/emacs/emacs.texi1
-rw-r--r--doc/emacs/misc.texi120
2 files changed, 102 insertions, 19 deletions
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 5c8977c6b09..a3eb4225a75 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -1082,6 +1082,7 @@ Shell Command History
1082 1082
1083Using Emacs as a Server 1083Using Emacs as a Server
1084 1084
1085* TCP Emacs server:: Listening to a TCP socket.
1085* Invoking emacsclient:: Connecting to the Emacs server. 1086* Invoking emacsclient:: Connecting to the Emacs server.
1086* emacsclient Options:: Emacs client startup options. 1087* emacsclient Options:: Emacs client startup options.
1087 1088
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index bcc20a6db16..84681f2269a 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1661,10 +1661,68 @@ expression @code{(+ 1 2)} on the @samp{foo} server, and returns
1661signaled.) Currently, this feature is mainly useful for developers. 1661signaled.) Currently, this feature is mainly useful for developers.
1662 1662
1663@menu 1663@menu
1664* TCP Emacs server:: Listening to a TCP socket.
1664* Invoking emacsclient:: Connecting to the Emacs server. 1665* Invoking emacsclient:: Connecting to the Emacs server.
1665* emacsclient Options:: Emacs client startup options. 1666* emacsclient Options:: Emacs client startup options.
1666@end menu 1667@end menu
1667 1668
1669@node TCP Emacs server
1670@subsection TCP Emacs server
1671@cindex TCP Emacs server
1672
1673@vindex server-use-tcp
1674 An Emacs server usually listens to connections on a local Unix
1675domain socket. Some operating systems, such as MS-Windows, do not
1676support local sockets; in that case, the server uses TCP sockets
1677instead. In some cases it is useful to have the server listen on a
1678TCP socket even if local sockets are supported, e.g., if you need to
1679contact the Emacs server from a remote machine. You can set
1680@code{server-use-tcp} to non-@code{nil} to have Emacs listen on a TCP
1681socket instead of a local socket. This is the default if your OS does
1682not support local sockets.
1683
1684@vindex server-host
1685@vindex server-port
1686 If the Emacs server is set to use TCP, it will by default listen to
1687a random port on the localhost interface. This can be changed to
1688another interface and/or a fixed port using the variables
1689@code{server-host} and @code{server-port}.
1690
1691@vindex server-auth-key
1692 A TCP socket is not subject to file system permissions. To retain
1693some control over which users can talk to an Emacs server over TCP
1694sockets, the @command{emacsclient} program must send an authorization
1695key to the server. This key is normally randomly generated by the
1696Emacs server. This is the recommended mode of operation.
1697
1698@findex server-generate-key
1699 If needed, you can set the authorization key to a static value by
1700setting the @code{server-auth-key} variable. The key must consist of
170164 ASCII printable characters except for space (this means characters
1702from @samp{!} to @samp{~}, or from decimal code 33 to 126). You can
1703use @kbd{M-x server-generate-key} to get a random key.
1704
1705@vindex server-auth-dir
1706@cindex server file
1707 When you start a TCP Emacs server, Emacs creates a @dfn{server file}
1708containing the TCP information to be used by @command{emacsclient} to
1709connect to the server. The variable @code{server-auth-dir} specifies
1710the directory containing the server file; by default, this is
1711@file{~/.emacs.d/server/}. In the absence of a local socket with file
1712permissions, the permissions of this directory determine which users
1713can have their @command{emacsclient} processes talk to the Emacs
1714server.
1715
1716@vindex EMACS_SERVER_FILE@r{, environment variable}
1717 To tell @command{emacsclient} to connect to the server over TCP with
1718a specific server file, use the @samp{-f} or @samp{--server-file}
1719option, or set the @env{EMACS_SERVER_FILE} environment variable
1720(@pxref{emacsclient Options}). If @code{server-auth-dir} is set to a
1721non-standard value, @command{emacsclient} needs an absolute file name
1722to the server file, as the default @code{server-auth-dir} is
1723hard-coded in @command{emacsclient} to be used as the directory for
1724resolving relative filenames.
1725
1668@node Invoking emacsclient 1726@node Invoking emacsclient
1669@subsection Invoking @code{emacsclient} 1727@subsection Invoking @code{emacsclient}
1670@cindex @code{emacsclient} invocation 1728@cindex @code{emacsclient} invocation
@@ -1810,25 +1868,18 @@ evaluate, @emph{not} as a list of files to visit.
1810 1868
1811@item -f @var{server-file} 1869@item -f @var{server-file}
1812@itemx --server-file=@var{server-file} 1870@itemx --server-file=@var{server-file}
1813@cindex @env{EMACS_SERVER_FILE} environment variable 1871Specify a server file (@pxref{TCP Emacs server}) for connecting to an
1814Specify a @dfn{server file} for connecting to an Emacs server via TCP. 1872Emacs server via TCP. Alternatively, you can set the
1815 1873@env{EMACS_SERVER_FILE} environment variable to point to the server
1816An Emacs server usually uses a 1874file.
1817local socket to listen for connections. Some operating systems, 1875
1818such as Microsoft Windows, do not support local sockets; in that case, 1876An Emacs server usually uses a local socket to listen for connections,
1819the server communicates with @command{emacsclient} via TCP. 1877but also supports connections over TCP. To connect to a TCP Emacs
1820 1878server, @command{emacsclient} needs to read a @dfn{server file}
1821@vindex server-auth-dir 1879containing the connection details of the Emacs server. The name of
1822@cindex server file 1880this file is specified with this option, either as a file name
1823@vindex server-port 1881relative to @file{~/.emacs.d/server} or as an absolute file name.
1824When you start a TCP Emacs server, Emacs creates a @dfn{server file} 1882@xref{TCP Emacs server}.
1825containing the TCP information to be used by @command{emacsclient} to
1826connect to the server. The variable @code{server-auth-dir} specifies
1827the directory containing the server file; by default, this is
1828@file{~/.emacs.d/server/}. To tell @command{emacsclient} to connect
1829to the server over TCP with a specific server file, use the @samp{-f}
1830or @samp{--server-file} option, or set the @env{EMACS_SERVER_FILE}
1831environment variable.
1832 1883
1833@item -n 1884@item -n
1834@itemx --no-wait 1885@itemx --no-wait
@@ -1872,6 +1923,37 @@ On MS-Windows, @samp{-t} behaves just like @samp{-c} if the Emacs
1872server is using the graphical display, but if the Emacs server is 1923server is using the graphical display, but if the Emacs server is
1873running on a text terminal, it creates a new frame in the current text 1924running on a text terminal, it creates a new frame in the current text
1874terminal. 1925terminal.
1926
1927@item -T @var{tramp-prefix}
1928@itemx --tramp-prefix=@var{tramp-prefix}
1929Set the prefix to add to filenames for Emacs to locate files on remote
1930machines using TRAMP (@pxref{Top, The Tramp Manual,, tramp, The Tramp
1931Manual}). This is mostly useful in combination with using the Emacs
1932server over TCP (@pxref{TCP Emacs server}). By ssh-forwarding the
1933listening port and making the @var{server-file} available on a remote
1934machine, programs on the remote machine can use @command{emacsclient}
1935as the value for the @env{EDITOR} and similar environment variables,
1936but instead of talking to an Emacs server on the remote machine, the
1937files will be visited in the local Emacs session using TRAMP.
1938
1939@vindex EMACSCLIENT_TRAMP@r{, environment variable}
1940Setting the environment variable @env{EMACSCLIENT_TRAMP} has the same
1941effect as using the @samp{-T} option. If both are specified, the
1942command-line option takes precedence.
1943
1944For example, assume two hosts, @samp{local} and @samp{remote}, and
1945that the local Emacs listens on tcp port 12345. Assume further that
1946@file{/home} is on a shared file system, so that the server file
1947@file{~/.emacs.d/server/server} is readable on both hosts.
1948
1949@example
1950local$ ssh -R12345:localhost:12345 remote
1951remote$ export EDITOR="emacsclient \
1952 --server-file=server \
1953 --tramp=/ssh:remote:"
1954remote$ $EDITOR /tmp/foo.txt #Should open in local emacs.
1955@end example
1956
1875@end table 1957@end table
1876 1958
1877 The new graphical or text terminal frames created by the @samp{-c} 1959 The new graphical or text terminal frames created by the @samp{-c}