home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / elisp / elisp-12 < prev    next >
Encoding:
GNU Info File  |  1993-05-31  |  49.3 KB  |  1,276 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: Output Streams,  Next: Output Functions,  Prev: Input Functions,  Up: Streams
  28.  
  29. Output Streams
  30. ==============
  31.  
  32.    An output stream specifies what to do with the characters produced
  33. by printing.  Most print functions accept an output stream as an
  34. optional argument.  Here are the possible types of output stream:
  35.  
  36. BUFFER
  37.      The output characters are inserted into BUFFER at point.  Point
  38.      advances as characters are inserted.
  39.  
  40. MARKER
  41.      The output characters are inserted into the buffer that MARKER is
  42.      in at the marker position.  The position advances as characters are
  43.      inserted.  The value of point in the buffer has no effect when the
  44.      stream is a marker.
  45.  
  46. FUNCTION
  47.      The output characters are passed to FUNCTION, which is responsible
  48.      for storing them away.  It is called with a single character as
  49.      argument, as many times as there are characters to be output, and
  50.      is free to do anything at all with the characters it receives.
  51.  
  52. `t'
  53.      The output characters are displayed in the echo area.
  54.  
  55. `nil'
  56.      `nil' specified as an output stream means that the value of
  57.      `standard-output' should be used as the output stream; that value
  58.      is the "default output stream", and must be a non-`nil' output
  59.      stream.
  60.  
  61. SYMBOL
  62.      A symbol as output stream is equivalent to the symbol's function
  63.      definition (if any).
  64.  
  65.    Here is an example of a buffer used as an output stream.  Point is
  66. initially located as shown immediately before the `h' in `the'.  At the
  67. end, point is located directly before that same `h'.
  68.  
  69.      ---------- Buffer: foo ----------
  70.      This is t-!-he contents of foo.
  71.      ---------- Buffer: foo ----------
  72.      
  73.      (print "This is the output" (get-buffer "foo"))
  74.           => "This is the output"
  75.      
  76.      ---------- Buffer: foo ----------
  77.      This is t
  78.      "This is the output"
  79.      -!-he contents of foo.
  80.      ---------- Buffer: foo ----------
  81.  
  82.    Now we show a use of a marker as an output stream.  Initially, the
  83. marker points in buffer `foo', between the `t' and the `h' in the word
  84. `the'.  At the end, the marker has been advanced over the inserted text
  85. so that it still points before the same `h'.  Note that the location of
  86. point, shown in the usual fashion, has no effect.
  87.  
  88.      ---------- Buffer: foo ----------
  89.      "This is the -!-output"
  90.      ---------- Buffer: foo ----------
  91.      
  92.      m
  93.           => #<marker at 11 in foo>
  94.      
  95.      (print "More output for foo." m)
  96.           => "More output for foo."
  97.      
  98.      ---------- Buffer: foo ----------
  99.      "This is t
  100.      "More output for foo."
  101.      he -!-output"
  102.      ---------- Buffer: foo ----------
  103.      
  104.      m
  105.           => #<marker at 35 in foo>
  106.  
  107.    The following example shows output to the echo area:
  108.  
  109.      (print "Echo Area output" t)
  110.           => "Echo Area output"
  111.      ---------- Echo Area ----------
  112.      "Echo Area output"
  113.      ---------- Echo Area ----------
  114.  
  115.    Finally, we show an output stream which is a function.  The function
  116. `eat-output' takes each character that it is given and conses it onto
  117. the front of the list `last-output' (*note Building Lists::.).  At the
  118. end, the list contains all the characters output, but in reverse order.
  119.  
  120.      (setq last-output nil)
  121.           => nil
  122.      
  123.      (defun eat-output (c)
  124.        (setq last-output (cons c last-output)))
  125.           => eat-output
  126.      
  127.      (print "This is the output" 'eat-output)
  128.           => "This is the output"
  129.      
  130.      last-output
  131.           => (10 34 116 117 112 116 117 111 32 101 104
  132.          116 32 115 105 32 115 105 104 84 34 10)
  133.  
  134. Now we can put the output in the proper order by reversing the list:
  135.  
  136.      (concat (nreverse last-output))
  137.           => "
  138.      \"This is the output\"
  139.      "
  140.  
  141. 
  142. File: elisp,  Node: Output Functions,  Next: Output Variables,  Prev: Output Streams,  Up: Streams
  143.  
  144. Output Functions
  145. ================
  146.  
  147.    This section describes the Lisp functions for printing Lisp objects.
  148.  
  149.    Some of the Emacs printing functions add quoting characters to the
  150. output when necessary so that it can be read properly.  The quoting
  151. characters used are `\' and `"'; they are used to distinguish strings
  152. from symbols, and to prevent punctuation characters in strings and
  153. symbols from being taken as delimiters.  *Note Printed
  154. Representation::, for full details.  You specify quoting or no quoting
  155. by the choice of printing function.
  156.  
  157.    If the text is to be read back into Lisp, then it is best to print
  158. with quoting characters to avoid ambiguity.  Likewise, if the purpose is
  159. to describe a Lisp object clearly for a Lisp programmer.  However, if
  160. the purpose of the output is to look nice for humans, then it is better
  161. to print without quoting.
  162.  
  163.    Printing a self-referent Lisp object requires an infinite amount of
  164. text.  In certain cases, trying to produce this text leads to a stack
  165. overflow.  Emacs detects such recursion and prints `#LEVEL' instead of
  166. recursively printing an object already being printed.  For example,
  167. here `#0' indicates a recursive reference to the object at level 0 of
  168. the current print operation:
  169.  
  170.      (setq foo (list nil))
  171.           => (nil)
  172.      (setcar foo foo)
  173.           => (#0)
  174.  
  175.    In the functions below, STREAM stands for an output stream.  (See
  176. the previous section for a description of output streams.)  If STREAM
  177. is `nil' or omitted, it defaults to the value of `standard-output'.
  178.  
  179.  - Function: print OBJECT &optional STREAM
  180.      The `print' is a convenient way of printing.  It outputs the
  181.      printed representation of OBJECT to STREAM, printing in addition
  182.      one newline before OBJECT and another after it.  Quoting
  183.      characters are used.  `print' returns OBJECT.  For example:
  184.  
  185.           (progn (print 'The\ cat\ in)
  186.                  (print "the hat")
  187.                  (print " came back"))
  188.                -|
  189.                -| The\ cat\ in
  190.                -|
  191.                -| "the hat"
  192.                -|
  193.                -| " came back"
  194.                -|
  195.                => " came back"
  196.  
  197.  - Function: prin1 OBJECT &optional STREAM
  198.      This function outputs the printed representation of OBJECT to
  199.      STREAM.  It does not print any spaces or newlines to separate
  200.      output as `print' does, but it does use quoting characters just
  201.      like `print'.  It returns OBJECT.
  202.  
  203.           (progn (prin1 'The\ cat\ in)
  204.                  (prin1 "the hat")
  205.                  (prin1 " came back"))
  206.                -| The\ cat\ in"the hat"" came back"
  207.                => " came back"
  208.  
  209.  - Function: princ OBJECT &optional STREAM
  210.      This function outputs the printed representation of OBJECT to
  211.      STREAM.  It returns OBJECT.
  212.  
  213.      This function is intended to produce output that is readable by
  214.      people, not by `read', so quoting characters are not used and
  215.      double-quotes are not printed around the contents of strings.  It
  216.      does not add any spacing between calls.
  217.  
  218.           (progn
  219.             (princ 'The\ cat)
  220.             (princ " in the \"hat\""))
  221.                -| The cat in the "hat"
  222.                => " in the \"hat\""
  223.  
  224.  - Function: terpri &optional STREAM
  225.      This function outputs a newline to STREAM.  The name stands for
  226.      "terminate print".
  227.  
  228.  - Function: write-char CHARACTER &optional STREAM
  229.      This function outputs CHARACTER to STREAM.  It returns CHARACTER.
  230.  
  231.  - Function: prin1-to-string OBJECT &optional NOESCAPE
  232.      This function returns a string containing the text that `prin1'
  233.      would have printed for the same argument.
  234.  
  235.           (prin1-to-string 'foo)
  236.                => "foo"
  237.           (prin1-to-string (mark-marker))
  238.                => "#<marker at 2773 in strings.texi>"
  239.  
  240.      If NOESCAPE is non-`nil', that inhibits use of quoting characters
  241.      in the output.  (This argument is supported in Emacs versions 19
  242.      and later.)
  243.  
  244.           (prin1-to-string "foo")
  245.                => "\"foo\""
  246.           (prin1-to-string "foo" t)
  247.                => "foo"
  248.  
  249.      See `format', in *Note String Conversion::, for other ways to
  250.      obtain the printed representation of a Lisp object as a string.
  251.  
  252. 
  253. File: elisp,  Node: Output Variables,  Prev: Output Functions,  Up: Streams
  254.  
  255. Variables Affecting Output
  256. ==========================
  257.  
  258.  - Variable: standard-output
  259.      The value of this variable is the default output stream, used when
  260.      the STREAM argument is omitted or `nil'.
  261.  
  262.  - Variable: print-escape-newlines
  263.      If this variable is non-`nil', then newline characters in strings
  264.      are printed as `\n'.  Normally they are printed as actual newlines.
  265.  
  266.      This variable affects the print functions `prin1' and `print', as
  267.      well as everything that uses them.  It does not affect `princ'.
  268.      Here is an example using `prin1':
  269.  
  270.           (prin1 "a\nb")
  271.                -| "a
  272.                -| b"
  273.                => "a
  274.                => b"
  275.           
  276.           (let ((print-escape-newlines t))
  277.             (prin1 "a\nb"))
  278.                -| "a\nb"
  279.                => "a
  280.                => b"
  281.  
  282.      In the second expression, the local binding of
  283.      `print-escape-newlines' is in effect during the call to `prin1',
  284.      but not during the printing of the result.
  285.  
  286.  - Variable: print-length
  287.      The value of this variable is the maximum number of elements of a
  288.      list that will be printed.  If the list being printed has more
  289.      than this many elements, then it is abbreviated with an ellipsis.
  290.  
  291.      If the value is `nil' (the default), then there is no limit.
  292.  
  293.           (setq print-length 2)
  294.                => 2
  295.           (print '(1 2 3 4 5))
  296.                -| (1 2 ...)
  297.                => (1 2 ...)
  298.  
  299.  - Variable: print-level
  300.      The value of this variable is the maximum depth of nesting of
  301.      parentheses that will be printed.  Any list or vector at a depth
  302.      exceeding this limit is abbreviated with an ellipsis.  A value of
  303.      `nil' (which is the default) means no limit.
  304.  
  305.      This variable exists in version 19 and later versions.
  306.  
  307. 
  308. File: elisp,  Node: Minibuffers,  Next: Command Loop,  Prev: Streams,  Up: Top
  309.  
  310. Minibuffers
  311. ***********
  312.  
  313.    A "minibuffer" is a special buffer that Emacs commands use to read
  314. arguments more complicated than the single numeric prefix argument.
  315. These arguments include file names, buffer names, and command names (as
  316. in `M-x').  The minibuffer is displayed on the bottom line of the
  317. screen, in the same place as the echo area, but only while it is in use
  318. for reading an argument.
  319.  
  320. * Menu:
  321.  
  322. * Intro to Minibuffers::      Basic information about minibuffers.
  323. * Text from Minibuffer::      How to read a straight text string.
  324. * Object from Minibuffer::    How to read a Lisp object or expression.
  325. * Minibuffer History::          Recording previous minibuffer inputs
  326.                 so the user can reuse them.
  327. * Completion::                How to invoke and customize completion.
  328. * Yes-or-No Queries::         Asking a question with a simple answer.
  329. * Multiple Queries::          Asking a series of similar questions.
  330. * Minibuffer Misc::           Various customization hooks and variables.
  331.  
  332. 
  333. File: elisp,  Node: Intro to Minibuffers,  Next: Text from Minibuffer,  Up: Minibuffers
  334.  
  335. Introduction to Minibuffers
  336. ===========================
  337.  
  338.    In most ways, a minibuffer is a normal Emacs buffer.  Most operations
  339. *within* a buffer, such as editing commands, work normally in a
  340. minibuffer.  However, many operations for managing buffers do not apply
  341. to minibuffers.  The name of a minibuffer always has the form
  342. ` *Minibuf-NUMBER', and it cannot be changed.  Minibuffers are
  343. displayed only in special windows used only for minibuffers; these
  344. windows always appear at the bottom of a frame.  (Sometime frames have
  345. no minibuffer window, and sometimes a special kind of frame contains
  346. nothing but a minibuffer window; see *Note Minibuffers and Frames::.)
  347.  
  348.    The minibuffers window is normally a single line; you can resize it
  349. temporarily with the window sizing commands, but reverts to its normal
  350. size when the minibuffer is exited.
  351.  
  352.    A "recursive minibuffer" may be created when there is an active
  353. minibuffer and a command is invoked that requires input from a
  354. minibuffer.  The first minibuffer is named ` *Minibuf-0*'.  Recursive
  355. minibuffers are named by incrementing the number at the end of the
  356. name.  (The names begin with a space so that they won't show up in
  357. normal buffer lists.)  Of several recursive minibuffers, the innermost
  358. (or most recently entered) is the active minibuffer.  We usually call
  359. this "the" minibuffer.  You can permit or forbid recursive minibuffers
  360. by setting the variable `enable-recursive-minibuffers' or by putting
  361. properties of that name on command symbols (*note Minibuffer Misc::.).
  362.  
  363.    Like other buffers, a minibuffer may use any of several local keymaps
  364. (*note Keymaps::.); these contain various exit commands and in some
  365. cases completion commands.  *Note Completion::.
  366.  
  367.    * `minibuffer-local-map' is for ordinary input (no completion).
  368.  
  369.    * `minibuffer-local-ns-map' is similar, except that SPC exits just
  370.      like RET.  This is used mainly for Mocklisp compatibility.
  371.  
  372.    * `minibuffer-local-completion-map' is for permissive completion.
  373.  
  374.    * `minibuffer-local-must-match-map' is for strict completion and for
  375.      cautious completion.
  376.  
  377. 
  378. File: elisp,  Node: Text from Minibuffer,  Next: Object from Minibuffer,  Prev: Intro to Minibuffers,  Up: Minibuffers
  379.  
  380. Reading Text Strings with the Minibuffer
  381. ========================================
  382.  
  383.    The minibuffer is usually used to read text which is returned as a
  384. string, but can also be used to read a Lisp object in textual form.  The
  385. most basic primitive for minibuffer input is `read-from-minibuffer'.
  386.  
  387.  - Function: read-from-minibuffer PROMPT-STRING &optional INITIAL
  388.           KEYMAP READ HIST
  389.      This function is the most general way to get input through the
  390.      minibuffer.  By default, it accepts arbitrary text and returns it
  391.      as a string; however, if READ is non-`nil', then it uses `read' to
  392.      convert the text into a Lisp object (*note Input Functions::.).
  393.  
  394.      The first thing this function does is to activate a minibuffer and
  395.      display it with PROMPT-STRING as the prompt.  This value must be a
  396.      string.
  397.  
  398.      Then, if INITIAL is a string; its contents are inserted into the
  399.      minibuffer as initial contents.  The text thus inserted is treated
  400.      as if the user had inserted it; the user can alter it with Emacs
  401.      editing commands.
  402.  
  403.      The value of INITIAL may also be a cons cell of the form `(STRING
  404.      . POSITION)'.  This means to insert STRING in the minibuffer but
  405.      put the cursor POSITION characters from the beginning, rather than
  406.      at the end.
  407.  
  408.      If KEYMAP is non-`nil', that keymap is the local keymap to use
  409.      while reading.  If KEYMAP is omitted or `nil', the value of
  410.      `minibuffer-local-map' is used as the keymap.  Specifying a keymap
  411.      is the most important way to customize minibuffer input for
  412.      various applications including completion.
  413.  
  414.      The argument HIST specifies which history list variable to use for
  415.      saving the input and for history commands used in the minibuffer.
  416.      It defaults to `minibuffer-history'.  *Note Minibuffer History::.
  417.  
  418.      When the user types a command to exit the minibuffer, the current
  419.      minibuffer contents are usually made into a string which becomes
  420.      the value of `read-from-minibuffer'.  However, if READ is
  421.      non-`nil', `read-from-minibuffer' converts the result to a Lisp
  422.      object, and returns that object, unevaluated.
  423.  
  424.      Suppose, for example, you are writing a search command and want to
  425.      record the last search string and provide it as a default for the
  426.      next search.  Suppose that the previous search string is stored in
  427.      the variable `last-search-string'.  Here is how you can read a
  428.      search string while providing the previous string as initial input
  429.      to be edited:
  430.  
  431.           (read-from-minibuffer "Find string: " last-search-string)
  432.  
  433.      Assuming the value of `last-search-string' is `No', and the user
  434.      wants to search for `Nope', the interaction looks like this:
  435.  
  436.           (setq last-search-string "No")
  437.           
  438.           (read-from-minibuffer "Find string: " last-search-string)
  439.           ---------- Buffer: Minibuffer ----------
  440.           Find string: No-!-
  441.           ---------- Buffer: Minibuffer ----------
  442.           ;; The user now types `pe RET':
  443.                => "Nope"
  444.  
  445.      This technique is no longer preferred for most applications; it is
  446.      usually better to use a history list.
  447.  
  448.  - Function: read-string PROMPT &optional INITIAL
  449.      This function reads a string from the minibuffer and returns it.
  450.      The arguments PROMPT and INITIAL are used as in
  451.      `read-from-minibuffer'.
  452.  
  453.      This is a simplified interface to the `read-from-minibuffer'
  454.      function:
  455.  
  456.           (read-string PROMPT INITIAL)
  457.           ==
  458.           (read-from-minibuffer PROMPT INITIAL nil nil)
  459.  
  460.  - Variable: minibuffer-local-map
  461.      This is the default local keymap for reading from the minibuffer.
  462.      It is the keymap used by the minibuffer for local bindings in the
  463.      function `read-string'.  By default, it makes the following
  464.      bindings:
  465.  
  466.     LFD
  467.           `exit-minibuffer'
  468.  
  469.     RET
  470.           `exit-minibuffer'
  471.  
  472.     `C-g'
  473.           `abort-recursive-edit'
  474.  
  475.     `M-n' and `M-p'
  476.           `next-history-element' and `previous-history-element'
  477.  
  478.     `M-r'
  479.           `next-matching-history-element'
  480.  
  481.     `M-s'
  482.           `previous-matching-history-element'
  483.  
  484.  - Function: read-no-blanks-input PROMPT &optional INITIAL
  485.      This function reads a string from the minibuffer, but does not
  486.      allow whitespace characters as part of the input: instead, those
  487.      characters terminate the input.  The arguments PROMPT and INITIAL
  488.      are used as in `read-from-minibuffer'.
  489.  
  490.      This is a simplified interface to the `read-from-minibuffer'
  491.      function, and passes the value of the `minibuffer-local-ns-map'
  492.      keymap as the KEYMAP argument for that function.  Since the keymap
  493.      `minibuffer-local-ns-map' does not rebind `C-q', it *is* possible
  494.      to put a space into the string, by quoting it.
  495.  
  496.           (read-no-blanks-input PROMPT INITIAL)
  497.           ==
  498.           (read-from-minibuffer PROMPT INITIAL minibuffer-local-ns-map)
  499.  
  500.  - Variable: minibuffer-local-ns-map
  501.      This built-in variable is the keymap used as the minibuffer local
  502.      keymap in the function `read-no-blanks-input'.  By default, it
  503.      makes the following bindings:
  504.  
  505.     LFD
  506.           `exit-minibuffer'
  507.  
  508.     SPC
  509.           `exit-minibuffer'
  510.  
  511.     TAB
  512.           `exit-minibuffer'
  513.  
  514.     RET
  515.           `exit-minibuffer'
  516.  
  517.     `C-g'
  518.           `abort-recursive-edit'
  519.  
  520.     `?'
  521.           `self-insert-and-exit'
  522.  
  523.     `M-n' and `M-p'
  524.           `next-history-element' and `previous-history-element'
  525.  
  526.     `M-r'
  527.           `next-matching-history-element'
  528.  
  529.     `M-s'
  530.           `previous-matching-history-element'
  531.  
  532. 
  533. File: elisp,  Node: Object from Minibuffer,  Next: Minibuffer History,  Prev: Text from Minibuffer,  Up: Minibuffers
  534.  
  535. Reading Lisp Objects with the Minibuffer
  536. ========================================
  537.  
  538.    This section describes functions for reading Lisp objects with the
  539. minibuffer.
  540.  
  541.  - Function: read-minibuffer PROMPT &optional INITIAL
  542.      This function reads a Lisp object in the minibuffer and returns it,
  543.      without evaluating it.  The arguments PROMPT and INITIAL are used
  544.      as in `read-from-minibuffer'; in particular, INITIAL must be a
  545.      string or `nil'.
  546.  
  547.      This is a simplified interface to the `read-from-minibuffer'
  548.      function:
  549.  
  550.           (read-minibuffer PROMPT INITIAL)
  551.           ==
  552.           (read-from-minibuffer PROMPT INITIAL nil t)
  553.  
  554.      Here is an example in which we supply the string `"(testing)"' as
  555.      initial input:
  556.  
  557.           (read-minibuffer
  558.            "Enter an expression: " (format "%s" '(testing)))
  559.           
  560.           ;; Here is how the minibuffer is displayed:
  561.  
  562.           ---------- Buffer: Minibuffer ----------
  563.           Enter an expression: (testing)-!-
  564.           ---------- Buffer: Minibuffer ----------
  565.  
  566.      The user can type RET immediately to use the initial input as a
  567.      default, or can edit the input.
  568.  
  569.  - Function: eval-minibuffer PROMPT &optional INITIAL
  570.      This function reads a Lisp expression in the minibuffer, evaluates
  571.      it, then returns the result.  The arguments PROMPT and INITIAL are
  572.      used as in `read-from-minibuffer'.
  573.  
  574.      This function simply evaluates the result of a call to
  575.      `read-minibuffer':
  576.  
  577.           (eval-minibuffer PROMPT INITIAL)
  578.           ==
  579.           (eval (read-minibuffer PROMPT INITIAL))
  580.  
  581.  - Function: edit-and-eval-command PROMPT FORM
  582.      This function reads a Lisp expression in the minibuffer, and then
  583.      evaluates it.  The difference between this command and
  584.      `eval-minibuffer' is that here the initial FORM is not optional
  585.      and it is treated as a Lisp object to be converted to printed
  586.      representation rather than as a string of text.  It is printed with
  587.      `prin1', so if it is a string, double-quote characters (`"')
  588.      appear in the initial text.  *Note Output Functions::.
  589.  
  590.      The first thing `edit-and-eval-command' does is to activate the
  591.      minibuffer with PROMPT as the prompt.  Then it inserts the printed
  592.      representation of FORM in the minibuffer, and lets the user edit.
  593.      When the user exits the minibuffer, the edited text is read with
  594.      `read' and then evaluated.  The resulting value becomes the value
  595.      of `edit-and-eval-command'.
  596.  
  597.      In the following example, we offer the user an expression with
  598.      initial text which is a valid form already:
  599.  
  600.           (edit-and-eval-command "Please edit: " '(forward-word 1))
  601.           
  602.           ;; After evaluating the preceding expression,
  603.           ;;   the following appears in the minibuffer:
  604.  
  605.           ---------- Buffer: Minibuffer ----------
  606.           Please edit: (forward-word 1)-!-
  607.           ---------- Buffer: Minibuffer ----------
  608.  
  609.      Typing RET right away would exit the minibuffer and evaluate the
  610.      expression, thus moving point forward one word.
  611.      `edit-and-eval-command' returns `nil' in this example.
  612.  
  613. 
  614. File: elisp,  Node: Minibuffer History,  Next: Completion,  Prev: Object from Minibuffer,  Up: Minibuffers
  615.  
  616. Minibuffer History
  617. ==================
  618.  
  619.    A minibuffer history list records previous minibuffer inputs so the
  620. user can reuse them conveniently.  There are many separate history lists
  621. which contain different kinds of inputs.  The Lisp programmer's job is
  622. to specify the right history list for each use of the minibuffer.
  623.  
  624.    The basic minibuffer input functions `read-from-minibuffer' and
  625. `completing-read' both accept an optional argument named HIST which is
  626. how you specify the history list.  Here are the possible values:
  627.  
  628. VARIABLE
  629.      If you specify a variable (a symbol), that variable is the history
  630.      list.
  631.  
  632. (VARIABLE . STARTPOS)
  633.      If you specify a cons cell of this form, then VARIABLE is the
  634.      history list variable, and STARTPOS specifies the initial history
  635.      position (an integer, counting from zero which specifies the most
  636.      recent element of the history).
  637.  
  638.      If you specify STARTPOS, then you should also specify that element
  639.      of the history as INITIAL, for consistency.
  640.  
  641.    If you don't specify HIST, then the default history list
  642. `minibuffer-history' is used.  For other standard history lists, see
  643. below.  You can also create your own history list variable; just
  644. initialize it to `nil' before the first use.  The value of the history
  645. list variable is a list of strings, most recent first.
  646.  
  647.    Both `read-from-minibuffer' and `completing-read' add new elements
  648. to the history list automatically, and provide commands to allow the
  649. user to reuse items on the list.  The only thing your program needs to
  650. do to use a history list is to initialize it and to pass its name to
  651. the input functions when you wish.  But it is safe to modify the list
  652. by hand when the minibuffer input functions are not using it.
  653.  
  654.  - Variable: minibuffer-history
  655.      The default history list for minibuffer history input.
  656.  
  657.  - Variable: query-replace-history
  658.      A history list for arguments to `query-replace' (and similar
  659.      arguments to other commands).
  660.  
  661.  - Variable: file-name-history
  662.      A history list for file name arguments.
  663.  
  664. 
  665. File: elisp,  Node: Completion,  Next: Yes-or-No Queries,  Prev: Minibuffer History,  Up: Minibuffers
  666.  
  667. Completion
  668. ==========
  669.  
  670.    "Completion" is a feature that fills in the rest of a name starting
  671. from an abbreviation for it.  Completion works by comparing the user's
  672. input against a list of valid names and determining how much of the
  673. name is determined uniquely by what the user has typed.
  674.  
  675.    For example, when you type `C-x b' (`switch-to-buffer') and then
  676. type the first few letters of the name of the buffer to which you wish
  677. to switch, and then type TAB (`minibuffer-complete'), Emacs extends the
  678. name as far as it can.  Standard Emacs commands offer completion for
  679. names of symbols, files, buffers, and processes; with the functions in
  680. this section, you can implement completion for other kinds of names.
  681.  
  682.    The `try-completion' function is the basic primitive for completion:
  683. it returns the longest determined completion of a given initial string,
  684. with a given set of strings to match against.
  685.  
  686.    The function `completing-read' provides a higher-level interface for
  687. completion.  A call to `completing-read' specifies how to determine the
  688. list of valid names.  The function then activates the minibuffer with a
  689. local keymap that binds a few keys to commands useful for completion.
  690. Other functions provide convenient simple interfaces for reading
  691. certain kinds of names with completion.
  692.  
  693. * Menu:
  694.  
  695. * Basic Completion::       Low-level functions for completing strings.
  696.                              (These are too low level to use the minibuffer.)
  697. * Programmed Completion::  Finding the completions for a given file name.
  698. * Minibuffer Completion::  Invoking the minibuffer with completion.
  699. * Completion Commands::    Minibuffer commands that do completion.
  700. * High-Level Completion::  Convenient special cases of completion
  701.                              (reading buffer name, file name, etc.)
  702. * Reading File Names::     Using completion to read file names.
  703. * Lisp Symbol Completion:: Completing the name of a symbol.
  704.  
  705. 
  706. File: elisp,  Node: Basic Completion,  Next: Programmed Completion,  Up: Completion
  707.  
  708. Basic Completion Functions
  709. --------------------------
  710.  
  711.  - Function: try-completion STRING COLLECTION &optional PREDICATE
  712.      This function returns the longest common substring of all possible
  713.      completions of STRING in COLLECTION.  The value of COLLECTION must
  714.      be an alist, an obarray, or a function which implements a virtual
  715.      set of strings.
  716.  
  717.      If COLLECTION is an alist (*note Association Lists::.), completion
  718.      compares the CAR of each cons cell in it against STRING; if the
  719.      beginning of the CAR equals STRING, the cons cell matches.  If no
  720.      cons cells match, `try-completion' returns `nil'.  If only one
  721.      cons cell matches, and the match is exact, then `try-completion'
  722.      returns `t'.  Otherwise, the value is the longest initial sequence
  723.      common to all the matching strings in the alist.
  724.  
  725.      If COLLECTION is an obarray (*note Creating Symbols::.), the names
  726.      of all symbols in the obarray form the space of possible
  727.      completions.  They are tested and used just like the CARs of the
  728.      elements of an association list.  (The global variable `obarray'
  729.      holds an obarray containing the names of all interned Lisp
  730.      symbols.)
  731.  
  732.      Note that the only valid way to make a new obarray is to create it
  733.      empty and then add symbols to it one by one using `intern'.  Also,
  734.      you cannot intern a given symbol in more than one obarray.
  735.  
  736.      If the argument PREDICATE is non-`nil', then it must be a function
  737.      of one argument.  It is used to test each possible match, and the
  738.      match is accepted only if PREDICATE returns non-`nil'.  The
  739.      argument given to PREDICATE is either a cons cell from the alist
  740.      (the CAR of which is a string) or else it is a symbol (*not* a
  741.      symbol name) from the obarray.
  742.  
  743.      It is also possible to use a function symbol as COLLECTION.  Then
  744.      the function is solely responsible for performing completion;
  745.      `try-completion' returns whatever this function returns.  The
  746.      function is called with three arguments: STRING, PREDICATE and
  747.      `nil'.  (The reason for the third argument is so that the same
  748.      function can be used in `all-completions' and do the appropriate
  749.      thing in either case.)  *Note Programmed Completion::.
  750.  
  751.      In the first of the following examples, the string `foo' is
  752.      matched by three of the alist CARs.  All of the matches begin with
  753.      the characters `fooba', so that is the result.  In the second
  754.      example, there is only one possible match, and it is exact, so the
  755.      value is `t'.
  756.  
  757.           (try-completion
  758.            "foo"
  759.            '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4)))
  760.                => "fooba"
  761.  
  762.           (try-completion "foo" '(("barfoo" 2) ("foo" 3)))
  763.                => t
  764.  
  765.      In the following example, numerous symbols begin with the
  766.      characters `forw', and all of them begin with the word `forward'.
  767.      In most of the symbols, this is followed with a `-', but not in
  768.      all, so no more than `forward' can be completed.
  769.  
  770.           (try-completion "forw" obarray)
  771.                => "forward"
  772.  
  773.      Finally, in the following example, only two of the three possible
  774.      matches pass the predicate `test' (the string `foobaz' is too
  775.      short).  Both of those begin with the string `foobar'.
  776.  
  777.           (defun test (s)
  778.             (> (length (car s)) 6))
  779.                => test
  780.  
  781.           (try-completion
  782.            "foo"
  783.            '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
  784.                'test)
  785.                => "foobar"
  786.  
  787.  - Function: all-completions STRING COLLECTION &optional PREDICATE
  788.      This function returns a list of all possible completions, instead
  789.      of the longest substring they share.  The parameters to this
  790.      function are the same as to `try-completion'.
  791.  
  792.      If COLLECTION is a function, it is called with three arguments:
  793.      STRING, PREDICATE and `t', and `all-completions' returns whatever
  794.      the function returns.  *Note Programmed Completion::.
  795.  
  796.      Here is an example, using the function `test' shown in the example
  797.      for `try-completion':
  798.  
  799.           (defun test (s)
  800.             (> (length (car s)) 6))
  801.                => test
  802.  
  803.           (all-completions
  804.            "foo"
  805.            '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
  806.            (function test))
  807.                => ("foobar1" "foobar2")
  808.  
  809.  - Variable: completion-ignore-case
  810.      If the value of this variable is non-`nil', Emacs does not
  811.      consider case significant in completion.
  812.  
  813.    The two functions `try-completion' and `all-completions' have
  814. nothing in themselves to do with minibuffers.  However, completion is
  815. most often used there, which is why it is described in this chapter.
  816.  
  817. 
  818. File: elisp,  Node: Programmed Completion,  Next: Minibuffer Completion,  Prev: Basic Completion,  Up: Completion
  819.  
  820. Programmed Completion
  821. ---------------------
  822.  
  823.    Sometimes it is not possible to create an alist or an obarray
  824. containing all the intended possible completions.  In such a case, you
  825. can supply your own function to compute the completion of a given
  826. string.  This is called "programmed completion".
  827.  
  828.    To use this feature, pass a symbol with a function definition as the
  829. COLLECTION argument to `completing-read'.  This command arranges to
  830. pass the function along to `try-completion' and `all-completions',
  831. which will then let your function do all the work.
  832.  
  833.    The completion function should accept three arguments:
  834.  
  835.    * The string to be completed.
  836.  
  837.    * The predicate function to filter possible matches, or `nil' if
  838.      none.  Your function should call the predicate for each possible
  839.      match and ignore the possible match if the predicate returns `nil'.
  840.  
  841.    * A flag specifying the type of operation.
  842.  
  843.    There are three flag values for three operations:
  844.  
  845.    * `nil' specifies `try-completion'.  The completion function should
  846.      return the completion of the specified string, or `t' if the
  847.      string is an exact match already, or `nil' if the string matches no
  848.      possibility.
  849.  
  850.    * `t' specifies `all-completions'.  The completion function should
  851.      return a list of all possible completions of the specified string.
  852.  
  853.    * `lambda' specifies a test for an exact match.  The completion
  854.      function should return `t' if the specified string is an exact
  855.      match for some possibility; `nil' otherwise.
  856.  
  857.    It would be consistent and clean for completion functions to allow
  858. lambda expressions (lists which are functions) as well as function
  859. symbols as COLLECTION, but this is impossible.  Lists as completion
  860. tables are already assigned another meaning--as alists.  It would be
  861. unreliable to fail to handle an alist normally because it is also a
  862. possible function.  So you must arrange for any function you wish to
  863. use for completion to be encapsulated in a symbol.
  864.  
  865.    Emacs uses programmed completion when completing file names.  *Note
  866. File Name Completion::.
  867.  
  868. 
  869. File: elisp,  Node: Minibuffer Completion,  Next: Completion Commands,  Prev: Programmed Completion,  Up: Completion
  870.  
  871. Completion and the Minibuffer
  872. -----------------------------
  873.  
  874.    This section describes the basic interface for reading from the
  875. minibuffer with completion.
  876.  
  877.  - Function: completing-read PROMPT COLLECTION &optional PREDICATE
  878.           REQUIRE-MATCH INITIAL HIST
  879.      This function reads a string in the minibuffer, assisting the user
  880.      by providing completion.  It activates the minibuffer with prompt
  881.      PROMPT, which must be a string.  If INITIAL is non-`nil',
  882.      `completing-read' inserts it into the minibuffer as part of the
  883.      input.  Then it allows the user to edit the input, providing
  884.      several commands to attempt completion.
  885.  
  886.      The actual completion is done by passing COLLECTION and PREDICATE
  887.      to the function `try-completion'.  This happens in certain
  888.      commands bound in the local keymaps used for completion.
  889.  
  890.      If REQUIRE-MATCH is `t', the user is not allowed to exit unless
  891.      the input completes to an element of COLLECTION.  If REQUIRE-MATCH
  892.      is neither `nil' nor `t', then `completing-read' does not exit
  893.      unless the input typed is itself an element of COLLECTION.  To
  894.      accomplish this, `completing-read' calls `read-minibuffer'.  It
  895.      uses the value of `minibuffer-local-completion-map' as the keymap
  896.      if REQUIRE-MATCH is `nil', and uses
  897.      `minibuffer-local-must-match-map' if REQUIRE-MATCH is non-`nil'.
  898.  
  899.      The argument HIST specifies which history list variable to use for
  900.      saving the input and for minibuffer history commands.  It defaults
  901.      to `minibuffer-history'.  *Note Minibuffer History::.
  902.  
  903.      Case is ignored when comparing the input against the possible
  904.      matches if the built-in variable `completion-ignore-case' is
  905.      non-`nil'.  *Note Basic Completion::.
  906.  
  907.      For example:
  908.  
  909.           (completing-read
  910.            "Complete a foo: "
  911.            '(("foobar1" 1) ("barfoo" 2) ("foobaz" 3) ("foobar2" 4))
  912.            nil t "fo")
  913.  
  914.           ;; After evaluating the preceding expression,
  915.           ;;   the following appears in the minibuffer:
  916.           
  917.           ---------- Buffer: Minibuffer ----------
  918.           Complete a foo: fo-!-
  919.           ---------- Buffer: Minibuffer ----------
  920.  
  921.      If the user then types `DEL DEL b RET', `completing-read' returns
  922.      `barfoo'.
  923.  
  924.      The `completing-read' function binds three variables to pass
  925.      information to the commands which actually do completion.  Here
  926.      they are:
  927.  
  928.     `minibuffer-completion-table'
  929.           This variable is bound to the COLLECTION argument.  It is
  930.           passed to the `try-completion' function.
  931.  
  932.     `minibuffer-completion-predicate'
  933.           This variable is bound to the PREDICATE argument.  It is
  934.           passed to the `try-completion' function.
  935.  
  936.     `minibuffer-completion-confirm'
  937.           This variable is bound to the REQUIRE-MATCH argument.  It is
  938.           used in the `minibuffer-complete-and-exit' function.
  939.  
  940. 
  941. File: elisp,  Node: Completion Commands,  Next: High-Level Completion,  Prev: Minibuffer Completion,  Up: Completion
  942.  
  943. Minibuffer Commands That Do Completion
  944. --------------------------------------
  945.  
  946.    This section describes the keymaps, commands and user options used in
  947. the minibuffer to do completion.
  948.  
  949.  - Variable: minibuffer-local-completion-map
  950.      `completing-read' uses this value as the local keymap when an
  951.      exact match of one of the completions is not required.  By
  952.      default, this keymap makes the following bindings:
  953.  
  954.     `?'
  955.           `minibuffer-completion-help'
  956.  
  957.     SPC
  958.           `minibuffer-complete-word'
  959.  
  960.     TAB
  961.           `minibuffer-complete'
  962.  
  963.      with other characters bound as in `minibuffer-local-map'.
  964.  
  965.  - Variable: minibuffer-local-must-match-map
  966.      `completing-read' uses this value as the local keymap when an
  967.      exact match of one of the completions is required.  Therefore, no
  968.      keys are bound to `exit-minibuffer', the command which exits the
  969.      minibuffer unconditionally.  By default, this keymap makes the
  970.      following bindings:
  971.  
  972.     `?'
  973.           `minibuffer-completion-help'
  974.  
  975.     SPC
  976.           `minibuffer-complete-word'
  977.  
  978.     TAB
  979.           `minibuffer-complete'
  980.  
  981.     LFD
  982.           `minibuffer-complete-and-exit'
  983.  
  984.     RET
  985.           `minibuffer-complete-and-exit'
  986.  
  987.      with other characters bound as in `minibuffer-local-map'.
  988.  
  989.  - Variable: minibuffer-completion-table
  990.      The value of this variable is the alist or obarray used for
  991.      completion in the minibuffer.  This is the global variable that
  992.      contains what `completing-read' passes to `try-completion'.  It is
  993.      used by all the minibuffer completion functions, such as
  994.      `minibuffer-complete-word'.
  995.  
  996.  - Variable: minibuffer-completion-predicate
  997.      This variable's value is the predicate that `completing-read'
  998.      passes to `try-completion'.  The variable is also used by the other
  999.      minibuffer completion functions.
  1000.  
  1001.  - Command: minibuffer-complete-word
  1002.      This function completes the minibuffer contents by at most a single
  1003.      word.  Even if the minibuffer contents have only one completion,
  1004.      `minibuffer-complete-word' does not add any characters beyond the
  1005.      first character that is not a word constituent.  *Note Syntax
  1006.      Tables::.
  1007.  
  1008.  - Command: minibuffer-complete
  1009.      This function completes the minibuffer contents as far as possible.
  1010.  
  1011.  - Command: minibuffer-complete-and-exit
  1012.      This function completes the minibuffer contents, and exits if
  1013.      confirmation is not required, i.e., if
  1014.      `minibuffer-completion-confirm' is non-`nil'.  If confirmation
  1015.      *is* required, it is given by repeating this command immediately.
  1016.  
  1017.  - Variable: minibuffer-completion-confirm
  1018.      When the value of this variable is non-`nil', Emacs asks for
  1019.      confirmation of a completion before exiting the minibuffer.  The
  1020.      function `minibuffer-complete-and-exit' checks the value of this
  1021.      variable before it exits.
  1022.  
  1023.  - Command: minibuffer-completion-help
  1024.      This function creates a list of the possible completions of the
  1025.      current minibuffer contents.  It works by calling `all-completions'
  1026.      using the value of the variable `minibuffer-completion-table' as
  1027.      the COLLECTION argument, and the value of
  1028.      `minibuffer-completion-predicate' as the PREDICATE argument.  The
  1029.      list of completions is displayed as text in a buffer named
  1030.      `*Completions*'.
  1031.  
  1032.  - Function: display-completion-list COMPLETIONS
  1033.      This function displays COMPLETIONS to the stream in
  1034.      `standard-output', usually a buffer.  (*Note Streams::, for more
  1035.      information about streams.)  The argument COMPLETIONS is normally
  1036.      a list of completions just returned by `all-completions', but it
  1037.      does not have to be.  Each element may be a symbol or a string,
  1038.      either of which is simply printed, or a list of two strings, which
  1039.      is printed as if the strings were concatenated.
  1040.  
  1041.      This function is called by `minibuffer-completion-help'.  The most
  1042.      common way to use it is together with
  1043.      `with-output-to-temp-buffer', like this:
  1044.  
  1045.           (with-output-to-temp-buffer " *Completions*"
  1046.             (display-completion-list
  1047.               (all-completions (buffer-string) my-alist)))
  1048.  
  1049.  - User Option: completion-auto-help
  1050.      If this variable is non-`nil', the completion commands
  1051.      automatically display a list of possible completions whenever
  1052.      nothing can be completed because the next character is not
  1053.      uniquely determined.
  1054.  
  1055. 
  1056. File: elisp,  Node: High-Level Completion,  Next: Reading File Names,  Prev: Completion Commands,  Up: Completion
  1057.  
  1058. High-Level Completion  Functions
  1059. --------------------------------
  1060.  
  1061.    This section describes the higher-level convenient functions for
  1062. reading certain sorts of names with completion.
  1063.  
  1064.  - Function: read-buffer PROMPT &optional DEFAULT EXISTING
  1065.      This function reads the name of a buffer and returns it as a
  1066.      string.  The argument DEFAULT is the default name to use, the
  1067.      value to return if the user exits with an empty minibuffer.  If
  1068.      non-`nil', it should be a string.  It is mentioned in the prompt,
  1069.      but is not inserted in the minibuffer as initial input.
  1070.  
  1071.      If EXISTING is non-`nil', then the name specified must be that of
  1072.      an  existing buffer.  The usual commands to exit the minibuffer do
  1073.      not exit if the text is not valid, and RET does completion to
  1074.      attempt to find a valid name.  (However, DEFAULT is not checked
  1075.      for this; it is returned, whatever it is, if the user exits with
  1076.      the minibuffer empty.)
  1077.  
  1078.      In the following example, the user enters `minibuffer.t', and then
  1079.      types RET.  The argument EXISTING is `t', and the only buffer name
  1080.      starting with the given input is `minibuffer.texi', so that name
  1081.      is the value.
  1082.  
  1083.           (read-buffer "Buffer name? " "foo" t)
  1084.           ;; After evaluating the preceding expression,
  1085.           ;;   the following prompt appears,
  1086.           ;;   with an empty minibuffer:
  1087.  
  1088.           ---------- Buffer: Minibuffer ----------
  1089.           Buffer name? (default foo) -!-
  1090.           ---------- Buffer: Minibuffer ----------
  1091.  
  1092.           ;; The user types `minibuffer.t RET'.
  1093.           
  1094.                => "minibuffer.texi"
  1095.  
  1096.  - Function: read-command PROMPT
  1097.      This function reads the name of a command and returns it as a Lisp
  1098.      symbol.  The argument PROMPT is used as in `read-from-minibuffer'.
  1099.      Recall that a command is anything for which `commandp' returns
  1100.      `t', and a command name is a symbol for which `commandp' returns
  1101.      `t'.  *Note Interactive Call::.
  1102.  
  1103.           (read-command "Command name? ")
  1104.           ;; After evaluating the preceding expression,
  1105.           ;;   the following appears in the minibuffer:
  1106.  
  1107.           ---------- Buffer: Minibuffer ----------
  1108.           Command name?
  1109.           ---------- Buffer: Minibuffer ----------
  1110.  
  1111.      If the user types `forward-c RET', then this function returns
  1112.      `forward-char'.
  1113.  
  1114.      The `read-command' function is a simplified interface to the
  1115.      `completing-read' function.  It uses the `commandp' predicate to
  1116.      allow only commands to be entered, and it uses the variable
  1117.      `obarray' so as to be able to complete all extant Lisp symbols:
  1118.  
  1119.           (read-command PROMPT)
  1120.           ==
  1121.           (intern (completing-read PROMPT obarray 'commandp t nil))
  1122.  
  1123.  - Function: read-variable PROMPT
  1124.      This function reads the name of a user variable and returns it as a
  1125.      symbol.
  1126.  
  1127.           (read-variable "Variable name? ")
  1128.           
  1129.           ;; After evaluating the preceding expression,
  1130.           ;;   the following prompt appears,
  1131.           ;;   with an empty minibuffer:
  1132.  
  1133.           ---------- Buffer: Minibuffer ----------
  1134.           Variable name? -!-
  1135.           ---------- Buffer: Minibuffer ----------
  1136.  
  1137.      If the user then types `fill-p RET', `read-variable' will return
  1138.      `fill-prefix'.
  1139.  
  1140.      This function is similar to `read-command', but uses the predicate
  1141.      `user-variable-p' instead of `commandp':
  1142.  
  1143.           (read-variable PROMPT)
  1144.           ==
  1145.           (intern
  1146.            (completing-read PROMPT obarray 'user-variable-p t nil))
  1147.  
  1148. 
  1149. File: elisp,  Node: Reading File Names,  Next: Lisp Symbol Completion,  Prev: High-Level Completion,  Up: Completion
  1150.  
  1151. Reading File Names
  1152. ------------------
  1153.  
  1154.    Here is another high-level completion function, designed for reading
  1155. a file name.  It provides special features including automatic insertion
  1156. of the default directory.
  1157.  
  1158.  - Function: read-file-name PROMPT &optional DIRECTORY DEFAULT EXISTING
  1159.           INITIAL
  1160.      This function reads a file name in the minibuffer, prompting with
  1161.      PROMPT and providing completion.  If DEFAULT is non-`nil', then
  1162.      the function returns DEFAULT if the user just types RET.
  1163.  
  1164.      If EXISTING is non-`nil', then the name must refer to an existing
  1165.      file; then RET performs completion to make the name valid if
  1166.      possible, and then refuses to exit if it is not valid.  If the
  1167.      value of EXISTING is neither `nil' nor `t', then RET also requires
  1168.      confirmation after completion.
  1169.  
  1170.      The argument DIRECTORY specifies the directory to use for
  1171.      completion of relative file names.  Usually it is inserted in the
  1172.      minibuffer as initial input as well.  It defaults to the current
  1173.      buffer's default directory.
  1174.  
  1175.      If you specify INITIAL, that is an initial file name to insert in
  1176.      the buffer along with DIRECTORY.  In this case, point goes after
  1177.      DIRECTORY, before INITIAL.  The default for INITIAL is
  1178.      `nil'--don't insert any file name.  To see what INITIAL does, try
  1179.      the command `C-x C-v'.
  1180.  
  1181.      Here is an example:
  1182.  
  1183.           (read-file-name "The file is ")
  1184.           
  1185.           ;; After evaluating the preceding expression,
  1186.           ;;   the following appears in the minibuffer:
  1187.  
  1188.           ---------- Buffer: Minibuffer ----------
  1189.           The file is /gp/gnu/elisp/-!-
  1190.           ---------- Buffer: Minibuffer ----------
  1191.  
  1192.      Typing `manual TAB' results in the following:
  1193.  
  1194.           ---------- Buffer: Minibuffer ----------
  1195.           The file is /gp/gnu/elisp/manual.texi-!-
  1196.           ---------- Buffer: Minibuffer ----------
  1197.  
  1198.      If the user types RET, `read-file-name' returns
  1199.      `"/gp/gnu/elisp/manual.texi"'.
  1200.  
  1201.  - User Option: insert-default-directory
  1202.      This variable is used by `read-file-name'.  Its value controls
  1203.      whether `read-file-name' starts by placing the name of the default
  1204.      directory in the minibuffer, plus the initial file name if any.
  1205.      If the value of this variable is `nil', then `read-file-name' does
  1206.      not place any initial input in the minibuffer.  In that case, the
  1207.      default directory is still used for completion of relative file
  1208.      names, but is not displayed.
  1209.  
  1210.      For example:
  1211.  
  1212.           ;; Here the minibuffer starts out containing the default directory.
  1213.           
  1214.           (let ((insert-default-directory t))
  1215.             (read-file-name "The file is "))
  1216.  
  1217.           ---------- Buffer: Minibuffer ----------
  1218.           The file is ~lewis/manual/-!-
  1219.           ---------- Buffer: Minibuffer ----------
  1220.  
  1221.           ;; Here the minibuffer is empty and only the prompt
  1222.           ;;   appears on its line.
  1223.           
  1224.           (let ((insert-default-directory nil))
  1225.             (read-file-name "The file is "))
  1226.  
  1227.           ---------- Buffer: Minibuffer ----------
  1228.           The file is -!-
  1229.           ---------- Buffer: Minibuffer ----------
  1230.  
  1231. 
  1232. File: elisp,  Node: Lisp Symbol Completion,  Prev: Reading File Names,  Up: Completion
  1233.  
  1234. Lisp Symbol Completion
  1235. ----------------------
  1236.  
  1237.    If you type a part of a symbol, and then type `M-TAB'
  1238. (`lisp-complete-symbol'), this command attempts to fill in as much more
  1239. of the symbol name as it can.  Not only does this save typing, but it
  1240. can help you with the name of a symbol that you have partially
  1241. forgotten.
  1242.  
  1243.  - Command: lisp-complete-symbol
  1244.      This function performs completion on the symbol name preceding
  1245.      point.  The name is completed against the symbols in the global
  1246.      variable `obarray', and characters from the completion are
  1247.      inserted into the buffer, making the name longer.  If there is
  1248.      more than one completion, a list of all possible completions is
  1249.      placed in the `*Help*' buffer.  The bell rings if there is no
  1250.      possible completion in `obarray'.
  1251.  
  1252.      If an open parenthesis immediately precedes the name, only symbols
  1253.      with function definitions are considered.  (By reducing the number
  1254.      of alternatives, this may succeed in completing more characters.)
  1255.      Otherwise, symbols with either a function definition, a value, or
  1256.      at least one property are considered.
  1257.  
  1258.      `lisp-complete-symbol' returns `t' if the symbol had an exact, and
  1259.      unique, match; otherwise, it returns `nil'.
  1260.  
  1261.      In the following example, the user has already inserted `(forwa'
  1262.      into the buffer `foo.el'.  The command `lisp-complete-symbol' then
  1263.      completes the name to `(forward-'.
  1264.  
  1265.           ---------- Buffer: foo.el ----------
  1266.           (forwa-!-
  1267.           ---------- Buffer: foo.el ----------
  1268.  
  1269.           (lisp-complete-symbol)
  1270.                => nil
  1271.  
  1272.           ---------- Buffer: foo.el ----------
  1273.           (forward--!-
  1274.           ---------- Buffer: foo.el ----------
  1275.  
  1276.