diff options
| author | Chong Yidong | 2011-12-12 15:25:58 +0800 |
|---|---|---|
| committer | Chong Yidong | 2011-12-12 15:25:58 +0800 |
| commit | 29eabb8efff24750fd18b98d2e4217e04abcb4ab (patch) | |
| tree | ee74a57f85796096684ebbb67363fa592caac013 | |
| parent | 333f9019e29e9b6de3a7ec07448be1d364ba540b (diff) | |
| download | emacs-29eabb8efff24750fd18b98d2e4217e04abcb4ab.tar.gz emacs-29eabb8efff24750fd18b98d2e4217e04abcb4ab.zip | |
More updates to Building chapter of Emacs manual.
* doc/emacs/building.texi (Executing Lisp): Fix xref for C-M-x.
(Lisp Libraries): Add xref to node explaining `load' in Lisp
manual. Note that load-path is not customizable.
(Lisp Eval): Note that listed commands are available globally.
Explain the meaning of "defun" in the C-M-x context.
(Lisp Interaction): Copyedits.
(External Lisp): Fix name of inferior Lisp buffer. Mention Scheme.
(Compilation): Define "inferior process".
| -rw-r--r-- | doc/emacs/ChangeLog | 12 | ||||
| -rw-r--r-- | doc/emacs/building.texi | 436 | ||||
| -rw-r--r-- | doc/emacs/emacs.texi | 2 | ||||
| -rw-r--r-- | etc/NEWS | 3 |
4 files changed, 233 insertions, 220 deletions
diff --git a/doc/emacs/ChangeLog b/doc/emacs/ChangeLog index d1dbbfd0831..c26f1a7e1ca 100644 --- a/doc/emacs/ChangeLog +++ b/doc/emacs/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2011-12-12 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * building.texi (Executing Lisp): Fix xref for C-M-x. | ||
| 4 | (Lisp Libraries): Add xref to node explaining `load' in Lisp | ||
| 5 | manual. Note that load-path is not customizable. | ||
| 6 | (Lisp Eval): Note that listed commands are available globally. | ||
| 7 | Explain the meaning of "defun" in the C-M-x context. | ||
| 8 | (Lisp Interaction): Copyedits. | ||
| 9 | (External Lisp): Fix name of inferior Lisp buffer. Mention | ||
| 10 | Scheme. | ||
| 11 | (Compilation): Define "inferior process". | ||
| 12 | |||
| 1 | 2011-12-10 Eli Zaretskii <eliz@gnu.org> | 13 | 2011-12-10 Eli Zaretskii <eliz@gnu.org> |
| 2 | 14 | ||
| 3 | * msdog.texi (Windows Fonts): Document how to force GDI font | 15 | * msdog.texi (Windows Fonts): Document how to force GDI font |
diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi index 5e2cb8119de..ab4a485cb87 100644 --- a/doc/emacs/building.texi +++ b/doc/emacs/building.texi | |||
| @@ -24,9 +24,9 @@ assist in the process of compiling and testing programs. | |||
| 24 | * Executing Lisp:: Various modes for editing Lisp programs, | 24 | * Executing Lisp:: Various modes for editing Lisp programs, |
| 25 | with different facilities for running | 25 | with different facilities for running |
| 26 | the Lisp programs. | 26 | the Lisp programs. |
| 27 | * Libraries: Lisp Libraries. Creating Lisp programs to run in Emacs. | 27 | * Lisp Libraries:: How Lisp programs are loaded into Emacs. |
| 28 | * Eval: Lisp Eval. Executing a single Lisp expression in Emacs. | 28 | * Lisp Eval:: Executing a single Lisp expression in Emacs. |
| 29 | * Interaction: Lisp Interaction. Executing Lisp in an Emacs buffer. | 29 | * Lisp Interaction:: Executing Lisp in an Emacs buffer. |
| 30 | * External Lisp:: Communicating through Emacs with a separate Lisp. | 30 | * External Lisp:: Communicating through Emacs with a separate Lisp. |
| 31 | @end menu | 31 | @end menu |
| 32 | 32 | ||
| @@ -37,10 +37,9 @@ assist in the process of compiling and testing programs. | |||
| 37 | @cindex compilation errors | 37 | @cindex compilation errors |
| 38 | @cindex error log | 38 | @cindex error log |
| 39 | 39 | ||
| 40 | Emacs can run compilers for languages such as C and Fortran as | 40 | Emacs can run compilers for languages such as C and Fortran, feeding |
| 41 | inferior processes, feeding the compilation log into an Emacs buffer. | 41 | the compilation log into an Emacs buffer. It can also parse the error |
| 42 | It can also parse the error messages and show you where the errors | 42 | messages and show you where the errors occurred. |
| 43 | occurred. | ||
| 44 | 43 | ||
| 45 | @table @kbd | 44 | @table @kbd |
| 46 | @item M-x compile | 45 | @item M-x compile |
| @@ -56,11 +55,11 @@ Kill the running compilation subprocess. | |||
| 56 | @findex compile | 55 | @findex compile |
| 57 | To run @code{make} or another compilation command, type @kbd{M-x | 56 | To run @code{make} or another compilation command, type @kbd{M-x |
| 58 | compile}. This reads a shell command line using the minibuffer, and | 57 | compile}. This reads a shell command line using the minibuffer, and |
| 59 | then executes the command in an inferior shell, putting output in the | 58 | then executes the command by running a shell as a subprocess (or |
| 60 | buffer named @samp{*compilation*}. The current buffer's default | 59 | @dfn{inferior process}) of Emacs. The output is inserted in a buffer |
| 61 | directory is used as the working directory for the execution of the | 60 | named @samp{*compilation*}. The current buffer's default directory is |
| 62 | command; normally, therefore, compilation takes place in this | 61 | used as the working directory for the execution of the command; |
| 63 | directory. | 62 | normally, therefore, compilation takes place in this directory. |
| 64 | 63 | ||
| 65 | @vindex compile-command | 64 | @vindex compile-command |
| 66 | The default compilation command is @samp{make -k}, which is usually | 65 | The default compilation command is @samp{make -k}, which is usually |
| @@ -1286,109 +1285,119 @@ that thread. | |||
| 1286 | @node Executing Lisp | 1285 | @node Executing Lisp |
| 1287 | @section Executing Lisp Expressions | 1286 | @section Executing Lisp Expressions |
| 1288 | 1287 | ||
| 1289 | Emacs has several different major modes for Lisp and Scheme. They are | 1288 | Emacs has major modes for several variants of Lisp. They use the |
| 1290 | the same in terms of editing commands, but differ in the commands for | 1289 | same editing commands as other programming language modes |
| 1291 | executing Lisp expressions. Each mode has its own purpose. | 1290 | (@pxref{Programs}). In addition, they provide special commands for |
| 1291 | executing Lisp expressions. | ||
| 1292 | 1292 | ||
| 1293 | @table @asis | 1293 | @table @asis |
| 1294 | @item Emacs-Lisp mode | 1294 | @item Emacs Lisp mode |
| 1295 | The mode for editing source files of programs to run in Emacs Lisp. | 1295 | The mode for editing Emacs Lisp source files. It defines @kbd{C-M-x} |
| 1296 | This mode defines @kbd{C-M-x} to evaluate the current defun. | 1296 | to evaluate the current top-level Lisp expression. @xref{Lisp Eval}. |
| 1297 | @xref{Lisp Libraries}. | 1297 | |
| 1298 | @item Lisp Interaction mode | 1298 | @item Lisp Interaction mode |
| 1299 | The mode for an interactive session with Emacs Lisp. It defines | 1299 | The mode for an interactive Emacs Lisp session. It defines @kbd{C-j} |
| 1300 | @kbd{C-j} to evaluate the sexp before point and insert its value in the | 1300 | to evaluate the expression before point and insert its value in the |
| 1301 | buffer. @xref{Lisp Interaction}. | 1301 | buffer. @xref{Lisp Interaction}. |
| 1302 | |||
| 1302 | @item Lisp mode | 1303 | @item Lisp mode |
| 1303 | The mode for editing source files of programs that run in Lisps other | 1304 | The mode for editing source files of programs that run in Lisps other |
| 1304 | than Emacs Lisp. This mode defines @kbd{C-M-x} to send the current defun | 1305 | than Emacs Lisp. It defines @kbd{C-M-x} to evaluate the current |
| 1305 | to an inferior Lisp process. @xref{External Lisp}. | 1306 | top-level expression in an external Lisp. @xref{External Lisp}. |
| 1307 | |||
| 1306 | @item Inferior Lisp mode | 1308 | @item Inferior Lisp mode |
| 1307 | The mode for an interactive session with an inferior Lisp process. | 1309 | The mode for an interactive session with an external Lisp which is |
| 1308 | This mode combines the special features of Lisp mode and Shell mode | 1310 | being run as a subprocess (or @dfn{inferior process}) of Emacs. |
| 1309 | (@pxref{Shell Mode}). | 1311 | @ifnottex |
| 1312 | @xref{External Lisp}. | ||
| 1313 | @end ifnottex | ||
| 1314 | |||
| 1310 | @item Scheme mode | 1315 | @item Scheme mode |
| 1311 | Like Lisp mode but for Scheme programs. | 1316 | Like Lisp mode, but for Scheme programs. |
| 1317 | |||
| 1312 | @item Inferior Scheme mode | 1318 | @item Inferior Scheme mode |
| 1313 | The mode for an interactive session with an inferior Scheme process. | 1319 | Like Inferior Lisp mode, but for Scheme. |
| 1314 | @end table | 1320 | @end table |
| 1315 | 1321 | ||
| 1316 | Most editing commands for working with Lisp programs are in fact | ||
| 1317 | available globally. @xref{Programs}. | ||
| 1318 | |||
| 1319 | @node Lisp Libraries | 1322 | @node Lisp Libraries |
| 1320 | @section Libraries of Lisp Code for Emacs | 1323 | @section Libraries of Lisp Code for Emacs |
| 1321 | @cindex libraries | 1324 | @cindex libraries |
| 1322 | @cindex loading Lisp code | 1325 | @cindex loading Lisp code |
| 1323 | 1326 | ||
| 1324 | Lisp code for Emacs editing commands is stored in files whose names | 1327 | Emacs Lisp code is stored in files whose names conventionally end in |
| 1325 | conventionally end in @file{.el}. This ending tells Emacs to edit them in | 1328 | @file{.el}. Such files are automatically visited in Emacs Lisp mode. |
| 1326 | Emacs-Lisp mode (@pxref{Executing Lisp}). | ||
| 1327 | 1329 | ||
| 1328 | @cindex byte code | 1330 | @cindex byte code |
| 1329 | Emacs Lisp code can be compiled into byte-code, which loads faster, | 1331 | Emacs Lisp code can be compiled into byte-code, which loads faster, |
| 1330 | takes up less space, and executes faster. @xref{Byte Compilation,, | 1332 | takes up less space, and executes faster. By convention, compiled |
| 1331 | Byte Compilation, elisp, the Emacs Lisp Reference Manual}. By | 1333 | Emacs Lisp code goes in a separate file whose name ends in |
| 1332 | convention, the compiled code for a library goes in a separate file | 1334 | @samp{.elc}. For example, the compiled code for @file{foo.el} goes in |
| 1333 | whose name ends in @samp{.elc}. Thus, the compiled code for | 1335 | @file{foo.elc}. @xref{Byte Compilation,, Byte Compilation, elisp, the |
| 1334 | @file{foo.el} goes in @file{foo.elc}. | 1336 | Emacs Lisp Reference Manual}. |
| 1335 | 1337 | ||
| 1336 | @findex load-file | 1338 | @findex load-file |
| 1337 | To execute a file of Emacs Lisp code, use @kbd{M-x load-file}. This | 1339 | To @dfn{load} an Emacs Lisp file, type @kbd{M-x load-file}. This |
| 1338 | command reads a file name using the minibuffer and then executes the | 1340 | command reads a file name using the minibuffer, and executes the |
| 1339 | contents of that file as Lisp code. It is not necessary to visit the | 1341 | contents of that file as Emacs Lisp code. It is not necessary to |
| 1340 | file first; in any case, this command reads the file as found on disk, | 1342 | visit the file first; this command reads the file directly from disk, |
| 1341 | not text in an Emacs buffer. | 1343 | not from an existing Emacs buffer. |
| 1342 | 1344 | ||
| 1343 | @findex load | 1345 | @findex load |
| 1344 | @findex load-library | 1346 | @findex load-library |
| 1345 | Once a file of Lisp code is installed in the Emacs Lisp library | 1347 | @cindex load path for Emacs Lisp |
| 1346 | directories, users can load it using @kbd{M-x load-library}. Programs | 1348 | If an Emacs Lisp file is installed in the Emacs Lisp @dfn{load path} |
| 1347 | can load it by calling @code{load}, a more primitive function that is | 1349 | (defined below), you can load it by typing @kbd{M-x load-library}, |
| 1348 | similar but accepts some additional arguments. | 1350 | instead of using @kbd{M-x load-file}. The @kbd{M-x load-library} |
| 1349 | 1351 | command prompts for a @dfn{library name} rather than a file name; it | |
| 1350 | @kbd{M-x load-library} differs from @kbd{M-x load-file} in that it | 1352 | searches through each directory in the Emacs Lisp load path, trying to |
| 1351 | searches a sequence of directories and tries three file names in each | 1353 | find a file matching that library name. If the library name is |
| 1352 | directory. Suppose your argument is @var{lib}; the three names are | 1354 | @samp{@var{foo}}, it tries looking for files named |
| 1353 | @file{@var{lib}.elc}, @file{@var{lib}.el}, and lastly just | 1355 | @file{@var{foo}.elc}, @file{@var{foo}.el}, and lastly just |
| 1354 | @file{@var{lib}}. If @file{@var{lib}.elc} exists, it is by convention | 1356 | @file{@var{foo}}; the first one found is loaded. This command prefers |
| 1355 | the result of compiling @file{@var{lib}.el}; it is better to load the | 1357 | @file{.elc} files over @file{.el} files because compiled files load |
| 1356 | compiled file, since it will load and run faster. | 1358 | and run faster. If it finds that @file{@var{lib}.el} is newer than |
| 1357 | 1359 | @file{@var{lib}.elc}, it issues a warning, in case someone made | |
| 1358 | If @code{load-library} finds that @file{@var{lib}.el} is newer than | 1360 | changes to the @file{.el} file and forgot to recompile it, but loads |
| 1359 | @file{@var{lib}.elc} file, it issues a warning, because it's likely | 1361 | the @file{.elc} file anyway. (Due to this behavior, you can save |
| 1360 | that somebody made changes to the @file{.el} file and forgot to | 1362 | unfinished edits to Emacs Lisp source files, and not recompile until |
| 1361 | recompile it. Nonetheless, it loads @file{@var{lib}.elc}. This is | 1363 | your changes are ready for use.) |
| 1362 | because people often leave unfinished edits the source file, and don't | 1364 | |
| 1363 | recompile it until they think it is ready to use. | 1365 | Emacs Lisp programs usually load Emacs Lisp files using the |
| 1366 | @code{load} function. This is similar to @code{load-library}, but is | ||
| 1367 | lower-level and accepts additional arguments. @xref{How Programs Do | ||
| 1368 | Loading,,, elisp, the Emacs Lisp Reference Manual}. | ||
| 1364 | 1369 | ||
| 1365 | @vindex load-path | 1370 | @vindex load-path |
| 1366 | The variable @code{load-path} specifies the sequence of directories | 1371 | The Emacs Lisp load path is specified by the variable |
| 1367 | searched by @kbd{M-x load-library}. Its value should be a list of | 1372 | @code{load-path}. Its value should be a list of directory names |
| 1368 | strings that are directory names; in addition, @code{nil} in this list | 1373 | (strings). These directories are searched, in the specified order, by |
| 1369 | stands for the current default directory. (Generally, it is not a | 1374 | the @kbd{M-x load-library} command, the lower-level @code{load} |
| 1370 | good idea to put @code{nil} in the list; if you find yourself wishing | 1375 | function, and other Emacs functions that find Emacs Lisp libraries. A |
| 1376 | list entry in @code{load-path} can also have the special value | ||
| 1377 | @code{nil}, which stands for the current default directory, but it is | ||
| 1378 | almost always a bad idea to use this. (If you find yourself wishing | ||
| 1371 | that @code{nil} were in the list, most likely what you really want is | 1379 | that @code{nil} were in the list, most likely what you really want is |
| 1372 | to do @kbd{M-x load-file} this once.) | 1380 | to use @kbd{M-x load-file}.) |
| 1373 | 1381 | ||
| 1374 | The default value of @code{load-path} is a list of directories where | 1382 | The default value of @code{load-path} is a list of directories where |
| 1375 | the Lisp code for Emacs itself is stored. If you have libraries of | 1383 | the Lisp code for Emacs itself is stored. If you have libraries of |
| 1376 | your own, put them in a single directory and add that directory to | 1384 | your own in another directory, you can add that directory to the load |
| 1377 | @code{load-path}, by adding a line like this to your init file | 1385 | path. Unlike most other variables described in this manual, |
| 1378 | (@pxref{Init File}): | 1386 | @code{load-path} cannot be changed via the Customize interface |
| 1387 | (@pxref{Easy Customization}), but you can add a directory to it by | ||
| 1388 | putting a line like this in your init file (@pxref{Init File}): | ||
| 1379 | 1389 | ||
| 1380 | @example | 1390 | @example |
| 1381 | (add-to-list 'load-path "/path/to/lisp/libraries") | 1391 | (add-to-list 'load-path "/path/to/my/lisp/library") |
| 1382 | @end example | 1392 | @end example |
| 1383 | 1393 | ||
| 1384 | @cindex autoload | 1394 | @cindex autoload |
| 1385 | Some commands are @dfn{autoloaded}: when you run them, Emacs will | 1395 | Some commands are @dfn{autoloaded}: when you run them, Emacs |
| 1386 | automatically load the associated library first. For instance, the | 1396 | automatically loads the associated library first. For instance, the |
| 1387 | @code{compile} and @code{compilation-mode} commands | 1397 | @kbd{M-x compile} command (@pxref{Compilation}) is autoloaded; if you |
| 1388 | (@pxref{Compilation}) are autoloaded; if you call either command, | 1398 | call it, Emacs automatically loads the @code{compile} library first. |
| 1389 | Emacs automatically loads the @code{compile} library. In contrast, | 1399 | In contrast, the command @kbd{M-x recompile} is not autoloaded, so it |
| 1390 | the command @code{recompile} is not autoloaded, so it is unavailable | 1400 | is unavailable until you load the @code{compile} library. |
| 1391 | until you load the @code{compile} library. | ||
| 1392 | 1401 | ||
| 1393 | @vindex load-dangerous-libraries | 1402 | @vindex load-dangerous-libraries |
| 1394 | @cindex Lisp files byte-compiled by XEmacs | 1403 | @cindex Lisp files byte-compiled by XEmacs |
| @@ -1399,38 +1408,35 @@ Emacs to crash. Set the variable @code{load-dangerous-libraries} to | |||
| 1399 | 1408 | ||
| 1400 | @node Lisp Eval | 1409 | @node Lisp Eval |
| 1401 | @section Evaluating Emacs Lisp Expressions | 1410 | @section Evaluating Emacs Lisp Expressions |
| 1402 | @cindex Emacs-Lisp mode | 1411 | @cindex Emacs Lisp mode |
| 1403 | @cindex mode, Emacs-Lisp | 1412 | @cindex mode, Emacs Lisp |
| 1404 | 1413 | ||
| 1405 | @findex emacs-lisp-mode | 1414 | @findex emacs-lisp-mode |
| 1406 | Lisp programs intended to be run in Emacs should be edited in | 1415 | Emacs Lisp mode is the major mode for editing Emacs Lisp. Its mode |
| 1407 | Emacs-Lisp mode; this happens automatically for file names ending in | 1416 | command is @kbd{M-x emacs-lisp-mode}. |
| 1408 | @file{.el}. By contrast, Lisp mode itself is used for editing Lisp | ||
| 1409 | programs intended for other Lisp systems. To switch to Emacs-Lisp mode | ||
| 1410 | explicitly, use the command @kbd{M-x emacs-lisp-mode}. | ||
| 1411 | |||
| 1412 | For testing of Lisp programs to run in Emacs, it is often useful to | ||
| 1413 | evaluate part of the program as it is found in the Emacs buffer. For | ||
| 1414 | example, after changing the text of a Lisp function definition, | ||
| 1415 | evaluating the definition installs the change for future calls to the | ||
| 1416 | function. Evaluation of Lisp expressions is also useful in any kind of | ||
| 1417 | editing, for invoking noninteractive functions (functions that are | ||
| 1418 | not commands). | ||
| 1419 | 1417 | ||
| 1420 | @table @kbd | 1418 | Emacs provides several commands for evaluating Emacs Lisp |
| 1421 | @item M-: | 1419 | expressions. You can use these commands in Emacs Lisp mode, to test |
| 1422 | Read a single Lisp expression in the minibuffer, evaluate it, and print | 1420 | your Emacs Lisp code as it is being written. For example, after |
| 1423 | the value in the echo area (@code{eval-expression}). | 1421 | re-writing a function, you can evaluate the function definition to |
| 1424 | @item C-x C-e | 1422 | make it take effect for subsequent function calls. These commands are |
| 1425 | Evaluate the Lisp expression before point, and print the value in the | 1423 | also available globally, and can be used outside Emacs Lisp mode. |
| 1426 | echo area (@code{eval-last-sexp}). | 1424 | |
| 1427 | @item C-M-x | 1425 | @table @asis |
| 1426 | @item @kbd{M-:} | ||
| 1427 | Read a single Emacs Lisp expression in the minibuffer, evaluate it, | ||
| 1428 | and print the value in the echo area (@code{eval-expression}). | ||
| 1429 | @item @kbd{C-x C-e} | ||
| 1430 | Evaluate the Emacs Lisp expression before point, and print the value | ||
| 1431 | in the echo area (@code{eval-last-sexp}). | ||
| 1432 | @item @kbd{C-M-x} @r{(in Emacs Lisp mode)} | ||
| 1433 | @itemx @kbd{M-x eval-defun} | ||
| 1428 | Evaluate the defun containing or after point, and print the value in | 1434 | Evaluate the defun containing or after point, and print the value in |
| 1429 | the echo area (@code{eval-defun}). | 1435 | the echo area (@code{eval-defun}). |
| 1430 | @item M-x eval-region | 1436 | @item @kbd{M-x eval-region} |
| 1431 | Evaluate all the Lisp expressions in the region. | 1437 | Evaluate all the Emacs Lisp expressions in the region. |
| 1432 | @item M-x eval-buffer | 1438 | @item @kbd{M-x eval-buffer} |
| 1433 | Evaluate all the Lisp expressions in the buffer. | 1439 | Evaluate all the Emacs Lisp expressions in the buffer. |
| 1434 | @end table | 1440 | @end table |
| 1435 | 1441 | ||
| 1436 | @ifinfo | 1442 | @ifinfo |
| @@ -1442,150 +1448,144 @@ Evaluate all the Lisp expressions in the buffer. | |||
| 1442 | @kindex M-: | 1448 | @kindex M-: |
| 1443 | @end ifnotinfo | 1449 | @end ifnotinfo |
| 1444 | @findex eval-expression | 1450 | @findex eval-expression |
| 1445 | @kbd{M-:} (@code{eval-expression}) is the most basic command for evaluating | 1451 | @kbd{M-:} (@code{eval-expression}) reads an expression using the |
| 1446 | a Lisp expression interactively. It reads the expression using the | 1452 | minibuffer, and evaluates it. (Before evaluating the expression, the |
| 1447 | minibuffer, so you can execute any expression on a buffer regardless of | 1453 | current buffer switches back to the buffer that was current when you |
| 1448 | what the buffer contains. When the expression is evaluated, the current | 1454 | typed @kbd{M-:}, not the minibuffer into which you typed the |
| 1449 | buffer is once again the buffer that was current when @kbd{M-:} was | 1455 | expression.) |
| 1450 | typed. | ||
| 1451 | |||
| 1452 | @kindex C-M-x @r{(Emacs-Lisp mode)} | ||
| 1453 | @findex eval-defun | ||
| 1454 | In Emacs-Lisp mode, the key @kbd{C-M-x} is bound to the command | ||
| 1455 | @code{eval-defun}, which parses the defun containing or following point | ||
| 1456 | as a Lisp expression and evaluates it. The value is printed in the echo | ||
| 1457 | area. This command is convenient for installing in the Lisp environment | ||
| 1458 | changes that you have just made in the text of a function definition. | ||
| 1459 | |||
| 1460 | @kbd{C-M-x} treats @code{defvar} expressions specially. Normally, | ||
| 1461 | evaluating a @code{defvar} expression does nothing if the variable it | ||
| 1462 | defines already has a value. But @kbd{C-M-x} unconditionally resets the | ||
| 1463 | variable to the initial value specified in the @code{defvar} expression. | ||
| 1464 | @code{defcustom} expressions are treated similarly. | ||
| 1465 | This special feature is convenient for debugging Lisp programs. | ||
| 1466 | Typing @kbd{C-M-x} on a @code{defface} expression reinitializes | ||
| 1467 | the face according to the @code{defface} specification. | ||
| 1468 | 1456 | ||
| 1469 | @kindex C-x C-e | 1457 | @kindex C-x C-e |
| 1470 | @findex eval-last-sexp | 1458 | @findex eval-last-sexp |
| 1471 | The command @kbd{C-x C-e} (@code{eval-last-sexp}) evaluates the Lisp | 1459 | The command @kbd{C-x C-e} (@code{eval-last-sexp}) evaluates the |
| 1472 | expression preceding point in the buffer, and displays the value in the | 1460 | Emacs Lisp expression preceding point in the buffer, and displays the |
| 1473 | echo area. It is available in all major modes, not just Emacs-Lisp | 1461 | value in the echo area. When the result of an evaluation is an |
| 1474 | mode. It does not treat @code{defvar} specially. | 1462 | integer, you can type @kbd{C-x C-e} a second time to display the value |
| 1475 | 1463 | of the integer result in additional formats (octal, hexadecimal, and | |
| 1476 | When the result of an evaluation is an integer, you can type | 1464 | character). |
| 1477 | @kbd{C-x C-e} a second time to display the value of the integer result | 1465 | |
| 1478 | in additional formats (octal, hexadecimal, and character). | 1466 | If @kbd{M-:} or @kbd{C-x C-e} is given a prefix argument, it inserts |
| 1479 | 1467 | the value into the current buffer at point, rather than displaying it | |
| 1480 | If @kbd{C-x C-e}, or @kbd{M-:} is given a numeric argument, it | 1468 | in the echo area. The argument's value does not matter. |
| 1481 | inserts the value into the current buffer at point, rather than | 1469 | |
| 1482 | displaying it in the echo area. The argument's value does not matter. | 1470 | @kindex C-M-x @r{(Emacs Lisp mode)} |
| 1483 | @kbd{C-M-x} with a numeric argument instruments the function | 1471 | @findex eval-defun |
| 1484 | definition for Edebug (@pxref{Instrumenting, Instrumenting for Edebug,, elisp, the Emacs Lisp Reference Manual}). | 1472 | The @code{eval-defun} command is bound to @kbd{C-M-x} in Emacs Lisp |
| 1473 | mode. It evaluates the top-level Lisp expression containing or | ||
| 1474 | following point, and prints the value in the echo area. In this | ||
| 1475 | context, a top-level expression is referred to as a ``defun'', but it | ||
| 1476 | need not be an actual @code{defun} (function definition). In | ||
| 1477 | particular, this command treats @code{defvar} expressions specially. | ||
| 1478 | Normally, evaluating a @code{defvar} expression does nothing if the | ||
| 1479 | variable it defines already has a value. But this command | ||
| 1480 | unconditionally resets the variable to the initial value specified by | ||
| 1481 | the @code{defvar}; this is convenient for debugging Emacs Lisp | ||
| 1482 | programs. @code{defcustom} and @code{defface} expressions are treated | ||
| 1483 | similarly. Note that the other commands documented in this section do | ||
| 1484 | not have this special feature. | ||
| 1485 | |||
| 1486 | With a prefix argument, @kbd{C-M-x} instruments the function | ||
| 1487 | definition for Edebug, the Emacs Lisp Debugger. @xref{Instrumenting, | ||
| 1488 | Instrumenting for Edebug,, elisp, the Emacs Lisp Reference Manual}. | ||
| 1485 | 1489 | ||
| 1486 | @findex eval-region | 1490 | @findex eval-region |
| 1487 | @findex eval-buffer | 1491 | @findex eval-buffer |
| 1488 | The most general command for evaluating Lisp expressions from a buffer | 1492 | The command @kbd{M-x eval-region} parses the text of the region as |
| 1489 | is @code{eval-region}. @kbd{M-x eval-region} parses the text of the | 1493 | one or more Lisp expressions, evaluating them one by one. @kbd{M-x |
| 1490 | region as one or more Lisp expressions, evaluating them one by one. | 1494 | eval-buffer} is similar but evaluates the entire buffer. |
| 1491 | @kbd{M-x eval-buffer} is similar but evaluates the entire | ||
| 1492 | buffer. This is a reasonable way to install the contents of a file of | ||
| 1493 | Lisp code that you are ready to test. Later, as you find bugs and | ||
| 1494 | change individual functions, use @kbd{C-M-x} on each function that you | ||
| 1495 | change. This keeps the Lisp world in step with the source file. | ||
| 1496 | 1495 | ||
| 1497 | @vindex eval-expression-print-level | 1496 | @vindex eval-expression-print-level |
| 1498 | @vindex eval-expression-print-length | 1497 | @vindex eval-expression-print-length |
| 1499 | @vindex eval-expression-debug-on-error | 1498 | @vindex eval-expression-debug-on-error |
| 1500 | The two customizable variables @code{eval-expression-print-level} and | 1499 | The customizable variables @code{eval-expression-print-level} and |
| 1501 | @code{eval-expression-print-length} control the maximum depth and length | 1500 | @code{eval-expression-print-length} control the maximum depth and |
| 1502 | of lists to print in the result of the evaluation commands before | 1501 | length of lists to print in the result of the evaluation commands |
| 1503 | abbreviating them. @code{eval-expression-debug-on-error} controls | 1502 | before abbreviating them. @code{eval-expression-debug-on-error} |
| 1504 | whether evaluation errors invoke the debugger when these commands are | 1503 | controls whether evaluation errors invoke the debugger when these |
| 1505 | used; its default is @code{t}. | 1504 | commands are used; its default is @code{t}. |
| 1506 | 1505 | ||
| 1507 | @node Lisp Interaction | 1506 | @node Lisp Interaction |
| 1508 | @section Lisp Interaction Buffers | 1507 | @section Lisp Interaction Buffers |
| 1509 | 1508 | ||
| 1509 | @findex lisp-interaction-mode | ||
| 1510 | When Emacs starts up, it contains a buffer named @samp{*scratch*}, | 1510 | When Emacs starts up, it contains a buffer named @samp{*scratch*}, |
| 1511 | which is provided for evaluating Lisp expressions interactively inside | 1511 | which is provided for evaluating Emacs Lisp expressions interactively. |
| 1512 | Emacs. Its major mode is Lisp Interaction mode. | 1512 | Its major mode is Lisp Interaction mode. You can also enable Lisp |
| 1513 | Interaction mode by typing @kbd{M-x lisp-interaction-mode}. | ||
| 1513 | 1514 | ||
| 1514 | @findex eval-print-last-sexp | 1515 | @findex eval-print-last-sexp |
| 1515 | @kindex C-j @r{(Lisp Interaction mode)} | 1516 | @kindex C-j @r{(Lisp Interaction mode)} |
| 1516 | The simplest way to use the @samp{*scratch*} buffer is to insert | 1517 | In the @samp{*scratch*} buffer, and other Lisp Interaction mode |
| 1517 | Lisp expressions and type @kbd{C-j} (@code{eval-print-last-sexp}) | 1518 | buffers, @kbd{C-j} (@code{eval-print-last-sexp}) evaluates the Lisp |
| 1518 | after each expression. This command reads the Lisp expression before | 1519 | expression before point, and inserts the value at point. Thus, as you |
| 1519 | point, evaluates it, and inserts the value in printed representation | 1520 | type expressions into the buffer followed by @kbd{C-j} after each |
| 1520 | before point. The result is a complete typescript of the expressions | 1521 | expression, the buffer records a transcript of the evaluated |
| 1521 | you have evaluated and their values. | 1522 | expressions and their values. All other commands in Lisp Interaction |
| 1523 | mode are the same as in Emacs Lisp mode. | ||
| 1522 | 1524 | ||
| 1523 | @vindex initial-scratch-message | 1525 | @vindex initial-scratch-message |
| 1524 | At startup, the @samp{*scratch*} buffer contains a short message, in | 1526 | At startup, the @samp{*scratch*} buffer contains a short message, in |
| 1525 | the form of a Lisp comment, that explains what it is for. This | 1527 | the form of a Lisp comment, that explains what it is for. This |
| 1526 | message is controlled by the variable @code{initial-scratch-message}, | 1528 | message is controlled by the variable @code{initial-scratch-message}, |
| 1527 | which should be either a string or @code{nil}. If you set it to the | 1529 | which should be either a string, or @code{nil} (which means to |
| 1528 | empty string, or @code{nil}, the initial message is suppressed. | 1530 | suppress the message). |
| 1529 | |||
| 1530 | @findex lisp-interaction-mode | ||
| 1531 | All other commands in Lisp Interaction mode are the same as in Emacs | ||
| 1532 | Lisp mode. You can enable Lisp Interaction mode by typing @kbd{M-x | ||
| 1533 | lisp-interaction-mode}. | ||
| 1534 | 1531 | ||
| 1535 | @findex ielm | 1532 | @findex ielm |
| 1536 | An alternative way of evaluating Emacs Lisp expressions interactively | 1533 | An alternative way of evaluating Emacs Lisp expressions |
| 1537 | is to use Inferior Emacs-Lisp mode, which provides an interface rather | 1534 | interactively is to use Inferior Emacs Lisp mode, which provides an |
| 1538 | like Shell mode (@pxref{Shell Mode}) for evaluating Emacs Lisp | 1535 | interface rather like Shell mode (@pxref{Shell Mode}) for evaluating |
| 1539 | expressions. Type @kbd{M-x ielm} to create an @samp{*ielm*} buffer | 1536 | Emacs Lisp expressions. Type @kbd{M-x ielm} to create an |
| 1540 | which uses this mode. For more information see that command's | 1537 | @samp{*ielm*} buffer which uses this mode. For more information, see |
| 1541 | documentation. | 1538 | that command's documentation. |
| 1542 | 1539 | ||
| 1543 | @node External Lisp | 1540 | @node External Lisp |
| 1544 | @section Running an External Lisp | 1541 | @section Running an External Lisp |
| 1542 | @cindex Lisp mode | ||
| 1543 | @cindex mode, Lisp | ||
| 1544 | @cindex Common Lisp | ||
| 1545 | 1545 | ||
| 1546 | Emacs has facilities for running programs in other Lisp systems. You can | 1546 | Lisp mode is the major mode for editing programs written in |
| 1547 | run a Lisp process as an inferior of Emacs, and pass expressions to it to | 1547 | general-purpose Lisp dialects, such as Common Lisp. Its mode command |
| 1548 | be evaluated. You can also pass changed function definitions directly from | 1548 | is @kbd{M-x lisp-mode}. Emacs uses Lisp mode automatically for files |
| 1549 | the Emacs buffers in which you edit the Lisp programs to the inferior Lisp | 1549 | whose names end in @file{.l}, @file{.lsp}, or @file{.lisp}. |
| 1550 | process. | ||
| 1551 | 1550 | ||
| 1552 | @findex run-lisp | 1551 | @findex run-lisp |
| 1553 | @vindex inferior-lisp-program | 1552 | @vindex inferior-lisp-program |
| 1554 | @kindex C-x C-z | 1553 | @kindex C-x C-z |
| 1555 | To run an inferior Lisp process, type @kbd{M-x run-lisp}. This runs | 1554 | You can run an external Lisp session as a subprocess or |
| 1556 | the program named @code{lisp}, the same program you would run by typing | 1555 | @dfn{inferior process} of Emacs, and pass expressions to it to be |
| 1557 | @code{lisp} as a shell command, with both input and output going through | 1556 | evaluated. To begin an external Lisp session, type @kbd{M-x |
| 1558 | an Emacs buffer named @samp{*lisp*}. That is to say, any ``terminal | 1557 | run-lisp}. This runs the program named @command{lisp}, and sets it up |
| 1559 | output'' from Lisp will go into the buffer, advancing point, and any | 1558 | so that both input and output go through an Emacs buffer named |
| 1560 | ``terminal input'' for Lisp comes from text in the buffer. (You can | 1559 | @samp{*inferior-lisp*}. To change the name of the Lisp program run by |
| 1561 | change the name of the Lisp executable file by setting the variable | 1560 | @kbd{M-x run-lisp}, change the variable @code{inferior-lisp-program}. |
| 1562 | @code{inferior-lisp-program}.) | 1561 | |
| 1563 | 1562 | The major mode for the @samp{*lisp*} buffer is Inferior Lisp mode, | |
| 1564 | To give input to Lisp, go to the end of the buffer and type the input, | 1563 | which combines the characteristics of Lisp mode and Shell mode |
| 1565 | terminated by @key{RET}. The @samp{*lisp*} buffer is in Inferior Lisp | 1564 | (@pxref{Shell Mode}). To send input to the Lisp session, go to the |
| 1566 | mode, which combines the special characteristics of Lisp mode with most | 1565 | end of the @samp{*lisp*} buffer and type the input, followed by |
| 1567 | of the features of Shell mode (@pxref{Shell Mode}). The definition of | 1566 | @key{RET}. Terminal output from the Lisp session is automatically |
| 1568 | @key{RET} to send a line to a subprocess is one of the features of Shell | 1567 | inserted in the buffer. |
| 1569 | mode. | ||
| 1570 | |||
| 1571 | @findex lisp-mode | ||
| 1572 | For the source files of programs to run in external Lisps, use Lisp | ||
| 1573 | mode. You can switch to this mode with @kbd{M-x lisp-mode}, and it is | ||
| 1574 | used automatically for files whose names end in @file{.l}, | ||
| 1575 | @file{.lsp}, or @file{.lisp}. | ||
| 1576 | 1568 | ||
| 1577 | @kindex C-M-x @r{(Lisp mode)} | 1569 | @kindex C-M-x @r{(Lisp mode)} |
| 1578 | @findex lisp-eval-defun | 1570 | @findex lisp-eval-defun |
| 1579 | When you edit a function in a Lisp program you are running, the easiest | 1571 | When you edit a Lisp program in Lisp mode, you can type @kbd{C-M-x} |
| 1580 | way to send the changed definition to the inferior Lisp process is the key | 1572 | (@code{lisp-eval-defun}) to send an expression from the Lisp mode |
| 1581 | @kbd{C-M-x}. In Lisp mode, this runs the function @code{lisp-eval-defun}, | 1573 | buffer to a Lisp session that you had started with @kbd{M-x run-lisp}. |
| 1582 | which finds the defun around or following point and sends it as input to | 1574 | The expression sent is the top-level Lisp expression at or following |
| 1583 | the Lisp process. (Emacs can send input to any inferior process regardless | 1575 | point. The resulting value goes as usual into the |
| 1584 | of what buffer is current.) | 1576 | @samp{*inferior-lisp*} buffer. Note that the effect of @kbd{C-M-x} in |
| 1585 | 1577 | Lisp mode is thus very similar to its effect in Emacs Lisp mode | |
| 1586 | Contrast the meanings of @kbd{C-M-x} in Lisp mode (for editing | 1578 | (@pxref{Lisp Eval}), except that the expression is sent to a different |
| 1587 | programs to be run in another Lisp system) and Emacs-Lisp mode (for | 1579 | Lisp environment instead of being evaluated in Emacs. |
| 1588 | editing Lisp programs to be run in Emacs; see @pxref{Lisp Eval}): in | 1580 | |
| 1589 | both modes it has the effect of installing the function definition | 1581 | @findex scheme-mode |
| 1590 | that point is in, but the way of doing so is different according to | 1582 | @findex run-scheme |
| 1591 | where the relevant Lisp environment is found. | 1583 | @cindex Scheme mode |
| 1584 | @cindex mode, Scheme | ||
| 1585 | @kindex C-M-x @r{(Scheme mode)} | ||
| 1586 | The facilities for editing Scheme code, and for sending expressions | ||
| 1587 | to a Scheme subprocess, are very similar. Scheme source files are | ||
| 1588 | edited in Scheme mode, which can be explicitly enabled with @kbd{M-x | ||
| 1589 | scheme-mode}. You can initiate a Scheme session by typing @kbd{M-x | ||
| 1590 | run-scheme} (the buffer for interacting with Scheme is named | ||
| 1591 | @samp{*scheme*}), and send expressions to it by typing @kbd{C-M-x}. | ||
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi index 8ecf0982e46..2cb02feee60 100644 --- a/doc/emacs/emacs.texi +++ b/doc/emacs/emacs.texi | |||
| @@ -699,7 +699,7 @@ Compiling and Testing Programs | |||
| 699 | * Executing Lisp:: Various modes for editing Lisp programs, | 699 | * Executing Lisp:: Various modes for editing Lisp programs, |
| 700 | with different facilities for running | 700 | with different facilities for running |
| 701 | the Lisp programs. | 701 | the Lisp programs. |
| 702 | * Lisp Libraries:: Creating Lisp programs to run in Emacs. | 702 | * Lisp Libraries:: How Lisp programs are loaded into Emacs. |
| 703 | * Lisp Eval:: Executing a single Lisp expression in Emacs. | 703 | * Lisp Eval:: Executing a single Lisp expression in Emacs. |
| 704 | * Lisp Interaction:: Executing Lisp in an Emacs buffer. | 704 | * Lisp Interaction:: Executing Lisp in an Emacs buffer. |
| 705 | * External Lisp:: Communicating through Emacs with a separate Lisp. | 705 | * External Lisp:: Communicating through Emacs with a separate Lisp. |
| @@ -570,6 +570,7 @@ region (or with the left margin if there is no previous line). | |||
| 570 | ** browse-url has a new variable `browse-url-mailto-function' | 570 | ** browse-url has a new variable `browse-url-mailto-function' |
| 571 | specifies how mailto: URLs are handled. The default is `browse-url-mail'. | 571 | specifies how mailto: URLs are handled. The default is `browse-url-mail'. |
| 572 | 572 | ||
| 573 | --- | ||
| 573 | ** BibTeX mode | 574 | ** BibTeX mode |
| 574 | 575 | ||
| 575 | *** BibTeX mode now supports biblatex. | 576 | *** BibTeX mode now supports biblatex. |
| @@ -625,7 +626,7 @@ view-diary-entries, list-diary-entries, show-all-diary-entries | |||
| 625 | ** comint and modes derived from it use the generic completion code. | 626 | ** comint and modes derived from it use the generic completion code. |
| 626 | 627 | ||
| 627 | ** Compilation mode | 628 | ** Compilation mode |
| 628 | 629 | --- | |
| 629 | *** Compilation mode can be used without font-lock-mode. | 630 | *** Compilation mode can be used without font-lock-mode. |
| 630 | `compilation-parse-errors-function' is now obsolete. | 631 | `compilation-parse-errors-function' is now obsolete. |
| 631 | 632 | ||