home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / elisp / elisp-26 < prev    next >
Encoding:
GNU Info File  |  1993-05-31  |  47.9 KB  |  1,133 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: Abbrev Tables,  Next: Defining Abbrevs,  Prev: Abbrev Mode,  Up: Abbrevs
  28.  
  29. Abbrev Tables
  30. =============
  31.  
  32.    This section describes how to create and manipulate abbrev tables.
  33.  
  34.  - Function: make-abbrev-table
  35.      This function creates and returns a new, empty abbrev table--an
  36.      obarray containing no symbols.  It is a vector filled with `nil's.
  37.  
  38.  - Function: clear-abbrev-table TABLE
  39.      This function undefines all the abbrevs in abbrev table TABLE,
  40.      leaving it empty.  The function returns `nil'.
  41.  
  42.  - Function: define-abbrev-table TABNAME DEFINITIONS
  43.      This function defines TABNAME (a symbol) as an abbrev table name,
  44.      i.e., as a variable whose value is an abbrev table.  It defines
  45.      abbrevs in the table according to DEFINITIONS, a list of elements
  46.      of the form `(ABBREVNAME EXPANSION HOOK USECOUNT)'.  The value is
  47.      always `nil'.
  48.  
  49.  - Variable: abbrev-table-name-list
  50.      This is a list of symbols whose values are abbrev tables.
  51.      `define-abbrev-table' adds the new abbrev table name to this list.
  52.  
  53.  - Function: insert-abbrev-table-description NAME &optional HUMAN
  54.      This function inserts before point a description of the abbrev
  55.      table named NAME.  The argument NAME is a symbol whose value is an
  56.      abbrev table.  The value is always `nil'.
  57.  
  58.      If HUMAN is non-`nil', a human-oriented description is inserted.
  59.      Otherwise the description is a Lisp expression--a call to
  60.      `define-abbrev-table' which would define NAME exactly as it is
  61.      currently defined.
  62.  
  63. 
  64. File: elisp,  Node: Defining Abbrevs,  Next: Abbrev Files,  Prev: Abbrev Tables,  Up: Abbrevs
  65.  
  66. Defining Abbrevs
  67. ================
  68.  
  69.    These functions define an abbrev in a specified abbrev table.
  70. `define-abbrev' is the low-level basic function, while `add-abbrev' is
  71. used by commands that ask for information from the user.
  72.  
  73.  - Function: add-abbrev TABLE TYPE ARG
  74.      This function adds an abbreviation to abbrev table TABLE.  The
  75.      argument TYPE is a string describing in English the kind of abbrev
  76.      this will be (typically, `"global"' or `"mode-specific"'); this is
  77.      used in prompting the user.  The argument ARG is the number of
  78.      words in the expansion.
  79.  
  80.      The return value is the symbol which internally represents the new
  81.      abbrev, or `nil' if the user declines to redefine an existing
  82.      abbrev.
  83.  
  84.  - Function: define-abbrev TABLE NAME EXPANSION HOOK
  85.      This function defines an abbrev in TABLE named NAME, to expand to
  86.      EXPANSION, and call HOOK.  The return value is an uninterned
  87.      symbol which represents the abbrev inside Emacs; its name is NAME.
  88.  
  89.      The argument NAME should be a string.  The argument EXPANSION
  90.      should be a string, or `nil', to undefine the abbrev.
  91.  
  92.      The argument HOOK is a function or `nil'.  If HOOK is non-`nil',
  93.      then it is called with no arguments after the abbrev is replaced
  94.      with EXPANSION; point is located at the end of EXPANSION.
  95.  
  96.      The use count of the abbrev is initialized to zero.
  97.  
  98.  - User Option: only-global-abbrevs
  99.      If this variable is non-`nil', it means that the user plans to use
  100.      global abbrevs only.  This tells the commands that define
  101.      mode-specific abbrevs to define global ones instead.  This
  102.      variable does not alter the functioning of the functions in this
  103.      section; it is examined by their callers.
  104.  
  105. 
  106. File: elisp,  Node: Abbrev Files,  Next: Abbrev Expansion,  Prev: Defining Abbrevs,  Up: Abbrevs
  107.  
  108. Saving Abbrevs in Files
  109. =======================
  110.  
  111.    A file of saved abbrev definitions is actually a file of Lisp code.
  112. The abbrevs are saved in the form of a Lisp program to define the same
  113. abbrev tables with the same contents.  Therefore, you can load the file
  114. with `load' (*note How Programs Do Loading::.).  However, the function
  115. `quietly-read-abbrev-file' is provided as a more convenient interface.
  116.  
  117.    User-level facilities such as `save-some-buffers' can save abbrevs
  118. in a file automatically, under the control of variables described here.
  119.  
  120.  - User Option: abbrev-file-name
  121.      This is the default file name for reading and saving abbrevs.
  122.  
  123.  - Function: quietly-read-abbrev-file FILENAME
  124.      This function reads abbrev definitions from a file named FILENAME,
  125.      previously written with `write-abbrev-file'.  If FILENAME is
  126.      `nil', the file specified in `abbrev-file-name' is used.
  127.      `save-abbrevs' is set to `t' so that changes will be saved.
  128.  
  129.      This function does not display any messages.  It returns `nil'.
  130.  
  131.  - User Option: save-abbrevs
  132.      A non-`nil' value for `save-abbrev' means that Emacs should save
  133.      abbrevs when files are saved.  `abbrev-file-name' specifies the
  134.      file to save the abbrevs in.
  135.  
  136.  - Variable: abbrevs-changed
  137.      This variable is set non-`nil' by defining or altering any
  138.      abbrevs.  This serves as a flag for various Emacs commands to
  139.      offer to save your abbrevs.
  140.  
  141.  - Command: write-abbrev-file FILENAME
  142.      Save all abbrev definitions, in all abbrev tables, in the file
  143.      FILENAME, in the form of a Lisp program which when loaded will
  144.      define the same abbrevs.  This function returns `nil'.
  145.  
  146. 
  147. File: elisp,  Node: Abbrev Expansion,  Next: Standard Abbrev Tables,  Prev: Abbrev Files,  Up: Abbrevs
  148.  
  149. Looking Up and Expanding Abbreviations
  150. ======================================
  151.  
  152.    Abbrevs are usually expanded by commands for interactive use,
  153. including `self-insert-command'.  This section describes the
  154. subroutines used in writing such functions, as well as the variables
  155. they use for communication.
  156.  
  157.  - Function: abbrev-symbol ABBREV &optional TABLE
  158.      This function returns the symbol representing the abbrev named
  159.      ABBREV.  The value returned is `nil' if that abbrev is not
  160.      defined.  The optional second argument TABLE is the abbrev table
  161.      to look it up in.  By default, this function tries first the
  162.      current buffer's local abbrev table, and second the global abbrev
  163.      table.
  164.  
  165.  - User Option: abbrev-all-caps
  166.      When this is set non-`nil', an abbrev entered entirely in upper
  167.      case is expanded using all upper case.  Otherwise, an abbrev
  168.      entered entirely in upper case is expanded by capitalizing each
  169.      word of the expansion.
  170.  
  171.  - Function: abbrev-expansion ABBREV &optional TABLE
  172.      This function returns the string that ABBREV would expand into (as
  173.      defined by the abbrev tables used for the current buffer).  The
  174.      optional argument TABLE specifies the abbrev table to use; if it is
  175.      specified, the abbrev is looked up in that table only.
  176.  
  177.  - Variable: abbrev-start-location
  178.      This is the buffer position for `expand-abbrev' to use as the start
  179.      of the next abbrev to be expanded.  (`nil' means use the word
  180.      before point instead.)  `abbrev-start-location' is set to `nil'
  181.      each time `expand-abbrev' is called.  This variable is also set by
  182.      `abbrev-prefix-mark'.
  183.  
  184.  - Variable: abbrev-start-location-buffer
  185.      The value of this variable is the buffer for which
  186.      `abbrev-start-location' has been set.  Trying to expand an abbrev
  187.      in any other buffer clears `abbrev-start-location'.  This variable
  188.      is set by `abbrev-prefix-mark'.
  189.  
  190.  - Variable: last-abbrev
  191.      This is the `abbrev-symbol' of the last abbrev expanded.  This
  192.      information is left by `expand-abbrev' for the sake of the
  193.      `unexpand-abbrev' command.
  194.  
  195.  - Variable: last-abbrev-location
  196.      This is the location of the last abbrev expanded.  This contains
  197.      information left by `expand-abbrev' for the sake of the
  198.      `unexpand-abbrev' command.
  199.  
  200.  - Variable: last-abbrev-text
  201.      This is the exact expansion  text of the last abbrev expanded, as
  202.      results from case conversion.  Its value is `nil' if the abbrev
  203.      has already been unexpanded.  This contains information left by
  204.      `expand-abbrev' for the sake of the `unexpand-abbrev' command.
  205.  
  206.  - Variable: pre-abbrev-expand-hook
  207.      This is a normal hook whose functions are executed, in sequence,
  208.      just before any expansion of an abbrev.  *Note Hooks::.  Since it
  209.      is a normal hook, the hook functions receive no arguments.
  210.      However, they can find the abbrev to be expanded by looking in the
  211.      buffer before point.
  212.  
  213.    The following sample code shows a simple use of
  214. `pre-abbrev-expand-hook'.  If the user terminates an abbrev with a
  215. punctuation character, the function issues a prompt.  Thus, this hook
  216. allows the user to decide whether the abbrev should be expanded, and to
  217. abort expansion if it is not desired.
  218.  
  219.      (add-hook 'pre-abbrev-expand-hook 'query-if-not-space)
  220.      
  221.      ;; This is the function invoked by `pre-abbrev-expand-hook'.
  222.      
  223.      ;; If the user terminated the abbrev with a space, the function does
  224.      ;; nothing (that is, it returns so that the abbrev can expand).  If the
  225.      ;; user entered some other character, this function asks whether
  226.      ;; expansion should continue.
  227.      
  228.      ;; If the user enters the prompt with `y', the function returns
  229.      ;; `nil' (because of the `not' function), but that is
  230.      ;; acceptable; the return value has no effect on expansion.
  231.      
  232.      (defun query-if-not-space ()
  233.        (if (/= ?\  (preceding-char))
  234.            (if (not (y-or-n-p "Do you want to expand this abbrev? "))
  235.                (error "Not expanding this abbrev"))))
  236.  
  237. 
  238. File: elisp,  Node: Standard Abbrev Tables,  Prev: Abbrev Expansion,  Up: Abbrevs
  239.  
  240. Standard Abbrev Tables
  241. ======================
  242.  
  243.    Here we list the variables that hold the abbrev tables for the
  244. preloaded major modes of Emacs.
  245.  
  246.  - Variable: global-abbrev-table
  247.      This is the abbrev table for mode-independent abbrevs.  The abbrevs
  248.      defined in it apply to all buffers.  Each buffer may also have a
  249.      local abbrev table, whose abbrev definitions take precedence over
  250.      those in the global table.
  251.  
  252.  - Variable: local-abbrev-table
  253.      The value of this buffer-local variable is the (mode-specific)
  254.      abbreviation table of the current buffer.
  255.  
  256.  - Variable: fundamental-mode-abbrev-table
  257.      This is the local abbrev table used in Fundamental mode.  It is the
  258.      local abbrev table in all buffers in Fundamental mode.
  259.  
  260.  - Variable: text-mode-abbrev-table
  261.      This is the local abbrev table used in Text mode.
  262.  
  263.  - Variable: c-mode-abbrev-table
  264.      This is the local abbrev table used in C mode.
  265.  
  266.  - Variable: lisp-mode-abbrev-table
  267.      This is the local abbrev table used in Lisp mode and Emacs Lisp
  268.      mode.
  269.  
  270. 
  271. File: elisp,  Node: Processes,  Next: System Interface,  Prev: Abbrevs,  Up: Top
  272.  
  273. Processes
  274. *********
  275.  
  276.    In the terminology of operating systems, a "process" is a space in
  277. which a program can execute.  Emacs runs in a process.  Emacs Lisp
  278. programs can invoke other programs in processes of their own.  These are
  279. called "subprocesses" or "child processes" of the Emacs process, which
  280. is their "parent process".
  281.  
  282.    A subprocess of Emacs may be "synchronous" or "asynchronous",
  283. depending on how it is created.  When you create a synchronous
  284. subprocess, the Lisp program waits for the subprocess to terminate
  285. before continuing execution.  When you create an asynchronous
  286. subprocess, it can run in parallel with the Lisp program.  This kind of
  287. subprocess is represented within Emacs by a Lisp object which is also
  288. called a "process".  Lisp programs can use this object to communicate
  289. with the subprocess or to control it.  For example, you can send
  290. signals, obtain status information, receive output from the process, or
  291. send input to it.
  292.  
  293.  - Function: processp OBJECT
  294.      This function returns `t' if OBJECT is a process, `nil' otherwise.
  295.  
  296. * Menu:
  297.  
  298. * Subprocess Creation::      Functions that start subprocesses.
  299. * Synchronous Processes::    Details of using synchronous subprocesses.
  300. * Asynchronous Processes::   Starting up an asynchronous subprocess.
  301. * Deleting Processes::       Eliminating an asynchronous subprocess.
  302. * Process Information::      Accessing run-status and other attributes.
  303. * Input to Processes::       Sending input to an asynchronous subprocess.
  304. * Signals to Processes::     Stopping, continuing or interrupting
  305.                                an asynchronous subprocess.
  306. * Output from Processes::    Collecting output from an asynchronous subprocess.
  307. * Sentinels::                Sentinels run when process run-status changes.
  308. * Transaction Queues::         Transaction-based communication with subprocesses.
  309. * TCP::                      Opening network connections.
  310.  
  311. 
  312. File: elisp,  Node: Subprocess Creation,  Next: Synchronous Processes,  Up: Processes
  313.  
  314. Functions that Create Subprocesses
  315. ==================================
  316.  
  317.    There are three functions that create a new subprocess in which to
  318. run a program.  One of them, `start-process', creates an asynchronous
  319. process and returns a process object (*note Asynchronous Processes::.).
  320. The other two, `call-process' and `call-process-region', create a
  321. synchronous process and do not return a process object (*note
  322. Synchronous Processes::.).
  323.  
  324.    Synchronous and asynchronous processes are explained in following
  325. sections.  Since the three functions are all called in a similar
  326. fashion, their common arguments are described here.
  327.  
  328.    In all cases, the function's PROGRAM argument specifies the program
  329. to be run.  An error is signaled if the file is not found or cannot be
  330. executed.  The actual file containing the program is found by following
  331. normal system rules: if the file name is absolute, then the program
  332. must be found in the specified file; if the name is relative, then the
  333. directories in `exec-path' are searched sequentially for a suitable
  334. file.  The variable `exec-path' is initialized when Emacs is started,
  335. based on the value of the environment variable `PATH'.  The standard
  336. file name constructs, `~', `.', and `..', are interpreted as usual in
  337. `exec-path', but environment variable substitutions (`$HOME', etc.) are
  338. not recognized; use `substitute-in-file-name' to perform them (*note
  339. File Name Expansion::.).
  340.  
  341.    Each of the subprocess-creating functions has a BUFFER-OR-NAME
  342. argument which specifies where the standard output from the program will
  343. go.  If BUFFER-OR-NAME is `nil', that says to discard the output unless
  344. a filter function handles it.  (*Note Filter Functions::, and *Note
  345. Streams::.)  Normally, you should avoid having multiple processes send
  346. output to the same buffer because their output would be intermixed
  347. randomly.
  348.  
  349.    All three of the subprocess-creating functions have a `&rest'
  350. argument, ARGS.  The ARGS must all be strings, and they are supplied to
  351. PROGRAM as separate command line arguments.  Wildcard characters and
  352. other shell constructs are not allowed in these strings, since they are
  353. passed directly to the specified program.
  354.  
  355.    *Please note:* the argument PROGRAM contains only the name of the
  356. program; it may not contain any command-line arguments.  Such arguments
  357. must be provided via ARGS.
  358.  
  359.    The subprocess gets its current directory from the value of
  360. `default-directory' (*note File Name Expansion::.).
  361.  
  362.    The subprocess inherits its environment from Emacs; but you can
  363. specify overrides for it with `process-environment'.  *Note System
  364. Environment::.
  365.  
  366.  - Variable: exec-directory
  367.      The value of this variable is the name of a directory (a string)
  368.      that contains programs that come with GNU Emacs, that are intended
  369.      for Emacs to invoke.  The program `wakeup' is an example of such a
  370.      program; the `display-time' command uses it to get a reminder once
  371.      per minute.
  372.  
  373.      The default value is the name of a directory whose name ends in
  374.      `arch-lib'.  We call the directory `emacs/arch-lib', since its
  375.      name usually ends that way.  We sometimes refer to "the directory
  376.      `emacs/arch-lib'," when strictly speaking we ought to say, "the
  377.      directory named by the variable `exec-directory'."  Most of the
  378.      time, there is no difference.
  379.  
  380.      (In earlier Emacs versions, prior to version 19, these files lived
  381.      in the directory `emacs/etc' instead of in `emacs/arch-lib'.)
  382.  
  383.  - User Option: exec-path
  384.      The value of this variable is a list of directories to search for
  385.      programs to run in subprocesses.  Each element is either the name
  386.      of a directory (i.e., a string), or `nil', which stands for the
  387.      default directory (which is the value of `default-directory').
  388.  
  389.      The value of `exec-path' is used by `call-process' and
  390.      `start-process' when the PROGRAM argument is not an absolute file
  391.      name.
  392.  
  393. 
  394. File: elisp,  Node: Synchronous Processes,  Next: Asynchronous Processes,  Prev: Subprocess Creation,  Up: Processes
  395.  
  396. Creating a Synchronous Process
  397. ==============================
  398.  
  399.    After a "synchronous process" is created, Emacs waits for the
  400. process to terminate before continuing.  Starting Dired is an example of
  401. this: it runs `ls' in a synchronous process, then modifies the output
  402. slightly.  Because the process is synchronous, the entire directory
  403. listing arrives in the buffer before Emacs tries to do anything with it.
  404.  
  405.    While Emacs waits for the synchronous subprocess to terminate, the
  406. user can quit by typing `C-g', and the process is killed by sending it
  407. a `SIGKILL' signal.  *Note Quitting::.
  408.  
  409.    The synchronous subprocess functions return `nil' in version 18.  In
  410. version 19, they will return an indication of how the process
  411. terminated.
  412.  
  413.  - Function: call-process PROGRAM &optional INFILE BUFFER-OR-NAME
  414.           DISPLAY &rest ARGS
  415.      This function calls PROGRAM in a separate process and waits for it
  416.      to finish.
  417.  
  418.      The standard input for the process comes from file INFILE if
  419.      INFILE is not `nil' and from `/dev/null' otherwise.  The process
  420.      output gets inserted in buffer BUFFER-OR-NAME before point, if
  421.      that argument names a buffer.  If BUFFER-OR-NAME is `t', output is
  422.      sent to the current buffer; if BUFFER-OR-NAME is `nil', output is
  423.      discarded.
  424.  
  425.      If BUFFER-OR-NAME is the integer 0, `call-process' returns `nil'
  426.      immediately and discards any output.  In this case, the process is
  427.      not truly synchronous, since it can run in parallel with Emacs;
  428.      but you can think of it as synchronous in that Emacs is
  429.      essentially finished with the subprocess as soon as this function
  430.      returns.
  431.  
  432.      If DISPLAY is non-`nil', then `call-process' redisplays the buffer
  433.      as output is inserted.  Otherwise the function does no redisplay,
  434.      and the results become visible on the screen only when Emacs
  435.      redisplays that buffer in the normal course of events.
  436.  
  437.      The remaining arguments, ARGS, are strings that are supplied as
  438.      the command line arguments for the program.
  439.  
  440.      The value returned by `call-process' (unless you told it not to
  441.      wait) indicates the reason for process termination.  A number
  442.      gives the exit status of the subprocess; 0 means success, and any
  443.      other value means failure.  If the process terminated with a
  444.      signal, `call-process' returns a string describing the signal.
  445.  
  446.      The examples below are both run with the buffer `foo' current.
  447.  
  448.           (call-process "pwd" nil t)
  449.                => nil
  450.           
  451.           ---------- Buffer: foo ----------
  452.           /usr/user/lewis/manual
  453.           ---------- Buffer: foo ----------
  454.  
  455.           (call-process "grep" nil "bar" nil "lewis" "/etc/passwd")
  456.                => nil
  457.           
  458.           ---------- Buffer: bar ----------
  459.           lewis:5LTsHm66CSWKg:398:21:Bil Lewis:/user/lewis:/bin/csh
  460.           
  461.           ---------- Buffer: bar ----------
  462.  
  463.      The `dired-readin' function contains a good example of the use of
  464.      `call-process':
  465.  
  466.           (call-process
  467.            "ls" nil buffer nil dired-listing-switches dirname)
  468.  
  469.  - Function: call-process-region START END PROGRAM &optional DELETE
  470.           BUFFER-OR-NAME DISPLAY &rest ARGS
  471.      This function sends the text between START to END as standard
  472.      input to a process running PROGRAM.  It deletes the text sent if
  473.      DELETE is non-`nil', which may be useful when the output is going
  474.      to be inserted back in the current buffer.
  475.  
  476.      If BUFFER-OR-NAME names a buffer, the output is inserted in that
  477.      buffer at point.  If BUFFER-OR-NAME is `t', the output is sent to
  478.      the current buffer.  If BUFFER-OR-NAME is `nil', the output is
  479.      discarded.  If BUFFER-OR-NAME is the integer 0, the output is
  480.      discarded and `call-process' returns `nil' immediately, just as
  481.      `call-process' would.
  482.  
  483.      If DISPLAY is non-`nil', then `call-process-region' redisplays the
  484.      buffer as output is inserted.  Otherwise the function does no
  485.      redisplay, and the results become visible on the screen only when
  486.      Emacs redisplays that buffer in the normal course of events.
  487.  
  488.      The remaining arguments, ARGS, are strings that are supplied as
  489.      the command line arguments for the program.
  490.  
  491.      The return value of `call-process-region' is just like that of
  492.      `call-process': `nil' if you told it to return without waiting;
  493.      otherwise, a number or string which indicates how the subprocess
  494.      terminated.
  495.  
  496.      In the following example, we use `call-process-region' to run the
  497.      `cat' utility, with standard input being the first five characters
  498.      in buffer `foo' (the word `input').  `cat' copies its standard
  499.      input into its standard output.  Since the argument BUFFER-OR-NAME
  500.      is `t', this output is inserted in the current buffer.
  501.  
  502.           ---------- Buffer: foo ----------
  503.           input-!-
  504.           ---------- Buffer: foo ----------
  505.  
  506.           (call-process-region 1 6 "cat" nil t)
  507.                => nil
  508.           
  509.           ---------- Buffer: foo ----------
  510.           inputinput-!-
  511.           ---------- Buffer: foo ----------
  512.  
  513.      The `shell-command-on-region' command uses `call-process-region'
  514.      like this:
  515.  
  516.           (call-process-region
  517.            start end
  518.            shell-file-name      ; Name of program.
  519.            nil                  ; Do not delete region.
  520.            buffer               ; Send output to `buffer'.
  521.            nil                  ; No redisplay during output.
  522.            "-c" command)        ; Arguments for the shell.
  523.  
  524. 
  525. File: elisp,  Node: Asynchronous Processes,  Next: Deleting Processes,  Prev: Synchronous Processes,  Up: Processes
  526.  
  527. Creating an Asynchronous Process
  528. ================================
  529.  
  530.    After an "asynchronous process" is created, Emacs and the Lisp
  531. program can continue running immediately.  The process may thereafter
  532. run in parallel with Emacs, and the two may communicate with each other
  533. using the functions described in following sections.  Here we describe
  534. how to create an asynchronous process, with `start-process'.
  535.  
  536.  - Function: start-process NAME BUFFER-OR-NAME PROGRAM &rest ARGS
  537.      This function creates a new asynchronous subprocess and starts the
  538.      program PROGRAM running in it.  It returns a process object that
  539.      stands for the new subprocess for Emacs Lisp programs.  The
  540.      argument NAME specifies the name for the process object; if a
  541.      process with this name already exists, then NAME is modified (by
  542.      adding `<1>', etc.) to be unique.  The buffer BUFFER-OR-NAME is the
  543.      buffer to associate with the process.
  544.  
  545.      The remaining arguments, ARGS, are strings that are supplied as
  546.      the command line arguments for the program.
  547.  
  548.      In the example below, the first process is started and runs
  549.      (rather, sleeps) for 100 seconds.  Meanwhile, the second process
  550.      is started, given the name `my-process<1>' for the sake of
  551.      uniqueness.  It inserts the directory listing at the end of the
  552.      buffer `foo', before the first process finishes.  Then it
  553.      finishes, and a message to that effect is inserted in the buffer.
  554.      Much later, the first process finishes, and another message is
  555.      inserted in the buffer for it.
  556.  
  557.           (start-process "my-process" "foo" "sleep" "100")
  558.                => #<process my-process>
  559.  
  560.           (start-process "my-process" "foo" "ls" "-l" "/user/lewis/bin")
  561.                => #<process my-process<1>>
  562.           
  563.           ---------- Buffer: foo ----------
  564.           total 2
  565.           lrwxrwxrwx  1 lewis     14 Jul 22 10:12 gnuemacs --> /emacs
  566.           -rwxrwxrwx  1 lewis     19 Jul 30 21:02 lemon
  567.           
  568.           Process my-process<1> finished
  569.           
  570.           Process my-process finished
  571.           ---------- Buffer: foo ----------
  572.  
  573.  - Function: start-process-shell-command NAME BUFFER-OR-NAME COMMAND
  574.           &rest COMMAND-ARGS
  575.      This function is like `start-process' except that it uses a shell
  576.      to execute the specified command.  The argument COMMAND is a shell
  577.      command name, and COMMAND-ARGS are the arguments for the shell
  578.      command.
  579.  
  580.  - Variable: process-connection-type
  581.      This variable controls the type of device used to communicate with
  582.      asynchronous subprocesses.  If it is `nil', then pipes are used.
  583.      If it is `t', then PTYs are used (or pipes if PTYs are not
  584.      supported).
  585.  
  586.      PTYs are usually preferable for processes visible to the user, as
  587.      in Shell mode, because they allow job control (`C-c', `C-z', etc.)
  588.      to work between the process and its children whereas pipes do not.
  589.      For subprocesses used for internal purposes by programs, it is
  590.      often better to use a pipe, because they are more efficient.  In
  591.      addition, the total number of PTYs is limited on many systems and
  592.      it is good not to waste them.
  593.  
  594.      The value `process-connection-type' is used when `start-process'
  595.      is called, so in order to change it for just one call of
  596.      `start-process', temporarily rebind it with `let'.
  597.  
  598.           (let ((process-connection-type nil))  ; Use a pipe.
  599.             (start-process ...))
  600.  
  601. 
  602. File: elisp,  Node: Deleting Processes,  Next: Process Information,  Prev: Asynchronous Processes,  Up: Processes
  603.  
  604. Deleting Processes
  605. ==================
  606.  
  607.    "Deleting a process" disconnects Emacs immediately from the
  608. subprocess, and removes it from the list of active processes.  It sends
  609. a signal to the subprocess to make the subprocess terminate, but this is
  610. not guaranteed to happen immediately.  (The process object itself
  611. continues to exist as long as other Lisp objects point to it.)
  612.  
  613.    You can delete a process explicitly at any time.  Processes are
  614. deleted automatically after they terminate, but not necessarily right
  615. away.  If you delete a terminated process explicitly before it is
  616. deleted automatically, no harm results.
  617.  
  618.  - Variable: delete-exited-processes
  619.      This variable controls automatic deletion of processes that have
  620.      terminated (due to calling `exit' or to a signal).  If it is
  621.      `nil', then they continue to exist until the user runs
  622.      `list-processes'.  Otherwise, they are deleted immediately after
  623.      they exit.
  624.  
  625.  - Function: delete-process NAME
  626.      This function deletes the process associated with NAME.  The
  627.      argument NAME may be a process, the name of a process, a buffer,
  628.      or the name of a buffer.  The subprocess is killed with a `SIGHUP'
  629.      signal.
  630.  
  631.           (delete-process "*shell*")
  632.                => nil
  633.  
  634.  - Function: process-kill-without-query PROCESS
  635.      This function declares that Emacs need not query the user if
  636.      PROCESS is still running when Emacs is exited.  The process will
  637.      be deleted silently.  The value is `t'.
  638.  
  639.           (process-kill-without-query (get-process "shell"))
  640.                => t
  641.  
  642. 
  643. File: elisp,  Node: Process Information,  Next: Input to Processes,  Prev: Deleting Processes,  Up: Processes
  644.  
  645. Process Information
  646. ===================
  647.  
  648.    Several functions return information about processes.
  649. `list-processes' is provided for interactive use.
  650.  
  651.  - Command: list-processes
  652.      This command displays a listing of all living processes.  (Any
  653.      processes listed as `Exited' or `Signaled' are actually eliminated
  654.      after the listing is made.)  This function returns `nil'.
  655.  
  656.  - Function: process-list
  657.      This function returns a list of all processes that have not been
  658.      deleted.
  659.  
  660.           (process-list)
  661.                => (#<process display-time> #<process shell>)
  662.  
  663.  - Function: get-process NAME
  664.      This function returns the process named NAME, or `nil' if there is
  665.      none.  An error is signaled if NAME is not a string.
  666.  
  667.           (get-process "shell")
  668.                => #<process shell>
  669.  
  670.  - Function: process-command PROCESS
  671.      This function returns the command that was executed to start
  672.      PROCESS.  This is a list of strings, the first string being the
  673.      program executed and the rest of the strings being the arguments
  674.      that were given to the program.
  675.  
  676.           (process-command (get-process "shell"))
  677.                => ("/bin/csh" "-i")
  678.  
  679.  - Function: process-exit-status PROCESS
  680.      This function returns the exit status of PROCESS or the signal
  681.      number that killed it.  (Use the result of `process-status' to
  682.      determine which of those it is.)  If PROCESS has not yet
  683.      terminated, the value is 0.
  684.  
  685.  - Function: process-id PROCESS
  686.      This function returns the PID of PROCESS.  This is an integer
  687.      which distinguishes the process PROCESS from all other processes
  688.      running on the same computer at the current time.  The PID of a
  689.      process is chosen by the operating system kernel when the process
  690.      is started and remains constant as long as the process exists.
  691.  
  692.  - Function: process-name PROCESS
  693.      This function returns the name of PROCESS.
  694.  
  695.  - Function: process-status PROCESS-NAME
  696.      This function returns the status of PROCESS-NAME as a symbol.  The
  697.      argument PROCESS-NAME must be either a process or a string.  If it
  698.      is a string, it need not name an actual process.
  699.  
  700.      The possible values for an actual subprocess are:
  701.  
  702.     `run'
  703.           for a process that is running.
  704.  
  705.     `stop'
  706.           for a process that is stopped but continuable.
  707.  
  708.     `exit'
  709.           for a process that has exited.
  710.  
  711.     `signal'
  712.           for a process that has received a fatal signal.
  713.  
  714.     `open'
  715.           for a network connection that is open.
  716.  
  717.     `closed'
  718.           for a network connection that is closed.  Once a connection
  719.           is closed, you cannot reopen it, though you might be able to
  720.           open a new connection to the same place.
  721.  
  722.     `nil'
  723.           if PROCESS-NAME is not the name of an existing process.
  724.  
  725.           (process-status "shell")
  726.                => run
  727.  
  728.           (process-status "never-existed")
  729.                => nil
  730.  
  731.           x
  732.                => #<process xx<1>>
  733.           (process-status x)
  734.                => exit
  735.  
  736.      For a network connection, `process-status' returns one of the
  737.      symbols `open' or `closed'.  The latter means that the other side
  738.      closed the connection, or Emacs did `delete-process'.
  739.  
  740.      In earlier Emacs versions (prior to version 19), the status of a
  741.      network connection was `run' if open, and `exit' if closed.
  742.  
  743. 
  744. File: elisp,  Node: Input to Processes,  Next: Signals to Processes,  Prev: Process Information,  Up: Processes
  745.  
  746. Sending Input to Processes
  747. ==========================
  748.  
  749.    Asynchronous subprocesses receive input when it is sent to them by
  750. Emacs, which is done with the functions in this section.  You must
  751. specify the process to send input to, and the input data to send.  The
  752. data appears on the "standard input" of the subprocess.
  753.  
  754.    Some operating systems have limited space for buffered input in a
  755. PTY.  On these systems, the subprocess will cease to read input
  756. correctly if you send an input line longer than the system can handle.
  757. You cannot avoid the problem by breaking the input into pieces and
  758. sending them separately, for the operating system will still have to put
  759. all the pieces together in the input buffer before it lets the
  760. subprocess read the line.  The only solution is to put the input in a
  761. temporary file, and send the process a brief command to read that file.
  762.  
  763.  - Function: process-send-string PROCESS-NAME STRING
  764.      This function sends PROCESS-NAME the contents of STRING as
  765.      standard input.  The argument PROCESS-NAME must be a process or
  766.      the name of a process.
  767.  
  768.      The function returns `nil'.
  769.  
  770.           (process-send-string "shell<1>" "ls\n")
  771.                => nil
  772.  
  773.           ---------- Buffer: *shell* ----------
  774.           ...
  775.           introduction.texi               syntax-tables.texi~
  776.           introduction.texi~              text.texi
  777.           introduction.txt                text.texi~
  778.           ...
  779.           ---------- Buffer: *shell* ----------
  780.  
  781.  - Command: process-send-region PROCESS-NAME START END
  782.      This function sends the text in the region defined by START and
  783.      END as standard input to PROCESS-NAME, which is a process or a
  784.      process name.
  785.  
  786.      An error is signaled unless both START and END are integers or
  787.      markers that indicate positions in the current buffer.  (It is
  788.      unimportant which number is larger.)
  789.  
  790.  - Function: process-send-eof &optional PROCESS-NAME
  791.      This function makes PROCESS-NAME see an end-of-file in its input.
  792.      The EOF comes after any text already sent to it.
  793.  
  794.      If PROCESS-NAME is not supplied, or if it is `nil', then this
  795.      function sends the EOF to the current buffer's process.  An error
  796.      is signaled if the current buffer has no process.
  797.  
  798.      The function returns PROCESS-NAME.
  799.  
  800.           (process-send-eof "shell")
  801.                => "shell"
  802.  
  803. 
  804. File: elisp,  Node: Signals to Processes,  Next: Output from Processes,  Prev: Input to Processes,  Up: Processes
  805.  
  806. Sending Signals to Processes
  807. ============================
  808.  
  809.    "Sending a signal" to a subprocess is a way of interrupting its
  810. activities.  There are several different signals, each with its own
  811. meaning.  For example, the signal `SIGINT' means that the user has
  812. typed `C-c', or that some analogous thing has happened.
  813.  
  814.    Each signal has a standard effect on the subprocess.  Most signals
  815. kill the subprocess, but some stop or resume execution instead.  Most
  816. signals can optionally be handled by programs; if the program handles
  817. the signal, then we can say nothing in general about its effects.
  818.  
  819.    The set of signals and their names is defined by the operating
  820. system; Emacs has facilities for sending only a few of the signals that
  821. are defined.  Emacs can send signals only to its own subprocesses.
  822.  
  823.    You can send signals explicitly by calling the functions in this
  824. section.  Emacs also sends signals automatically at certain times:
  825. killing a buffer sends a `SIGHUP' signal to all its associated
  826. processes; killing Emacs sends a `SIGHUP' signal to all remaining
  827. processes.  (`SIGHUP' is a signal that usually indicates that the user
  828. hung up the phone.)
  829.  
  830.    Each of the signal-sending functions takes two optional arguments:
  831. PROCESS-NAME and CURRENT-GROUP.
  832.  
  833.    The argument PROCESS-NAME must be either a process, the name of one,
  834. or `nil'.  If it is `nil', the process defaults to the process
  835. associated with the current buffer.  An error is signaled if
  836. PROCESS-NAME does not identify a process.
  837.  
  838.    The argument CURRENT-GROUP is a flag that makes a difference when
  839. you are running a job-control shell as an Emacs subprocess.  If it is
  840. non-`nil', then the signal is sent to the current process-group of the
  841. terminal which Emacs uses to communicate with the subprocess.  If the
  842. process is a job-control shell, this means the shell's current subjob.
  843. If it is `nil', the signal is sent to the process group of the
  844. immediate subprocess of Emacs.  If the subprocess is a job-control
  845. shell, this is the shell itself.
  846.  
  847.    The flag CURRENT-GROUP has no effect when a pipe is used to
  848. communicate with the subprocess, because the operating system does not
  849. support the distinction in the case of pipes.  For the same reason,
  850. job-control shells won't work when a pipe is used.  See
  851. `process-connection-type' in *Note Asynchronous Processes::.
  852.  
  853.  - Function: interrupt-process &optional PROCESS-NAME CURRENT-GROUP
  854.      This function interrupts the process PROCESS-NAME by sending the
  855.      signal `SIGINT'.  Outside of Emacs, typing the "interrupt
  856.      character" (normally `C-c' on some systems, and `DEL' on others)
  857.      sends this signal.  When the argument CURRENT-GROUP is non-`nil',
  858.      you can think of this function as "typing `C-c'" on the terminal
  859.      by which Emacs talks to the subprocess.
  860.  
  861.  - Function: kill-process &optional PROCESS-NAME CURRENT-GROUP
  862.      This function kills the process PROCESS-NAME by sending the signal
  863.      `SIGKILL'.  This signal kills the subprocess immediately, and
  864.      cannot be handled by the subprocess.
  865.  
  866.  - Function: quit-process &optional PROCESS-NAME CURRENT-GROUP
  867.      This function sends the signal `SIGQUIT' to the process
  868.      PROCESS-NAME.  This signal is the one sent by the "quit character"
  869.      (usually `C-b' or `C-\') when you are not inside Emacs.
  870.  
  871.  - Function: stop-process &optional PROCESS-NAME CURRENT-GROUP
  872.      This function stops the process PROCESS-NAME by sending the signal
  873.      `SIGTSTP'.  Use `continue-process' to resume its execution.
  874.  
  875.      On systems with job control, the "stop character" (usually `C-z')
  876.      sends this signal (outside of Emacs).  When CURRENT-GROUP is
  877.      non-`nil', you can think of this function as "typing `C-z'" on the
  878.      terminal Emacs uses to communicate with the subprocess.
  879.  
  880.  - Function: continue-process &optional PROCESS-NAME CURRENT-GROUP
  881.      This function resumes execution of the process PROCESS by sending
  882.      it the signal `SIGCONT'.  This presumes that PROCESS-NAME was
  883.      stopped previously.
  884.  
  885.  - Function: signal-process PID SIGNAL
  886.      This function sends a signal to process PID, which need not be a
  887.      child of Emacs.  The argument SIGNAL specifies which signal to
  888.      send; it should be an integer.
  889.  
  890. 
  891. File: elisp,  Node: Output from Processes,  Next: Sentinels,  Prev: Signals to Processes,  Up: Processes
  892.  
  893. Receiving Output from Processes
  894. ===============================
  895.  
  896.    There are two ways to receive the output that a subprocess writes to
  897. its standard output stream.  The output can be inserted in a buffer,
  898. which is called the associated buffer of the process, or a function
  899. called the "filter function" can be called to act on the output.
  900.  
  901. * Menu:
  902.  
  903. * Process Buffers::       If no filter, output is put in a buffer.
  904. * Filter Functions::      Filter functions accept output from the process.
  905. * Accepting Output::      Explicitly permitting subprocess output.
  906.                             Waiting for subprocess output.
  907.  
  908. 
  909. File: elisp,  Node: Process Buffers,  Next: Filter Functions,  Up: Output from Processes
  910.  
  911. Process Buffers
  912. ---------------
  913.  
  914.    A process can (and usually does) have an "associated buffer", which
  915. is an ordinary Emacs buffer that is used for two purposes: storing the
  916. output from the process, and deciding when to kill the process.  You
  917. can also use the buffer to identify a process to operate on, since in
  918. normal practice only one process is associated with any given buffer.
  919. Many applications of processes also use the buffer for editing input to
  920. be sent to the process, but this is not built into Emacs Lisp.
  921.  
  922.    Unless the process has a filter function (*note Filter Functions::.),
  923. its output is inserted in the associated buffer.  The position to insert
  924. the output is determined by the `process-mark' (*note Process
  925. Information::.), which is then updated to point to the end of the text
  926. just inserted.  Usually, but not always, the `process-mark' is at the
  927. end of the buffer.  If the process has no buffer and no filter
  928. function, its output is discarded.
  929.  
  930.  - Function: process-buffer PROCESS
  931.      This function returns the associated buffer of the process PROCESS.
  932.  
  933.           (process-buffer (get-process "shell"))
  934.                => #<buffer *shell*>
  935.  
  936.  - Function: process-mark PROCESS
  937.      This function returns the marker which controls where additional
  938.      output from the process will be inserted in the process buffer.
  939.      When output is inserted, the marker is updated to point at the end
  940.      of the output.  This causes successive batches of output to be
  941.      inserted consecutively.
  942.  
  943.      If PROCESS does not insert its output into a buffer, then
  944.      `process-mark' returns a marker that points nowhere.
  945.  
  946.      Filter functions normally should use this marker in the same
  947.      fashion as is done by direct insertion of output in the buffer.  A
  948.      good example of a filter function that uses `process-mark' is
  949.      found at the end of the following section.
  950.  
  951.      When the user is expected to enter input in the process buffer for
  952.      transmission to the process, the process marker is useful for
  953.      distinguishing the new input from previous output.
  954.  
  955.  - Function: set-process-buffer PROCESS BUFFER
  956.      This function sets the buffer associated with PROCESS to BUFFER.
  957.      If BUFFER is `nil', the process will not be associated with any
  958.      buffer.
  959.  
  960.  - Function: get-buffer-process BUFFER-OR-NAME
  961.      This function returns the process associated with BUFFER-OR-NAME.
  962.      If there are several processes associated with it, then one is
  963.      chosen.  (Presently, the one chosen is the one most recently
  964.      created.)  It is usually a bad idea to have more than one process
  965.      associated with the same buffer.
  966.  
  967.           (get-buffer-process "*shell*")
  968.                => #<process shell>
  969.  
  970.      If the process's buffer is killed, the actual child process is
  971.      killed with a `SIGHUP' signal (*note Signals to Processes::.).
  972.  
  973. 
  974. File: elisp,  Node: Filter Functions,  Next: Accepting Output,  Prev: Process Buffers,  Up: Output from Processes
  975.  
  976. Process Filter Functions
  977. ------------------------
  978.  
  979.    A process "filter function" is a function that receives the standard
  980. output from the associated process.  If a process has a filter, then
  981. *all* output from that process, that would otherwise have been in a
  982. buffer, is passed to the filter.  The process buffer is used for output
  983. from the process only when there is no filter.
  984.  
  985.    A filter function must accept two arguments: the associated process
  986. and a string, which is the output.  The function is then free to do
  987. whatever it chooses with the output.
  988.  
  989.    A filter function runs only while Emacs is waiting (e.g., for
  990. terminal input, or for time to elapse, or for process output).  This
  991. avoids the timing errors that could result from running filters at
  992. random places in the middle of other Lisp programs.  You may explicitly
  993. cause Emacs to wait, so that filter functions will run, by calling
  994. `sit-for', `sleep-for' or `accept-process-output' (*note Accepting
  995. Output::.).  Emacs is also waiting when the command loop is reading
  996. input.
  997.  
  998.    Quitting is normally inhibited within a filter function--otherwise,
  999. the effect of typing `C-g' at command level or to quit a user command
  1000. would be unpredictable.  If you want to permit quitting inside a filter
  1001. function, bind `inhibit-quit' to `nil'.  *Note Quitting::.
  1002.  
  1003.    Many filter functions sometimes or always insert the text in the
  1004. process's buffer, mimicking the actions of Emacs when there is no
  1005. filter.  Such filter functions need to use `set-buffer' in order to be
  1006. sure to insert in that buffer.  To avoid setting the current buffer
  1007. semipermanently, these filter functions must use `unwind-protect' to
  1008. make sure to restore the previous current buffer.  They should also
  1009. update the process marker, and in some cases update the value of point.
  1010. Here is how to do these things:
  1011.  
  1012.      (defun ordinary-insertion-filter (proc string)
  1013.        (let ((old-buffer (current-buffer)))
  1014.          (unwind-protect
  1015.              (let (moving)
  1016.                (set-buffer (process-buffer proc))
  1017.                (setq moving (= (point) (process-mark proc)))
  1018.  
  1019.      (save-excursion
  1020.                  ;; Insert the text, moving the process-marker.
  1021.                  (goto-char (process-mark proc))
  1022.                  (insert string)
  1023.                  (set-marker (process-mark proc) (point)))
  1024.                (if moving (goto-char (process-mark proc))))
  1025.            (set-buffer old-buffer))))
  1026.  
  1027. The reason to use an explicit `unwind-protect' rather than letting
  1028. `save-excursion' restore the current buffer is so as to preserve the
  1029. change in point made by `goto-char'.
  1030.  
  1031.    To make the filter force the process buffer to be visible whenever
  1032. new text arrives, insert the following line just before the
  1033. `unwind-protect':
  1034.  
  1035.      (display-buffer (process-buffer proc))
  1036.  
  1037.    To force point to move to the end of the new output no matter where
  1038. it was previously, eliminate the variable `moving' and call `goto-char'
  1039. unconditionally.
  1040.  
  1041.    All filter functions that do regexp searching or matching should save
  1042. and restore the match data.  Otherwise, a filter function that runs
  1043. during a call to `sit-for' might clobber the match data of the program
  1044. that called `sit-for'.  *Note Match Data::.
  1045.  
  1046.    The output to the function may come in chunks of any size.  A program
  1047. that produces the same output twice in a row may send it as one batch
  1048. of 200 characters one time, and five batches of 40 characters the next.
  1049.  
  1050.  - Function: set-process-filter PROCESS FILTER
  1051.      This function gives PROCESS the filter function FILTER.  If FILTER
  1052.      is `nil', then the process will have no filter.
  1053.  
  1054.  - Function: process-filter PROCESS
  1055.      This function returns the filter function of PROCESS, or `nil' if
  1056.      it has none.
  1057.  
  1058.    Here is an example of use of a filter function:
  1059.  
  1060.      (defun keep-output (process output)
  1061.         (setq kept (cons output kept)))
  1062.           => keep-output
  1063.  
  1064.      (setq kept nil)
  1065.           => nil
  1066.  
  1067.      (set-process-filter (get-process "shell") 'keep-output)
  1068.           => keep-output
  1069.  
  1070.      (process-send-string "shell" "ls ~/other\n")
  1071.           => nil
  1072.      kept
  1073.           => ("lewis@slug[8] % "
  1074.  
  1075.      "FINAL-W87-SHORT.MSS    backup.otl              kolstad.mss~
  1076.      address.txt             backup.psf              kolstad.psf
  1077.      backup.bib~             david.mss               resume-Dec-86.mss~
  1078.      backup.err              david.psf               resume-Dec.psf
  1079.      backup.mss              dland                   syllabus.mss
  1080.      "
  1081.      "#backups.mss#          backup.mss~             kolstad.mss
  1082.      ")
  1083.  
  1084.    Here is another, more realistic example, which demonstrates how to
  1085. use the process mark to do insertion in the same fashion as is done when
  1086. there is no filter function:
  1087.  
  1088.      ;; Insert input in the buffer specified by `my-shell-buffer'
  1089.      ;;   and make sure that buffer is shown in some window.
  1090.      (defun my-process-filter (proc str)
  1091.          (let ((cur (selected-window))
  1092.                (pop-up-windows t))
  1093.            (pop-to-buffer my-shell-buffer)
  1094.  
  1095.      (goto-char (point-max))
  1096.            (insert str)
  1097.            (set-marker (process-mark proc) (point-max))
  1098.            (select-window cur)))
  1099.  
  1100. 
  1101. File: elisp,  Node: Accepting Output,  Prev: Filter Functions,  Up: Output from Processes
  1102.  
  1103. Accepting Output from Processes
  1104. -------------------------------
  1105.  
  1106.    Output from asynchronous subprocesses normally arrives only while
  1107. Emacs is waiting for some sort of external event, such as elapsed time
  1108. or terminal input.  Occasionally it is useful in a Lisp program to
  1109. explicitly permit output to arrive at a specific point, or even to wait
  1110. until output arrives from a process.
  1111.  
  1112.  - Function: accept-process-output &optional PROCESS SECONDS MILLISEC
  1113.      This function allows Emacs to read pending output from processes.
  1114.      The output is inserted in the associated buffers or given to their
  1115.      filter functions.  If PROCESS is non-`nil' then this function does
  1116.      not return until some output has been received from PROCESS.
  1117.  
  1118.      The arguments SECONDS and MILLISEC let you specify timeout
  1119.      periods.  The former specifies a period measured in seconds and the
  1120.      latter specifies one measured in milliseconds.  The two time
  1121.      periods thus specified are added together, and
  1122.      `accept-process-output' returns after that much time whether or
  1123.      not there has been any subprocess output.
  1124.  
  1125.      Not all operating systems support waiting periods other than
  1126.      multiples of a second; on those that do not, you get an error if
  1127.      you specify nonzero MILLISEC.
  1128.  
  1129.      The function `accept-process-output' returns non-`nil' if it did
  1130.      get some output, or `nil' if the timeout expired before output
  1131.      arrived.
  1132.  
  1133.