diff options
| author | Eli Zaretskii | 2017-05-19 11:51:16 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-05-19 11:51:16 +0300 |
| commit | 7430617d3d84dc111e1a28f4f3884bf827d4fec9 (patch) | |
| tree | 94d971a5e3865716b282e84e8b7f4e782cccd38b /doc | |
| parent | bb5c6614eb171eef8c08474e0f949fe18ef4b230 (diff) | |
| download | emacs-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.texi | 1 | ||||
| -rw-r--r-- | doc/emacs/misc.texi | 120 |
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 | ||
| 1083 | Using Emacs as a Server | 1083 | Using 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 | |||
| 1661 | signaled.) Currently, this feature is mainly useful for developers. | 1661 | signaled.) 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 | ||
| 1675 | domain socket. Some operating systems, such as MS-Windows, do not | ||
| 1676 | support local sockets; in that case, the server uses TCP sockets | ||
| 1677 | instead. In some cases it is useful to have the server listen on a | ||
| 1678 | TCP socket even if local sockets are supported, e.g., if you need to | ||
| 1679 | contact 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 | ||
| 1681 | socket instead of a local socket. This is the default if your OS does | ||
| 1682 | not 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 | ||
| 1687 | a random port on the localhost interface. This can be changed to | ||
| 1688 | another 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 | ||
| 1693 | some control over which users can talk to an Emacs server over TCP | ||
| 1694 | sockets, the @command{emacsclient} program must send an authorization | ||
| 1695 | key to the server. This key is normally randomly generated by the | ||
| 1696 | Emacs 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 | ||
| 1700 | setting the @code{server-auth-key} variable. The key must consist of | ||
| 1701 | 64 ASCII printable characters except for space (this means characters | ||
| 1702 | from @samp{!} to @samp{~}, or from decimal code 33 to 126). You can | ||
| 1703 | use @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} | ||
| 1708 | containing the TCP information to be used by @command{emacsclient} to | ||
| 1709 | connect to the server. The variable @code{server-auth-dir} specifies | ||
| 1710 | the directory containing the server file; by default, this is | ||
| 1711 | @file{~/.emacs.d/server/}. In the absence of a local socket with file | ||
| 1712 | permissions, the permissions of this directory determine which users | ||
| 1713 | can have their @command{emacsclient} processes talk to the Emacs | ||
| 1714 | server. | ||
| 1715 | |||
| 1716 | @vindex EMACS_SERVER_FILE@r{, environment variable} | ||
| 1717 | To tell @command{emacsclient} to connect to the server over TCP with | ||
| 1718 | a specific server file, use the @samp{-f} or @samp{--server-file} | ||
| 1719 | option, or set the @env{EMACS_SERVER_FILE} environment variable | ||
| 1720 | (@pxref{emacsclient Options}). If @code{server-auth-dir} is set to a | ||
| 1721 | non-standard value, @command{emacsclient} needs an absolute file name | ||
| 1722 | to the server file, as the default @code{server-auth-dir} is | ||
| 1723 | hard-coded in @command{emacsclient} to be used as the directory for | ||
| 1724 | resolving 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 | 1871 | Specify a server file (@pxref{TCP Emacs server}) for connecting to an |
| 1814 | Specify a @dfn{server file} for connecting to an Emacs server via TCP. | 1872 | Emacs server via TCP. Alternatively, you can set the |
| 1815 | 1873 | @env{EMACS_SERVER_FILE} environment variable to point to the server | |
| 1816 | An Emacs server usually uses a | 1874 | file. |
| 1817 | local socket to listen for connections. Some operating systems, | 1875 | |
| 1818 | such as Microsoft Windows, do not support local sockets; in that case, | 1876 | An Emacs server usually uses a local socket to listen for connections, |
| 1819 | the server communicates with @command{emacsclient} via TCP. | 1877 | but also supports connections over TCP. To connect to a TCP Emacs |
| 1820 | 1878 | server, @command{emacsclient} needs to read a @dfn{server file} | |
| 1821 | @vindex server-auth-dir | 1879 | containing the connection details of the Emacs server. The name of |
| 1822 | @cindex server file | 1880 | this file is specified with this option, either as a file name |
| 1823 | @vindex server-port | 1881 | relative to @file{~/.emacs.d/server} or as an absolute file name. |
| 1824 | When you start a TCP Emacs server, Emacs creates a @dfn{server file} | 1882 | @xref{TCP Emacs server}. |
| 1825 | containing the TCP information to be used by @command{emacsclient} to | ||
| 1826 | connect to the server. The variable @code{server-auth-dir} specifies | ||
| 1827 | the directory containing the server file; by default, this is | ||
| 1828 | @file{~/.emacs.d/server/}. To tell @command{emacsclient} to connect | ||
| 1829 | to the server over TCP with a specific server file, use the @samp{-f} | ||
| 1830 | or @samp{--server-file} option, or set the @env{EMACS_SERVER_FILE} | ||
| 1831 | environment 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 | |||
| 1872 | server is using the graphical display, but if the Emacs server is | 1923 | server is using the graphical display, but if the Emacs server is |
| 1873 | running on a text terminal, it creates a new frame in the current text | 1924 | running on a text terminal, it creates a new frame in the current text |
| 1874 | terminal. | 1925 | terminal. |
| 1926 | |||
| 1927 | @item -T @var{tramp-prefix} | ||
| 1928 | @itemx --tramp-prefix=@var{tramp-prefix} | ||
| 1929 | Set the prefix to add to filenames for Emacs to locate files on remote | ||
| 1930 | machines using TRAMP (@pxref{Top, The Tramp Manual,, tramp, The Tramp | ||
| 1931 | Manual}). This is mostly useful in combination with using the Emacs | ||
| 1932 | server over TCP (@pxref{TCP Emacs server}). By ssh-forwarding the | ||
| 1933 | listening port and making the @var{server-file} available on a remote | ||
| 1934 | machine, programs on the remote machine can use @command{emacsclient} | ||
| 1935 | as the value for the @env{EDITOR} and similar environment variables, | ||
| 1936 | but instead of talking to an Emacs server on the remote machine, the | ||
| 1937 | files will be visited in the local Emacs session using TRAMP. | ||
| 1938 | |||
| 1939 | @vindex EMACSCLIENT_TRAMP@r{, environment variable} | ||
| 1940 | Setting the environment variable @env{EMACSCLIENT_TRAMP} has the same | ||
| 1941 | effect as using the @samp{-T} option. If both are specified, the | ||
| 1942 | command-line option takes precedence. | ||
| 1943 | |||
| 1944 | For example, assume two hosts, @samp{local} and @samp{remote}, and | ||
| 1945 | that 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 | ||
| 1950 | local$ ssh -R12345:localhost:12345 remote | ||
| 1951 | remote$ export EDITOR="emacsclient \ | ||
| 1952 | --server-file=server \ | ||
| 1953 | --tramp=/ssh:remote:" | ||
| 1954 | remote$ $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} |