Go to the first, previous, next, last section, table of contents.


Input Streams

These are the possible types of input stream, for the functions which use them see section Input Functions.

file
Characters are read from the file object file, for the functions which manipulate file objects see section Files.
mark
The marker mark points to the next character that will be read. Each time a character is read the position that mark points to will be advanced to the following character. See section Marks.
buffer
Reads from the position of the cursor in the buffer buffer. This position is advanced as characters are read.
(buffer . position)
Characters are read from the position position in the buffer buffer. position is advanced to the next character as each character is read.
function
Each time an input character is required the function is called with no arguments. It should return the character read (an integer) or nil if for some reason no character is available. function should also be able to `unread' one character. When this happens the function will be called with one argument -- the value of the last character read. The function should arrange it so that the next time it is called it returns this character. A possible implementation could be,
(defvar ms-unread-char nil
  "If non-nil the character which was pushed back.")

(defun my-stream (&optional unread-char)
  (if unread-char
      (setq ms-unread-char unread-char)
    (if ms-unread-char
        (prog1
          ms-unread-char
          (setq ms-unread-char nil))
      ;; Normal case -- read and return a character from somewhere
      ...
nil
Read from the stream stored in the variable standard-input.

It is also possible to use a string as an input stream. The string to be read from must be applied to the make-string-input-stream function and the result from this function used as the input stream.

Function: make-string-input-stream string &optional start
Returns an input stream which will supply the characters of the string string in order starting with the character at position start (or from position zero if this argument is undefined).

(read (make-string-input-stream "(1 . 2)"))
    => (1 . 2)

Variable: standard-input
The input stream which is used when no other is specified or is nil.


Go to the first, previous, next, last section, table of contents.