home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / elisp / elisp-10 < prev    next >
Encoding:
GNU Info File  |  1993-05-31  |  48.7 KB  |  1,204 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.  
  4.    This is edition 2.0 of the GNU Emacs Lisp Reference Manual, for
  5. Emacs Version 19.
  6.  
  7.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  8. Cambridge, MA 02139 USA
  9.  
  10.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided that
  18. the entire resulting derived work is distributed under the terms of a
  19. permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that this permission notice may be stated in a
  24. translation approved by the Foundation.
  25.  
  26. 
  27. File: elisp,  Node: Features,  Next: Unloading,  Prev: Repeated Loading,  Up: Loading
  28.  
  29. Features
  30. ========
  31.  
  32.    `provide' and `require' are an alternative to `autoload' for loading
  33. files automatically.  They work in terms of named "features".
  34. Autoloading is triggered by calling a specific function, but a feature
  35. is loaded the first time another program asks for it by name.
  36.  
  37.    The use of named features simplifies the task of determining whether
  38. required definitions have been defined.  A feature name is a symbol that
  39. stands for a collection of functions, variables, etc.  A program that
  40. needs the collection may ensure that they are defined by "requiring"
  41. the feature.  If the file that contains the feature has not yet been
  42. loaded, then it will be loaded (or an error will be signaled if it
  43. cannot be loaded).  The file thus loaded must "provide" the required
  44. feature or an error will be signaled.
  45.  
  46.    To require the presence of a feature, call `require' with the
  47. feature name as argument.  `require' looks in the global variable
  48. `features' to see whether the desired feature has been provided
  49. already.  If not, it loads the feature from the appropriate file.  This
  50. file should call `provide' at the top-level to add the feature to
  51. `features'.
  52.  
  53.    Features are normally named after the files they are provided in so
  54. that `require' need not be given the file name.
  55.  
  56.    For example, in `emacs/lisp/prolog.el', the definition for
  57. `run-prolog' includes the following code:
  58.  
  59.      (defun run-prolog ()
  60.        "Run an inferior Prolog process,\
  61.       input and output via buffer *prolog*."
  62.        (interactive)
  63.        (require 'comint)
  64.        (switch-to-buffer (make-comint "prolog" prolog-program-name))
  65.        (inferior-prolog-mode))
  66.  
  67. The expression `(require 'shell)' loads the file `shell.el' if it has
  68. not yet been loaded.  This ensures that `make-shell' is defined.
  69.  
  70.    The `shell.el' file contains the following top-level expression:
  71.  
  72.      (provide 'shell)
  73.  
  74. This adds `shell' to the global `features' list when the `shell' file
  75. is loaded, so that `(require 'shell)' will henceforth know that nothing
  76. needs to be done.
  77.  
  78.    When `require' is used at top-level in a file, it takes effect if
  79. you byte-compile that file (*note Byte Compilation::.).  This is in case
  80. the required package contains macros that the byte compiler must know
  81. about.
  82.  
  83.    Although top-level calls to `require' are evaluated during byte
  84. compilation, `provide' calls are not.  Therefore, you can ensure that a
  85. file of definitions is loaded before it is byte-compiled by including a
  86. `provide' followed by a `require' for the same feature, as in the
  87. following example.
  88.  
  89.      (provide 'my-feature)  ; Ignored by byte compiler,
  90.                             ;   evaluated by `load'.
  91.      (require 'my-feature)  ; Evaluated by byte compiler.
  92.  
  93.  - Function: provide FEATURE
  94.      This function announces that FEATURE is now loaded, or being
  95.      loaded, into the current Emacs session.  This means that the
  96.      facilities associated with FEATURE are or will be available for
  97.      other Lisp programs.
  98.  
  99.      The direct effect of calling `provide' is to add FEATURE to the
  100.      front of the list `features' if it is not already in the list.
  101.      The argument FEATURE must be a symbol.  `provide' returns FEATURE.
  102.  
  103.           features
  104.                => (bar bish)
  105.           
  106.           (provide 'foo)
  107.                => foo
  108.           features
  109.                => (foo bar bish)
  110.  
  111.      During autoloading, if the file is not completely loaded (due to an
  112.      error in the evaluation of the contents) any function definitions
  113.      or `provide' calls that occurred during the load are undone.
  114.      *Note Autoload::.
  115.  
  116.  - Function: require FEATURE &optional FILENAME
  117.      This function checks whether FEATURE is present in the current
  118.      Emacs session (using `(featurep FEATURE)'; see below).  If it is
  119.      not, then `require' loads FILENAME with `load'.  If FILENAME is
  120.      not supplied, then the name of the symbol FEATURE is used as the
  121.      file name to load.
  122.  
  123.      If FEATURE is not provided after the file has been loaded, Emacs
  124.      will signal the error `error' (with data `Required feature FEATURE
  125.      was not provided').
  126.  
  127.  - Function: featurep FEATURE
  128.      This function returns `t' if FEATURE has been provided in the
  129.      current Emacs session (i.e., FEATURE is a member of `features'.)
  130.  
  131.  - Variable: features
  132.      The value of this variable is a list of symbols that are the
  133.      features loaded in the current Emacs session.  Each symbol was put
  134.      in this list with a call to `provide'.  The order of the elements
  135.      in the `features' list is not significant.
  136.  
  137. 
  138. File: elisp,  Node: Unloading,  Next: Hooks for Loading,  Prev: Features,  Up: Loading
  139.  
  140. Unloading
  141. =========
  142.  
  143.    You can discard the functions and variables loaded by a library to
  144. reclaim memory for other Lisp objects.  To do this, use the function
  145. `unload-feature':
  146.  
  147.  - Command: unload-feature FEATURE
  148.      This command unloads the library that provided feature FEATURE.
  149.      It undefines all functions and variables defined with `defvar',
  150.      `defmacro', `defconst', `defsubst' and `defalias' by the library
  151.      which provided feature FEATURE.  It then restores any autoloads
  152.      associated with those symbols.
  153.  
  154.    The `unload-feature' function is written in Lisp; its actions are
  155. based on the variable `load-history'.
  156.  
  157.  - Variable: load-history
  158.      This variable's value is an alist connecting library names with the
  159.      names of functions and variables they define, the features they
  160.      provide, and the features they require.
  161.  
  162.      Each element is a list and describes one library.  The CAR of the
  163.      list is the name of the library, as a string.  The rest of the
  164.      list is composed of these kinds of objects:
  165.  
  166.         * Symbols, which were defined as functions or variables.
  167.  
  168.         * Lists of the form `(require . FEATURE)' indicating the
  169.           features that are required.
  170.  
  171.         * Lists of the form `(provide . FEATURE)' indicating the
  172.           features that are provided.
  173.  
  174.      The value of `load-history' may have one element whose CAR is
  175.      `nil'.  This element describes definitions made with `eval-buffer'
  176.      on a buffer that is not visiting a file.
  177.  
  178.    The command `eval-region' updates `load-history', but does so by
  179. adding the symbols defined to the element for the file being visited,
  180. rather than replacing that element.
  181.  
  182. 
  183. File: elisp,  Node: Hooks for Loading,  Prev: Unloading,  Up: Loading
  184.  
  185. Hooks for Loading
  186. =================
  187.  
  188.    You can ask for code to be executed if and when a particular library
  189. is loaded, by calling `eval-after-load'.
  190.  
  191.  - Function: eval-after-load LIBRARY FORM
  192.      This function arranges to evaluate FORM at the end of loading the
  193.      library LIBRARY, if and when LIBRARY is loaded.
  194.  
  195.      The library name LIBRARY must exactly match the argument of
  196.      `load'.  To get the proper results when an installed library is
  197.      found by searching `load-path', you should not include any
  198.      directory names in LIBRARY.
  199.  
  200.      An error in FORM does not undo the load, but does prevent
  201.      execution of the rest of FORM.
  202.  
  203.  - Variable: after-load-alist
  204.      An alist of expressions to evaluate if and when particular
  205.      libraries are loaded.  Each element looks like this:
  206.  
  207.           (FILENAME FORMS...)
  208.  
  209.      The function `load' checks `after-load-alist' in order to
  210.      implement `eval-after-load'.
  211.  
  212. 
  213. File: elisp,  Node: Byte Compilation,  Next: Debugging,  Prev: Loading,  Up: Top
  214.  
  215. Byte Compilation
  216. ****************
  217.  
  218.    GNU Emacs Lisp has a "compiler" that translates functions written in
  219. Lisp into a special representation called "byte-code" that can be
  220. executed more efficiently.  The compiler replaces Lisp function
  221. definitions with byte-code.  When a byte-code function is called, its
  222. definition is evaluated by the "byte-code interpreter".
  223.  
  224.    Because the byte-compiled code is evaluated by the byte-code
  225. interpreter, instead of being executed directly by the machine's
  226. hardware (as true compiled code is), byte-code is completely
  227. transportable from machine to machine without recompilation.  It is not,
  228. however, as fast as true compiled code.
  229.  
  230.    In general, any version of Emacs can run byte-compiled code produced
  231. by recent earlier versions of Emacs, but the reverse is not true.  In
  232. particular, if you compile a program with Emacs 18, you can run the
  233. compiled code in Emacs 19, but not vice versa.
  234.  
  235.    *Note Compilation Errors::, for how to investigate errors occurring
  236. in byte compilation.
  237.  
  238. * Menu:
  239.  
  240. * Compilation Functions::       Byte compilation functions.
  241. * Eval During Compile::      Code to be evaluated when you compile.
  242. * Byte-Code Objects::        The data type used for byte-compiled functions.
  243. * Disassembly::                 Disassembling byte-code; how to read byte-code.
  244.  
  245. 
  246. File: elisp,  Node: Compilation Functions,  Next: Eval During Compile,  Up: Byte Compilation
  247.  
  248. The Compilation Functions
  249. =========================
  250.  
  251.    You can byte-compile an individual function or macro definition with
  252. the `byte-compile' function.  You can compile a whole file with
  253. `byte-compile-file', or several files with `byte-recompile-directory'
  254. or `batch-byte-compile'.
  255.  
  256.    When you run the byte compiler, you may get warnings in a buffer
  257. called `*Compile-Log*'.  These report usage in your program that
  258. suggest a problem, but are not necessarily erroneous.
  259.  
  260.    Be careful when byte-compiling code that uses macros.  Macro calls
  261. are expanded when they are compiled, so the macros must already be
  262. defined for proper compilation.  For more details, see *Note Compiling
  263. Macros::.
  264.  
  265.    While byte-compiling a file, any `require' calls at top-level are
  266. executed.  One way to ensure that necessary macro definitions are
  267. available during compilation is to require the file that defines them.
  268. *Note Features::.
  269.  
  270.    A byte-compiled function is not as efficient as a primitive function
  271. written in C, but runs much faster than the version written in Lisp.
  272. For a rough comparison, consider the example below:
  273.  
  274.      (defun silly-loop (n)
  275.        "Return time before and after N iterations of a loop."
  276.        (let ((t1 (current-time-string)))
  277.          (while (> (setq n (1- n))
  278.                    0))
  279.          (list t1 (current-time-string))))
  280.      => silly-loop
  281.      
  282.      (silly-loop 100000)
  283.      => ("Thu Jan 12 20:18:38 1989"
  284.          "Thu Jan 12 20:19:29 1989")  ; 51 seconds
  285.      
  286.      (byte-compile 'silly-loop)
  287.      => [Compiled code not shown]
  288.      
  289.      (silly-loop 100000)
  290.      => ("Thu Jan 12 20:21:04 1989"
  291.          "Thu Jan 12 20:21:17 1989")  ; 13 seconds
  292.  
  293.    In this example, the interpreted code required 51 seconds to run,
  294. whereas the byte-compiled code required 13 seconds.  These results are
  295. representative, but actual results will vary greatly.
  296.  
  297.  - Function: byte-compile SYMBOL
  298.      This function byte-compiles the function definition of SYMBOL,
  299.      replacing the previous definition with the compiled one.  The
  300.      function definition of SYMBOL must be the actual code for the
  301.      function; i.e., the compiler does not follow indirection to
  302.      another symbol.  `byte-compile' does not compile macros.
  303.      `byte-compile' returns the new, compiled definition of SYMBOL.
  304.  
  305.           (defun factorial (integer)
  306.             "Compute factorial of INTEGER."
  307.             (if (= 1 integer) 1
  308.               (* integer (factorial (1- integer)))))
  309.                => factorial
  310.           
  311.           (byte-compile 'factorial)
  312.                =>
  313.           #[(integer)
  314.             "^H\301U\203^H^@\301\207\302^H\303^HS!\"\207"
  315.             [integer 1 * factorial]
  316.             4 "Compute factorial of INTEGER."]
  317.  
  318.      The result is a compiled function object.  The string it contains
  319.      is the actual byte-code; each character in it is an instruction.
  320.      The vector contains all the constants, variable names and function
  321.      names used by the function, except for certain primitives that are
  322.      coded as special instructions.
  323.  
  324.  - Command: compile-defun
  325.      This command reads the defun containing point, compiles it, and
  326.      evaluates the result.  If you use this on a defun that is actually
  327.      a function definition, the effect is to install a compiled version
  328.      of that function.
  329.  
  330.  - Command: byte-compile-file FILENAME
  331.      This function compiles a file of Lisp code named FILENAME into a
  332.      file of byte-code.  The output file's name is made by appending
  333.      `c' to the end of FILENAME.
  334.  
  335.      Compilation works by reading the input file one form at a time.
  336.      If it is a definition of a function or macro, the compiled
  337.      function or macro definition is written out.  Other forms are
  338.      batched together, then each batch is compiled, and written so that
  339.      its compiled code will be executed when the file is read.  All
  340.      comments are discarded when the input file is read.
  341.  
  342.      This command returns `t'.  When called interactively, it prompts
  343.      for the file name.
  344.  
  345.           % ls -l push*
  346.           -rw-r--r--  1 lewis     791 Oct  5 20:31 push.el
  347.           
  348.           (byte-compile-file "~/emacs/push.el")
  349.                => t
  350.           
  351.           % ls -l push*
  352.           -rw-r--r--  1 lewis     791 Oct  5 20:31 push.el
  353.           -rw-rw-rw-  1 lewis     638 Oct  8 20:25 push.elc
  354.  
  355.  - Command: byte-recompile-directory DIRECTORY FLAG
  356.      This function recompiles every `.el' file in DIRECTORY that needs
  357.      recompilation.  A file needs recompilation if a `.elc' file exists
  358.      but is older than the `.el' file.
  359.  
  360.      If a `.el' file exists, but there is no corresponding `.elc' file,
  361.      then FLAG is examined.  If it is `nil', the file is ignored.  If
  362.      it is non-`nil', the user is asked whether the file should be
  363.      compiled.
  364.  
  365.      The returned value of this command is unpredictable.
  366.  
  367.  - Function: batch-byte-compile
  368.      This function runs `byte-compile-file' on the files remaining on
  369.      the command line.  This function must be used only in a batch
  370.      execution of Emacs, as it kills Emacs on completion.  An error in
  371.      one file does not prevent processing of subsequent files.  (The
  372.      file which gets the error will not, of course, produce any
  373.      compiled code.)
  374.  
  375.           % emacs -batch -f batch-byte-compile *.el
  376.  
  377.  - Function: byte-code CODE-STRING DATA-VECTOR MAX-STACK
  378.      This function actually interprets byte-code.  A byte-compiled
  379.      function is actually defined with a body that calls `byte-code'.
  380.      Don't call this function yourself.  Only the byte compiler knows
  381.      how to generate valid calls to this function.
  382.  
  383.      In newer Emacs versions (19 and up), byte-code is usually executed
  384.      as part of a compiled function object, and only rarely as part of
  385.      a call to `byte-code'.
  386.  
  387. 
  388. File: elisp,  Node: Eval During Compile,  Next: Byte-Code Objects,  Prev: Compilation Functions,  Up: Byte Compilation
  389.  
  390. Evaluation During Compilation
  391. =============================
  392.  
  393.    These features permit you to write code to be evaluated during
  394. compilation of a program.
  395.  
  396.  - Special Form: eval-and-compile BODY
  397.      This form marks BODY to be evaluated both when you compile the
  398.      containing code and when you run it (whether compiled or not).
  399.  
  400.      You can get a similar result by putting BODY in a separate file
  401.      and referring to that file with `require'.  Using `require' is
  402.      preferable if there is a substantial amount of code to be executed
  403.      in this way.
  404.  
  405.  - Special Form: eval-when-compile BODY
  406.      This form marks BODY to be evaluated at compile time *only*.  The
  407.      result of evaluation by the compiler becomes a constant which
  408.      appears in the compiled program.  When the program is interpreted,
  409.      not compiled at all, BODY is evaluated normally.
  410.  
  411.      At top-level, this is analogous to the Common Lisp idiom
  412.      `(eval-when (compile) ...)'.  Elsewhere, the Common Lisp `#.'
  413.      reader macro (but not when interpreting) is closer to what
  414.      `eval-when-compile' does.
  415.  
  416. 
  417. File: elisp,  Node: Byte-Code Objects,  Next: Disassembly,  Prev: Eval During Compile,  Up: Byte Compilation
  418.  
  419. Byte-Code Objects
  420. =================
  421.  
  422.    Byte-compiled functions have a special data type: they are
  423. "byte-code function objects".
  424.  
  425.    Internally, a byte-code function object is much like a vector;
  426. however, the evaluator handles this data type specially when it appears
  427. as a function to be called.  The printed representation for a byte-code
  428. function object is like that for a vector, with an additional `#'
  429. before the opening `['.
  430.  
  431.    In Emacs version 18, there was no byte-code function object data
  432. type; compiled functions used the function `byte-code' to run the byte
  433. code.
  434.  
  435.    A byte-code function object must have at least four elements; there
  436. is no maximum number, but only the first six elements are actually used.
  437. They are:
  438.  
  439. ARGLIST
  440.      The list of argument symbols.
  441.  
  442. BYTE-CODE
  443.      The string containing the byte-code instructions.
  444.  
  445. CONSTANTS
  446.      The vector of constants referenced by the byte code.
  447.  
  448. STACKSIZE
  449.      The maximum stack size this function needs.
  450.  
  451. DOCSTRING
  452.      The documentation string (if any); otherwise, `nil'.  For functions
  453.      preloaded before Emacs is dumped, this is usually an integer which
  454.      is an index into the `DOC' file; use `documentation' to convert
  455.      this into a string (*note Accessing Documentation::.).
  456.  
  457. INTERACTIVE
  458.      The interactive spec (if any).  This can be a string or a Lisp
  459.      expression.  It is `nil' for a function that isn't interactive.
  460.  
  461.    Here's an example of a byte-code function object, in printed
  462. representation.  It is the definition of the command `backward-sexp'.
  463.  
  464.      #[(&optional arg)
  465.        "^H\204^F^@\301^P\302^H[!\207"
  466.        [arg 1 forward-sexp]
  467.        2
  468.        254435
  469.        "p"]
  470.  
  471.    The primitive way to create a byte-code object is with
  472. `make-byte-code':
  473.  
  474.  - Function: make-byte-code &rest ELEMENTS
  475.      This function constructs and returns a byte-code function object
  476.      with ELEMENTS as its elements.
  477.  
  478.    You should not try to come up with the elements for a byte-code
  479. function yourself, because if they are inconsistent, Emacs may crash
  480. when you call the function.  Always leave it to the byte-compiler to
  481. create these objects; it, we hope, always makes the elements consistent.
  482.  
  483.    You can access the elements of a byte-code object using `aref'; you
  484. can also use `vconcat' to create a vector with the same elements.
  485.  
  486. 
  487. File: elisp,  Node: Disassembly,  Prev: Byte-Code Objects,  Up: Byte Compilation
  488.  
  489. Disassembled Byte-Code
  490. ======================
  491.  
  492.    People do not write byte-code; that job is left to the byte compiler.
  493. But we provide a disassembler to satisfy a cat-like curiosity.  The
  494. disassembler converts the byte-compiled code into humanly readable form.
  495.  
  496.    The byte-code interpreter is implemented as a simple stack machine.
  497. Values get stored by being pushed onto the stack, and are popped off and
  498. manipulated, the results being pushed back onto the stack.  When a
  499. function returns, the top of the stack is popped and returned as the
  500. value of the function.
  501.  
  502.    In addition to the stack, values used during byte-code execution can
  503. be stored in ordinary Lisp variables.  Variable values can be pushed
  504. onto the stack, and variables can be set by popping the stack.
  505.  
  506.  - Command: disassemble OBJECT &optional STREAM
  507.      This function prints the disassembled code for OBJECT.  If STREAM
  508.      is supplied, then output goes there.  Otherwise, the disassembled
  509.      code is printed to the stream `standard-output'.  The argument
  510.      OBJECT can be a function name or a lambda expression.
  511.  
  512.      As a special exception, if this function is used interactively, it
  513.      outputs to a buffer named `*Disassemble*'.
  514.  
  515.    Here are two examples of using the `disassemble' function.  We have
  516. added explanatory comments to help you relate the byte-code to the Lisp
  517. source; these do not appear in the output of `disassemble'.  These
  518. examples show unoptimized byte-code.  Nowadays byte-code is usually
  519. optimized, but we did not want to rewrite these examples, since they
  520. still serve their purpose.
  521.  
  522.      (defun factorial (integer)
  523.        "Compute factorial of an integer."
  524.        (if (= 1 integer) 1
  525.          (* integer (factorial (1- integer)))))
  526.           => factorial
  527.      
  528.      (factorial 4)
  529.           => 24
  530.      
  531.      (disassemble 'factorial)
  532.           -| byte-code for factorial:
  533.       doc: Compute factorial of an integer.
  534.       args: (integer)
  535.      
  536.      0   constant 1              ; Push 1 onto stack.
  537.      
  538.      1   varref   integer        ; Get value of `integer'
  539.                                  ;   from the environment
  540.                                  ;   and push the value
  541.                                  ;   onto the stack.
  542.      
  543.      2   eqlsign                 ; Pop top two values off stack,
  544.                                  ;   compare them,
  545.                                  ;   and push result onto stack.
  546.      
  547.      3   goto-if-nil 10          ; Pop and test top of stack;
  548.                                  ;   if `nil', go to 10,
  549.                                  ;   else continue.
  550.      
  551.      6   constant 1              ; Push 1 onto top of stack.
  552.      
  553.      7   goto     17             ; Go to 17 (in this case, 1 will be
  554.                                  ;   returned by the function).
  555.      
  556.      10  constant *              ; Push symbol `*' onto stack.
  557.      
  558.      11  varref   integer        ; Push value of `integer' onto stack.
  559.      
  560.      12  constant factorial      ; Push `factorial' onto stack.
  561.      
  562.      13  varref   integer        ; Push value of `integer' onto stack.
  563.      
  564.      14  sub1                    ; Pop `integer', decrement value,
  565.                                  ;   push new value onto stack.
  566.      
  567.                                  ; Stack now contains:
  568.                                  ;   - decremented value of `integer'
  569.                                  ;   - `factorial'
  570.                                  ;   - value of `integer'
  571.                                  ;   - `*'
  572.      
  573.      15  call     1              ; Call function `factorial' using
  574.                                  ;   the first (i.e., the top) element
  575.                                  ;   of the stack as the argument;
  576.                                  ;   push returned value onto stack.
  577.      
  578.                                  ; Stack now contains:
  579.                                  ;   - result of result of recursive
  580.                                  ;        call to `factorial'
  581.                                  ;   - value of `integer'
  582.                                  ;   - `*'
  583.      
  584.      16  call     2              ; Using the first two
  585.                                  ;   (i.e., the top two)
  586.                                  ;   elements of the stack
  587.                                  ;   as arguments,
  588.                                  ;   call the function `*',
  589.                                  ;   pushing the result onto the stack.
  590.      
  591.      17  return                  ; Return the top element
  592.                                  ;   of the stack.
  593.           => nil
  594.  
  595.    The `silly-loop' function is somewhat more complex:
  596.  
  597.      (defun silly-loop (n)
  598.        "Return time before and after N iterations of a loop."
  599.        (let ((t1 (current-time-string)))
  600.          (while (> (setq n (1- n))
  601.                    0))
  602.          (list t1 (current-time-string))))
  603.           => silly-loop
  604.      
  605.      (disassemble 'silly-loop)
  606.           -| byte-code for silly-loop:
  607.       doc: Return time before and after N iterations of a loop.
  608.       args: (n)
  609.      
  610.      0   constant current-time-string  ; Push
  611.                                        ;   `current-time-string'
  612.                                        ;   onto top of stack.
  613.      
  614.      1   call     0              ; Call `current-time-string'
  615.                                  ;    with no argument,
  616.                                  ;    pushing result onto stack.
  617.      
  618.      2   varbind  t1             ; Pop stack and bind `t1'
  619.                                  ;   to popped value.
  620.      
  621.      3   varref   n              ; Get value of `n' from
  622.                                  ;   the environment and push
  623.                                  ;   the value onto the stack.
  624.      
  625.      4   sub1                    ; Subtract 1 from top of stack.
  626.      
  627.      5   dup                     ; Duplicate the top of the stack;
  628.                                  ;   i.e. copy the top of
  629.                                  ;   the stack and push the
  630.                                  ;   copy onto the stack.
  631.      
  632.      6   varset   n              ; Pop the top of the stack,
  633.                                  ;   and bind `n' to the value.
  634.      
  635.                                  ; In effect, the sequence `dup varset'
  636.                                  ;   copies the top of the stack
  637.                                  ;   into the value of `n'
  638.                                  ;   without popping it.
  639.      
  640.      7   constant 0              ; Push 0 onto stack.
  641.      
  642.      8   gtr                     ; Pop top two values off stack,
  643.                                  ;   test if N is greater than 0
  644.                                  ;   and push result onto stack.
  645.      
  646.      9   goto-if-nil-else-pop 17 ; Goto 17 if `n' > 0
  647.                                  ;   else pop top of stack
  648.                                  ;   and continue
  649.                                  ;   (this exits the while loop).
  650.      
  651.      12  constant nil            ; Push `nil' onto stack
  652.                                  ;   (this is the body of the loop).
  653.      
  654.      13  discard                 ; Discard result of the body
  655.                                  ;   of the loop (a while loop
  656.                                  ;   is always evaluated for
  657.                                  ;   its side effects).
  658.      
  659.      14  goto     3              ; Jump back to beginning
  660.                                  ;   of while loop.
  661.      
  662.      17  discard                 ; Discard result of while loop
  663.                                  ;   by popping top of stack.
  664.      
  665.      18  varref   t1             ; Push value of `t1' onto stack.
  666.      
  667.      19  constant current-time-string  ; Push
  668.                                        ;   `current-time-string'
  669.                                        ;   onto top of stack.
  670.      
  671.      20  call     0              ; Call `current-time-string' again.
  672.      
  673.      21  list2                   ; Pop top two elements off stack,
  674.                                  ;   create a list of them,
  675.                                  ;   and push list onto stack.
  676.      
  677.      22  unbind   1              ; Unbind `t1' in local environment.
  678.      
  679.      23  return                  ; Return value of the top of stack.
  680.      
  681.           => nil
  682.  
  683. 
  684. File: elisp,  Node: Debugging,  Next: Streams,  Prev: Byte Compilation,  Up: Top
  685.  
  686. Debugging Lisp Programs
  687. ***********************
  688.  
  689.    There are three ways to investigate a problem in an Emacs Lisp
  690. program, depending on what you are doing with the program when the
  691. problem appears.
  692.  
  693.    * If the problem occurs when you run the program, you can use the
  694.      Lisp debugger to investigate what is happening during execution.
  695.  
  696.    * If the problem is syntactic, so that Lisp cannot even read the
  697.      program, you can use the Emacs facilities for editing Lisp to
  698.      localize it.
  699.  
  700.    * If the problem occurs when trying to compile the program with the
  701.      byte compiler, you need to know how to examine the compiler's
  702.      input buffer.
  703.  
  704. * Menu:
  705.  
  706. * Debugger::            How the Emacs Lisp debugger is implemented.
  707. * Syntax Errors::       How to find syntax errors.
  708. * Compilation Errors::  How to find errors that show up in byte compilation.
  709. * Edebug::        A source-level Emacs Lisp debugger.
  710.  
  711.    Another useful debugging tool is a dribble file.  When a dribble file
  712. is open, Emacs copies all keyboard input characters to that file.
  713. Afterward, you can examine the file to find out what input was used.
  714. *Note Terminal Input::.
  715.  
  716.    For debugging problems in terminal descriptions, the
  717. `open-termscript' function can be useful.  *Note Terminal Output::.
  718.  
  719. 
  720. File: elisp,  Node: Debugger,  Next: Syntax Errors,  Up: Debugging
  721.  
  722. The Lisp Debugger
  723. =================
  724.  
  725.    The "Lisp debugger" provides you with the ability to suspend
  726. evaluation of a form.  While evaluation is suspended (a state that is
  727. commonly known as a "break"), you may examine the run time stack,
  728. examine the values of local or global variables, or change those values.
  729. Since a break is a recursive edit, all the usual editing facilities of
  730. Emacs are available; you can even run programs that will enter the
  731. debugger recursively.  *Note Recursive Editing::.
  732.  
  733. * Menu:
  734.  
  735. * Error Debugging::       Entering the debugger when an error happens.
  736. * Infinite Loops::      Stopping and debugging a program that doesn't exit.
  737. * Function Debugging::    Entering it when a certain function is called.
  738. * Explicit Debug::        Entering it at a certain point in the program.
  739. * Using Debugger::        What the debugger does; what you see while in it.
  740. * Debugger Commands::     Commands used while in the debugger.
  741. * Invoking the Debugger:: How to call the function `debug'.
  742. * Internals of Debugger:: Subroutines of the debugger, and global variables.
  743.  
  744. 
  745. File: elisp,  Node: Error Debugging,  Next: Infinite Loops,  Up: Debugger
  746.  
  747. Entering the Debugger on an Error
  748. ---------------------------------
  749.  
  750.    The most important time to enter the debugger is when a Lisp error
  751. happens.  This allows you to investigate the immediate causes of the
  752. error.
  753.  
  754.    However, entry to the debugger is not a normal consequence of an
  755. error.  Many commands frequently get Lisp errors when invoked in
  756. inappropriate contexts (such as `C-f' at the end of the buffer) and
  757. during ordinary editing it would be very unpleasant to enter the
  758. debugger each time this happens.  If you want errors to enter the
  759. debugger, set the variable `debug-on-error' to non-`nil'.
  760.  
  761.  - User Option: debug-on-error
  762.      This variable determines whether the debugger is called when a
  763.      error is signaled and not handled.  If `debug-on-error' is `t', all
  764.      errors call the debugger.  If it is `nil', none call the debugger.
  765.  
  766.      The value can also be a list of error conditions that should call
  767.      the debugger.  For example, if you set it to the list
  768.      `(void-variable)', then only errors about a variable that has no
  769.      value invoke the debugger.
  770.  
  771. 
  772. File: elisp,  Node: Infinite Loops,  Next: Function Debugging,  Prev: Error Debugging,  Up: Debugger
  773.  
  774. Debugging Infinite Loops
  775. ------------------------
  776.  
  777.    When a program loops infinitely and fails to return, your first
  778. problem is to stop the loop.  On most operating systems, you can do this
  779. with `C-g', which causes quit.
  780.  
  781.    Ordinary quitting gives no information about why the program was
  782. looping.  To get more information, you can set the variable
  783. `debug-on-quit' to non-`nil'.  Quitting with `C-g' is not considered an
  784. error, and `debug-on-error' has no effect on the handling of `C-g'.
  785. Contrariwise, `debug-on-quit' has no effect on errors.
  786.  
  787.    Once you have the debugger running in the middle of the infinite
  788. loop, you can proceed from the debugger using the stepping commands.
  789. If you step through the entire loop, you will probably get enough
  790. information to solve the problem.
  791.  
  792.  - User Option: debug-on-quit
  793.      This variable determines whether the debugger is called when `quit'
  794.      is signaled and not handled.  If `debug-on-quit' is non-`nil',
  795.      then the debugger is called whenever you quit (that is, type
  796.      `C-g').  If `debug-on-quit' is `nil', then the debugger is not
  797.      called when you quit.  *Note Quitting::.
  798.  
  799. 
  800. File: elisp,  Node: Function Debugging,  Next: Explicit Debug,  Prev: Infinite Loops,  Up: Debugger
  801.  
  802. Entering the Debugger on a Function Call
  803. ----------------------------------------
  804.  
  805.    To investigate a problem that happens in the middle of a program, one
  806. useful technique is to cause the debugger to be entered when a certain
  807. function is called.  You can do this to the function in which the
  808. problem occurs, and then step through the function, or you can do this
  809. to a function called shortly before the problem, step quickly over the
  810. call to that function, and then step through its caller.
  811.  
  812.  - Command: debug-on-entry FUNCTION-NAME
  813.      This function requests FUNCTION-NAME to invoke the debugger each
  814.      time it is called.  It works by inserting the form `(debug
  815.      'debug)' into the function definition as the first form.
  816.  
  817.      Any function defined as Lisp code may be set to break on entry,
  818.      regardless of whether it is interpreted code or compiled code.
  819.      Even functions that are commands may be debugged--they will enter
  820.      the debugger when called inside a function, or when called
  821.      interactively (after the reading of the arguments).  Primitive
  822.      functions (i.e., those written in C) may not be debugged.
  823.  
  824.      When `debug-on-entry' is called interactively, it prompts for
  825.      FUNCTION-NAME in the minibuffer.
  826.  
  827.      Caveat: if `debug-on-entry' is called more than once on the same
  828.      function, the second call does nothing.  If you redefine a function
  829.      after using `debug-on-entry' on it, the code to enter the debugger
  830.      is lost.
  831.  
  832.      `debug-on-entry' returns FUNCTION-NAME.
  833.  
  834.           (defun fact (n)
  835.             (if (zerop n) 1
  836.                 (* n (fact (1- n)))))
  837.                => fact
  838.           (debug-on-entry 'fact)
  839.                => fact
  840.           (fact 3)
  841.                => 6
  842.           
  843.           ------ Buffer: *Backtrace* ------
  844.           Entering:
  845.           * fact(3)
  846.             eval-region(4870 4878 t)
  847.             byte-code("...")
  848.             eval-last-sexp(nil)
  849.             (let ...)
  850.             eval-insert-last-sexp(nil)
  851.           * call-interactively(eval-insert-last-sexp)
  852.           ------ Buffer: *Backtrace* ------
  853.           
  854.           (symbol-function 'fact)
  855.                => (lambda (n)
  856.                     (debug (quote debug))
  857.                     (if (zerop n) 1 (* n (fact (1- n)))))
  858.  
  859.  - Command: cancel-debug-on-entry FUNCTION-NAME
  860.      This function undoes the effect of `debug-on-entry' on
  861.      FUNCTION-NAME.  When called interactively, it prompts for
  862.      FUNCTION-NAME in the minibuffer.
  863.  
  864.      If `cancel-debug-on-entry' is called more than once on the same
  865.      function, the second call does nothing.  `cancel-debug-on-entry'
  866.      returns FUNCTION-NAME.
  867.  
  868. 
  869. File: elisp,  Node: Explicit Debug,  Next: Using Debugger,  Prev: Function Debugging,  Up: Debugger
  870.  
  871. Explicit Entry to the Debugger
  872. ------------------------------
  873.  
  874.    You can cause the debugger to be called at a certain point in your
  875. program by writing the expression `(debug)' at that point.  To do this,
  876. visit the source file, insert the text `(debug)' at the proper place,
  877. and type `C-M-x'.  Be sure to undo this insertion before you save the
  878. file!
  879.  
  880.    The place where you insert `(debug)' must be a place where an
  881. additional form can be evaluated and its value ignored.  (If the value
  882. isn't ignored, it will alter the execution of the program!)  Usually
  883. this means inside a `progn' or an implicit `progn' (*note
  884. Sequencing::.).
  885.  
  886. 
  887. File: elisp,  Node: Using Debugger,  Next: Debugger Commands,  Prev: Explicit Debug,  Up: Debugger
  888.  
  889. Using the Debugger
  890. ------------------
  891.  
  892.    When the debugger is entered, it displays the previously selected
  893. buffer in one window and a buffer named `*Backtrace*' in another
  894. window.  The backtrace buffer contains one line for each level of Lisp
  895. function execution currently going on.  At the beginning of this buffer
  896. is a message describing the reason that the debugger was invoked (such
  897. as the error message and associated data, if it was invoked due to an
  898. error).
  899.  
  900.    The backtrace buffer is read-only and uses a special major mode,
  901. Debugger mode, in which letters are defined as debugger commands.  The
  902. usual Emacs editing commands are available; thus, you can switch windows
  903. to examine the buffer that was being edited at the time of the error,
  904. switch buffers, visit files, or do any other sort of editing.  However,
  905. the debugger is a recursive editing level (*note Recursive Editing::.)
  906. and it is wise to go back to the backtrace buffer and exit the debugger
  907. (with the `q' command) when you are finished with it.  Exiting the
  908. debugger gets out of the recursive edit and kills the backtrace buffer.
  909.  
  910.    The contents of the backtrace buffer show you the functions that are
  911. executing and the arguments that were given to them.  It also allows
  912. you to specify a stack frame by moving point to the line describing
  913. that frame.  (A stack frame is the place where the Lisp interpreter
  914. records information about a particular invocation of a function.  The
  915. frame whose line point is on is considered the "current frame".) Some
  916. of the debugger commands operate on the current frame.
  917.  
  918.    The debugger itself should always be run byte-compiled, since it
  919. makes assumptions about how many stack frames are used for the debugger
  920. itself.  These assumptions are false if the debugger is running
  921. interpreted.
  922.  
  923. 
  924. File: elisp,  Node: Debugger Commands,  Next: Invoking the Debugger,  Prev: Using Debugger,  Up: Debugger
  925.  
  926. Debugger Commands
  927. -----------------
  928.  
  929.    Inside the debugger (in Debugger mode), these special commands are
  930. available in addition to the usual cursor motion commands.  (Keep in
  931. mind that all the usual facilities of Emacs, such as switching windows
  932. or buffers, are still available.)
  933.  
  934.    The most important use of debugger commands is for stepping through
  935. code, so that you can see how control flows.  The debugger can step
  936. through the control structures of an interpreted function, but cannot do
  937. so in a byte-compiled function.  If you would like to step through a
  938. byte-compiled function, replace it with an interpreted definition of the
  939. same function.  (To do this, visit the source file for the function and
  940. type `C-M-x' on its definition.)
  941.  
  942. `c'
  943.      Exit the debugger and continue execution.  When continuing is
  944.      possible, it resumes execution of the program as if the debugger
  945.      had never been entered (aside from the effect of any variables or
  946.      data structures you may have changed while inside the debugger).
  947.  
  948.      Continuing is possible after entry to the debugger due to function
  949.      entry or exit, explicit invocation, quitting or certain errors.
  950.      Most errors cannot be continued; trying to continue an unsuitable
  951.      error causes the same error to occur again.
  952.  
  953. `d'
  954.      Continue execution, but enter the debugger the next time any Lisp
  955.      function is called.  This allows you to step through the
  956.      subexpressions of an expression, seeing what values the
  957.      subexpressions compute, and what else they do.
  958.  
  959.      The stack frame made for the function call which enters the
  960.      debugger in this way will be flagged automatically so that the
  961.      debugger will be called again when the frame is exited.  You can
  962.      use the `u' command to cancel this flag.
  963.  
  964. `b'
  965.      Flag the current frame so that the debugger will be entered when
  966.      the frame is exited.  Frames flagged in this way are marked with
  967.      stars in the backtrace buffer.
  968.  
  969. `u'
  970.      Don't enter the debugger when the current frame is exited.  This
  971.      cancels a `b' command on that frame.
  972.  
  973. `e'
  974.      Read a Lisp expression in the minibuffer, evaluate it, and print
  975.      the value in the echo area.  This is the same as the command
  976.      `M-ESC', except that `e' is not normally disabled like `M-ESC'.
  977.  
  978. `q'
  979.      Terminate the program being debugged; return to top-level Emacs
  980.      command execution.
  981.  
  982.      If the debugger was entered due to a `C-g' but you really want to
  983.      quit, and not debug, use the `q' command.
  984.  
  985. `r'
  986.      Return a value from the debugger.  The value is computed by
  987.      reading an expression with the minibuffer and evaluating it.
  988.  
  989.      The `r' command makes a difference when the debugger was invoked
  990.      due to exit from a Lisp call frame (as requested with `b'); then
  991.      the value specified in the `r' command is used as the value of that
  992.      frame.
  993.  
  994.      You can't use `r' when the debugger was entered due to an error.
  995.  
  996. 
  997. File: elisp,  Node: Invoking the Debugger,  Next: Internals of Debugger,  Prev: Debugger Commands,  Up: Debugger
  998.  
  999. Invoking the Debugger
  1000. ---------------------
  1001.  
  1002.    Here we describe fully the function used to invoke the debugger.
  1003.  
  1004.  - Function: debug &rest DEBUGGER-ARGS
  1005.      This function enters the debugger.  It switches buffers to a buffer
  1006.      named `*Backtrace*' (or `*Backtrace*<2>' if it is the second
  1007.      recursive entry to the debugger, etc.), and fills it with
  1008.      information about the stack of Lisp function calls.  It then
  1009.      enters a recursive edit, leaving that buffer in Debugger mode and
  1010.      displayed in the selected window.
  1011.  
  1012.      Debugger mode provides a `c' command which operates by exiting the
  1013.      recursive edit, switching back to the previous buffer, and
  1014.      returning to whatever called `debug'.  The `r' command also
  1015.      returns from `debug'.  These are the only ways the function
  1016.      `debug' can return to its caller.
  1017.  
  1018.      If the first of the DEBUGGER-ARGS passed to `debug' is `nil' (or
  1019.      if it is not one of the following special values), then the rest
  1020.      of the arguments to `debug' are printed at the top of the
  1021.      `*Backtrace*' buffer.  This mechanism is used to display a message
  1022.      to the user.
  1023.  
  1024.      However, if the first argument passed to `debug' is one of the
  1025.      following special values, then it has special significance.
  1026.      Normally, these values are passed to `debug' only by the internals
  1027.      of Emacs and the debugger, and not by programmers calling `debug'.
  1028.  
  1029.      The special values are:
  1030.  
  1031.     `lambda'
  1032.           When the first argument is `lambda', the debugger displays
  1033.           `Entering:' as a line of text at the top of the buffer.  This
  1034.           means that a function is being entered when
  1035.           `debug-on-next-call' is non-`nil'.
  1036.  
  1037.     `debug'
  1038.           When the first argument is `debug', the debugger displays
  1039.           `Entering:' just as in the `lambda' case.  However, `debug'
  1040.           as the argument indicates that the reason for entering the
  1041.           debugger is that a function set to debug on entry is being
  1042.           entered.
  1043.  
  1044.           In addition, `debug' as the first argument directs the
  1045.           debugger to mark the function that called `debug' so that it
  1046.           will invoke the debugger when exited.  (When `lambda' is the
  1047.           first argument, the debugger does not do this, because it has
  1048.           already been done by the interpreter.)
  1049.  
  1050.     `t'
  1051.           When the first argument is `t', the debugger displays the
  1052.           following as the top line in the buffer:
  1053.  
  1054.                Beginning evaluation of function call form:
  1055.  
  1056.           This indicates that it was entered due to the evaluation of a
  1057.           list form at a time when `debug-on-next-call' is non-`nil'.
  1058.  
  1059.     `exit'
  1060.           When the first argument is `exit', it indicates the exit of a
  1061.           stack frame previously marked to invoke the debugger on exit.
  1062.           The second argument given to `debug' in this case is the
  1063.           value being returned from the frame.  The debugger displays
  1064.           `Return value:' on the top line of the buffer, followed by
  1065.           the value being returned.
  1066.  
  1067.     `error'
  1068.           When the first argument is `error', the debugger indicates
  1069.           that it is being entered because an error or `quit' was
  1070.           signaled and not handled, by displaying `Signaling:' followed
  1071.           by the error signaled and any arguments to `signal'.  For
  1072.           example,
  1073.  
  1074.                (let ((debug-on-error t))
  1075.                     (/ 1 0))
  1076.                
  1077.                ------ Buffer: *Backtrace* ------
  1078.                Signaling: (arith-error)
  1079.                  /(1 0)
  1080.                ...
  1081.                ------ Buffer: *Backtrace* ------
  1082.  
  1083.           If an error was signaled, presumably the variable
  1084.           `debug-on-error' is non-`nil'.  If `quit' was signaled, then
  1085.           presumably the variable `debug-on-quit' is non-`nil'.
  1086.  
  1087.     `nil'
  1088.           Use `nil' as the first of the DEBUGGER-ARGS when you want to
  1089.           enter the debugger explicitly.  The rest of the DEBUGGER-ARGS
  1090.           are printed on the top line of the buffer.  You can use this
  1091.           feature to display messages--for example, to remind yourself
  1092.           of the conditions under which `debug' is called.
  1093.  
  1094. 
  1095. File: elisp,  Node: Internals of Debugger,  Prev: Invoking the Debugger,  Up: Debugger
  1096.  
  1097. Internals of the Debugger
  1098. -------------------------
  1099.  
  1100.    This section describes functions and variables used internally by the
  1101. debugger.
  1102.  
  1103.  - Variable: debugger
  1104.      The value of this variable is the function to call to invoke the
  1105.      debugger.  Its value must be a function of any number of arguments
  1106.      (or, more typically, the name of a function).  Presumably this
  1107.      function will enter some kind of debugger.  The default value of
  1108.      the variable is `debug'.
  1109.  
  1110.      The first argument that Lisp hands to the function indicates why it
  1111.      was called.  The convention for arguments is detailed in the
  1112.      description of `debug'.
  1113.  
  1114.  - Command: backtrace
  1115.      This function prints a trace of Lisp function calls currently
  1116.      active.  This is the function used by `debug' to fill up the
  1117.      `*Backtrace*' buffer.  It is written in C, since it must have
  1118.      access to the stack to determine which function calls are active.
  1119.      The return value is always `nil'.
  1120.  
  1121.      In the following example, `backtrace' is called explicitly in a
  1122.      Lisp expression.  When the expression is evaluated, the backtrace
  1123.      is printed to the stream `standard-output': in this case, to the
  1124.      buffer `backtrace-output'.  Each line of the backtrace represents
  1125.      one function call.  If the arguments of the function call are all
  1126.      known, they are displayed; if they are being computed, that fact
  1127.      is stated.  The arguments of special forms are elided.
  1128.  
  1129.           (with-output-to-temp-buffer "backtrace-output"
  1130.             (let ((var 1))
  1131.               (save-excursion
  1132.                 (setq var (eval '(progn
  1133.                                    (1+ var)
  1134.                                    (list 'testing (backtrace))))))))
  1135.           
  1136.                => nil
  1137.  
  1138.           ----------- Buffer: backtrace-output ------------
  1139.             backtrace()
  1140.             (list ...computing arguments...)
  1141.             (progn ...)
  1142.             eval((progn (1+ var) (list (quote testing) (backtrace))))
  1143.             (setq ...)
  1144.             (save-excursion ...)
  1145.             (let ...)
  1146.             (with-output-to-temp-buffer ...)
  1147.             eval-region(1973 2142 #<buffer *scratch*>)
  1148.             byte-code("...  for eval-print-last-sexp ...")
  1149.             eval-print-last-sexp(nil)
  1150.           * call-interactively(eval-print-last-sexp)
  1151.           ----------- Buffer: backtrace-output ------------
  1152.  
  1153.      The character `*' indicates a frame whose debug-on-exit flag is
  1154.      set.
  1155.  
  1156.  - Variable: debug-on-next-call
  1157.      This variable determines whether the debugger is called before the
  1158.      next `eval', `apply' or `funcall'.  It is automatically reset to
  1159.      `nil' when the debugger is entered.
  1160.  
  1161.      The `d' command in the debugger works by setting this variable.
  1162.  
  1163.  - Function: backtrace-debug LEVEL FLAG
  1164.      This function sets the debug-on-exit flag of the eval frame LEVEL
  1165.      levels down to FLAG.  If FLAG is non-`nil', this will cause the
  1166.      debugger to be entered when that frame exits.  Even a nonlocal
  1167.      exit through that frame will enter the debugger.
  1168.  
  1169.      The debug-on-exit flag is an entry in the stack frame of a
  1170.      function call.  This flag is examined on every exit from a
  1171.      function.
  1172.  
  1173.      Normally, this function is only called by the debugger.
  1174.  
  1175.  - Variable: command-debug-status
  1176.      This variable records the debugging status of current interactive
  1177.      command.  Each time a command is called interactively, this
  1178.      variable is bound to `nil'.  The debugger can set this variable to
  1179.      leave information for future debugger invocations during the same
  1180.      command.
  1181.  
  1182.      The advantage of using this variable rather that defining another
  1183.      global variable is that the data will never carry over to a later
  1184.      other command invocation.
  1185.  
  1186.  - Function: backtrace-frame FRAME-NUMBER
  1187.      The function `backtrace-frame' is intended for use in Lisp
  1188.      debuggers.  It returns information about what computation is
  1189.      happening in the eval frame LEVEL levels down.
  1190.  
  1191.      If that frame has not evaluated the arguments yet (or is a special
  1192.      form), the value is `(nil FUNCTION ARG-FORMS...)'.
  1193.  
  1194.      If that frame has evaluated its arguments and called its function
  1195.      already, the value is `(t FUNCTION ARG-VALUES...)'.
  1196.  
  1197.      In the return value, FUNCTION is whatever was supplied as CAR of
  1198.      evaluated list, or a `lambda' expression in the case of a macro
  1199.      call.  If the function has a `&rest' argument, that is represented
  1200.      as the tail of the list ARG-VALUES.
  1201.  
  1202.      If the argument is out of range, `backtrace-frame' returns `nil'.
  1203.  
  1204.