Mercurial > emacs
comparison man/misc.texi @ 74494:ad8a70083559
(Emacs Server): Improve wording. Don't mention the ``server program''.
Add a cross-reference to "Init File" node.
(Invoking emacsclient): Add index entries. Document both short and long
versions of command-line options. Document the -f option.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 08 Dec 2006 17:02:33 +0000 |
parents | b57213679354 |
children | ea1646547d96 |
comparison
equal
deleted
inserted
replaced
74493:817f7407b88f | 74494:ad8a70083559 |
---|---|
1242 sending. By convention, most of these programs use the environment | 1242 sending. By convention, most of these programs use the environment |
1243 variable @env{EDITOR} to specify which editor to run. If you set | 1243 variable @env{EDITOR} to specify which editor to run. If you set |
1244 @env{EDITOR} to @samp{emacs}, they invoke Emacs---but in an | 1244 @env{EDITOR} to @samp{emacs}, they invoke Emacs---but in an |
1245 inconvenient fashion, by starting a new, separate Emacs process. This | 1245 inconvenient fashion, by starting a new, separate Emacs process. This |
1246 is inconvenient because it takes time and because the new Emacs process | 1246 is inconvenient because it takes time and because the new Emacs process |
1247 doesn't share the buffers in any existing Emacs process. | 1247 doesn't share the buffers with any existing Emacs process. |
1248 | 1248 |
1249 You can arrange to use your existing Emacs process as the editor for | 1249 You can arrange to use your existing Emacs process as the editor for |
1250 programs like @code{mail} by using the Emacs client and Emacs server | 1250 programs like @code{mail} by using the Emacs client program and the |
1251 programs. Here is how. | 1251 server that is part of Emacs. Here is how. |
1252 | 1252 |
1253 @cindex @env{TEXEDIT} environment variable | 1253 @cindex @env{TEXEDIT} environment variable |
1254 First, the preparation. Within Emacs, call the function | 1254 @findex server-start |
1255 @code{server-start}. (Your @file{.emacs} file can do this automatically | 1255 First, the preparations. Within Emacs, call the function |
1256 if you add the expression @code{(server-start)} to it.) Then, outside | 1256 @code{server-start}. (Your @file{.emacs} init file can do this |
1257 Emacs, set the @env{EDITOR} environment variable to @samp{emacsclient}. | 1257 automatically if you add the expression @code{(server-start)} to it, |
1258 (Note that some programs use a different environment variable; for | 1258 see @ref{Init File}.) Then, outside Emacs, set the @env{EDITOR} |
1259 example, to make @TeX{} use @samp{emacsclient}, you should set the | 1259 environment variable to @samp{emacsclient}. (Note that some programs |
1260 @env{TEXEDIT} environment variable to @samp{emacsclient +%d %s}.) | 1260 use a different environment variable; for example, to make @TeX{} use |
1261 @samp{emacsclient}, you should set the @env{TEXEDIT} environment | |
1262 variable to @samp{emacsclient +%d %s}.) | |
1263 | |
1264 @pindex emacs.bash | |
1265 @cindex Bash command to use Emacs server | |
1266 As an alternative to using @code{emacsclient}, the file | |
1267 @file{etc/emacs.bash} defines a Bash command @code{edit} which will | |
1268 communicate with a running Emacs session, or start one if none exist. | |
1261 | 1269 |
1262 @kindex C-x # | 1270 @kindex C-x # |
1263 @findex server-edit | 1271 @findex server-edit |
1264 Then, whenever any program invokes your specified @env{EDITOR} | 1272 Now, whenever any program invokes your specified @env{EDITOR} |
1265 program, the effect is to send a message to your principal Emacs telling | 1273 program, the effect is to send a message to your principal Emacs telling |
1266 it to visit a file. (That's what the program @code{emacsclient} does.) | 1274 it to visit a file. (That's what the program @code{emacsclient} does.) |
1267 Emacs displays the buffer immediately and you can immediately begin | 1275 Emacs displays the buffer immediately and you can immediately begin |
1268 editing it. | 1276 editing it in the already running Emacs session. |
1269 | 1277 |
1270 When you've finished editing that buffer, type @kbd{C-x #} | 1278 When you've finished editing that buffer, type @kbd{C-x #} |
1271 (@code{server-edit}). This saves the file and sends a message back to | 1279 (@code{server-edit}). This saves the file and sends a message back to |
1272 the @code{emacsclient} program telling it to exit. The programs that | 1280 the @code{emacsclient} program telling it to exit. The programs that |
1273 use @env{EDITOR} wait for the ``editor'' (actually, @code{emacsclient}) | 1281 use @env{EDITOR} wait for the ``editor'' (actually, @code{emacsclient}) |
1295 @vindex server-name | 1303 @vindex server-name |
1296 You can run multiple Emacs servers on the same machine by giving | 1304 You can run multiple Emacs servers on the same machine by giving |
1297 each one a unique ``server name'', using the variable | 1305 each one a unique ``server name'', using the variable |
1298 @code{server-name}. For example, @kbd{M-x set-variable @key{RET} | 1306 @code{server-name}. For example, @kbd{M-x set-variable @key{RET} |
1299 server-name @key{RET} foo @key{RET}} sets the server name to | 1307 server-name @key{RET} foo @key{RET}} sets the server name to |
1300 @samp{foo}. The @code{emacsclient} program can visit a server by name | 1308 @samp{foo}. The @code{emacsclient} program can specify a server by |
1301 using the @samp{-s} option. @xref{Invoking emacsclient}. | 1309 name using the @samp{-s} option. @xref{Invoking emacsclient}. |
1302 | 1310 |
1303 While @code{mail} or another application is waiting for | 1311 While @code{mail} or another application is waiting for |
1304 @code{emacsclient} to finish, @code{emacsclient} does not read terminal | 1312 @code{emacsclient} to finish, @code{emacsclient} does not read terminal |
1305 input. So the terminal that @code{mail} was using is effectively | 1313 input. So the terminal that @code{mail} was using is effectively |
1306 blocked for the duration. In order to edit with your principal Emacs, | 1314 blocked for the duration. In order to edit with your principal Emacs, |
1333 * Invoking emacsclient:: Emacs client startup options. | 1341 * Invoking emacsclient:: Emacs client startup options. |
1334 @end menu | 1342 @end menu |
1335 | 1343 |
1336 @node Invoking emacsclient,, Emacs Server, Emacs Server | 1344 @node Invoking emacsclient,, Emacs Server, Emacs Server |
1337 @subsection Invoking @code{emacsclient} | 1345 @subsection Invoking @code{emacsclient} |
1346 @cindex @code{emacsclient} invocation and options | |
1338 | 1347 |
1339 To run the @code{emacsclient} program, specify file names as arguments, | 1348 To run the @code{emacsclient} program, specify file names as arguments, |
1340 and optionally line numbers as well, like this: | 1349 and optionally line numbers as well, like this: |
1341 | 1350 |
1342 @example | 1351 @example |
1361 | 1370 |
1362 But if you use the option @samp{-n} or @samp{--no-wait} when running | 1371 But if you use the option @samp{-n} or @samp{--no-wait} when running |
1363 @code{emacsclient}, then it returns immediately. (You can take as | 1372 @code{emacsclient}, then it returns immediately. (You can take as |
1364 long as you like to edit the files in Emacs.) | 1373 long as you like to edit the files in Emacs.) |
1365 | 1374 |
1366 The option @samp{--alternate-editor=@var{command}} specifies a | 1375 The option @samp{-a @var{command}} or |
1367 command to run if @code{emacsclient} fails to contact Emacs. This is | 1376 @samp{--alternate-editor=@var{command}} specifies a command to run if |
1368 useful when running @code{emacsclient} in a script. For example, the | 1377 @code{emacsclient} fails to contact Emacs. This is useful when |
1369 following setting for the @env{EDITOR} environment variable will | 1378 running @code{emacsclient} in a script. For example, the following |
1370 always give you an editor, even if no Emacs server is running: | 1379 setting for the @env{EDITOR} environment variable will always give you |
1380 an editor, even if no Emacs server is running: | |
1371 | 1381 |
1372 @example | 1382 @example |
1373 EDITOR="emacsclient --alternate-editor emacs +%d %s" | 1383 EDITOR="emacsclient --alternate-editor emacs +%d %s" |
1374 @end example | 1384 @end example |
1375 | 1385 |
1376 @noindent | 1386 @noindent |
1387 @cindex @env{ALTERNATE_EDITOR} environment variable | |
1377 The environment variable @env{ALTERNATE_EDITOR} has the same effect, with | 1388 The environment variable @env{ALTERNATE_EDITOR} has the same effect, with |
1378 the value of the @samp{--alternate-editor} option taking precedence. | 1389 the value of the @samp{--alternate-editor} option taking precedence. |
1379 | 1390 |
1380 @pindex emacs.bash | |
1381 Alternatively, the file @file{etc/emacs.bash} defines a bash | |
1382 function which will communicate with a running Emacs server, or start | |
1383 one if none exists. | |
1384 | |
1385 If you use several displays, you can tell Emacs on which display to | 1391 If you use several displays, you can tell Emacs on which display to |
1386 open the given files with the option @samp{--display=@var{DISPLAY}}. | 1392 open the given files with the @samp{-d @var{display}} or |
1387 This can be used typically when connecting from home to an Emacs | 1393 @samp{--display=@var{display}} option to @code{emacsclient}. This is |
1388 server running on your machine at your workplace. | 1394 handy when connecting from home to an Emacs session running on your |
1395 machine at your workplace. | |
1389 | 1396 |
1390 If there is more than one Emacs server running, you can specify a | 1397 If there is more than one Emacs server running, you can specify a |
1391 server name with the option @samp{-s @var{name}}. | 1398 server name with the @samp{-s @var{name}} or |
1399 @samp{--socket-name=@var{name}} option to @code{emacsclient}. (This | |
1400 option is not supported on MS-Windows.) | |
1392 | 1401 |
1393 You can also use @code{emacsclient} to execute any piece of Emacs Lisp | 1402 You can also use @code{emacsclient} to execute any piece of Emacs Lisp |
1394 code, using the option @samp{--eval}. When this option is given, the | 1403 code, using the @samp{-e} or @samp{--eval} option. When this option |
1395 rest of the arguments is not taken as a list of files to visit but as | 1404 is given, the rest of the arguments is interpreted as a list of |
1396 a list of expressions to evaluate. | 1405 expressions to evaluate, not a list of files to visit. |
1406 | |
1407 @cindex @env{EMACS_SERVER_FILE} environment variable | |
1408 When you start the Emacs server (by calling @code{server-start}), | |
1409 Emacs creates a file with information about the TCP connection to the | |
1410 server: the host where Emacs runs, the port where it listens for | |
1411 @code{emacsclient} requests, and the authentication string to use for | |
1412 the connection. @code{emacsclient} uses this information if it needs | |
1413 to connect to the server via TCP. By default, this TCP configuration | |
1414 file is placed in the @file{~/.emacs.d/server/} directory@footnote{ | |
1415 On MS-Windows, if @env{HOME} is not set or the TCP configuration file | |
1416 cannot be found there, Emacs in addition attempts to find the file in | |
1417 the @file{.emacs.d/server/} subdirectory of the directory pointed | |
1418 to by the @env{APPDATA} environment variable, which is a user-specific | |
1419 directory for application data files. This is similar to what Emacs | |
1420 does on MS-Windows to search for the user's @file{.emacs} file.} | |
1421 ; you can | |
1422 direct @code{emacsclient} to use a different file with the @samp{-f | |
1423 @var{file}} or @samp{--server-file=@var{file}} option, or by defining | |
1424 the @env{EMACS_SERVER_FILE} environment variable that points to the | |
1425 non-default TCP configuration file. | |
1397 | 1426 |
1398 @node Printing, Sorting, Emacs Server, Top | 1427 @node Printing, Sorting, Emacs Server, Top |
1399 @section Printing Hard Copies | 1428 @section Printing Hard Copies |
1400 @cindex hardcopy | 1429 @cindex hardcopy |
1401 @cindex printing | 1430 @cindex printing |