入出力


*eol-cr*

Type: Variable
Package: editor
File: encoding.l
改行コードのCRを表す値です。
プロセスやバッファの入出力の改行コードを設定するのに使用します。

SeeAlso: *eol-lf*
SeeAlso: *eol-crlf*
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

*eol-crlf*

Type: Variable
Package: editor
File: encoding.l
改行コードのCRLFを表す値です。
プロセスやバッファの入出力の改行コードを設定するのに使用します。

SeeAlso: *eol-cr*
SeeAlso: *eol-lf*
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

*eol-lf*

Type: Variable
Package: editor
File: encoding.l
改行コードのLFを表す値です。
プロセスやバッファの入出力の改行コードを設定するのに使用します。

SeeAlso: *eol-cr*
SeeAlso: *eol-crlf*
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

*keyboard*

Type: Variable
Package: editor
キーボードからの入力を表すストリームです。

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

*standard-input*

Type: Variable
Package: lisp
標準入力を表すストリームです。
普段はキーボードからの入力になっています。

SeeAlso: *standard-output*
SeeAlso: *keyboard*
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

*standard-output*

Type: Variable
Package: lisp
標準出力を表すストリームです。
普段はステータスバーのウィンドウへの出力になっています。
lisp-interaction-mode の C-j(eval-print-last-sexp) では
そのバッファへの出力になっています。

使用例:
  ;;; eval-expression で評価した場合
  *standard-output*  
  => #<status window stream 48042808>

  ;;; eval-print-last-sexp で評価した場合
  *standard-output*
  => #<buffer stream 48042280>

SeeAlso: *standard-input*
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

broadcast-stream-streams

Type: Function
Arguments: broadcast-stream-streams BROADCAST-STREAM
Package: lisp
File: builtin.l
make-broadcast-streamで作られたBROADCAST-STREAMの出力先のストリームのリ
ストを返します。

使用例:
  ;;; hogeの出力先をリストで得る。
  (with-open-stream (foo (open "foo.txt" :direction :output))
    (with-open-stream (bar (open "bar.txt" :direction :output))
      (with-open-stream (hoge (make-broadcast-stream foo bar))
        (broadcast-stream-streams hoge))))
  => (#<file-output stream: C:/applications/xyzzy/foo.txt>
      #<file-output stream: C:/applications/xyzzy/bar.txt>)

SeeAlso: make-broadcast-stream
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

buffer-stream-buffer

Type: Function
Arguments: buffer-stream-buffer STREAM
Package: editor
File: builtin.l
buffer-streamであるストリームが関連付けられているバッファを返します。

  STREAM : buffer-streamであるストリームを指定します。

SeeAlso: make-buffer-stream
SeeAlso: buffer-stream-point
SeeAlso: xyzzyで提供されているストリームの種類
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

buffer-stream-p

Type: Function
Arguments: buffer-stream-p STREAM
Package: editor
File: builtin.l
ストリームがbuffer-streamかどうかを返します。

  STREAM : 判定するストリーム

  t   ストリームはbuffer-streamである。
  nil ストリームはbuffer-streamではない。

SeeAlso: xyzzyで提供されているストリームの種類
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

buffer-stream-point

Type: Function
Arguments: buffer-stream-point STREAM
Package: editor
File: builtin.l
buffer-streamであるストリームのポイントを返します。

  STREAM : buffer-streamであるストリームを指定します。

SeeAlso: buffer-stream-set-point
SeeAlso: file-position
SeeAlso: make-buffer-stream
SeeAlso: xyzzyで提供されているストリームの種類
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

buffer-stream-set-point

Type: Function
Arguments: buffer-stream-set-point STREAM POINT
Package: editor
File: builtin.l
buffer-streamであるストリームのポイントを指定します。

  STREAM : buffer-streamであるストリームを指定します。
  POINT  : buffer-stream上の入出力のポイントを指定します。

参考:
  misc.lのwith-output-to-bufferとかwith-input-from-buffer

SeeAlso: xyzzyで提供されているストリームの種類
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

clear-input

Type: Function
Arguments: clear-input &optional INPUT-STREAM
Package: lisp
File: builtin.l
入力ストリームにバッファリングされている入力をクリアします。

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

clear-message

Type: Function
Arguments: clear-message
Package: editor
File: misc.l
ステータスバーのメッセージを消去します。

SeeAlso: message
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

close

Type: Function
Arguments: close STREAM &key :abort
Package: lisp
File: builtin.l
指定されたストリームをクローズします。

  STREAM : クローズするストリームを指定します。
  :abort : 異常終了時に指定します。
        t       ストリームに対する副作用を取り消そうとします。
        nil     ストリーム普通に終了します。

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

concatenated-stream-streams

Type: Function
Arguments: concatenated-stream-streams CONCATENATED-STREAM
Package: lisp
File: builtin.l
make-concatenated-streamで作られたCONCATENATED-STREAMの入力元のストリームのリ
ストを返します。

使用例:
  ;;; hogeの入力元をリストで得る。
  (with-open-stream (foo (make-string-input-stream "foo"))
    (with-open-stream (bar (make-string-input-stream "bar"))
      (with-open-stream (hoge (make-concatenated-stream foo bar))
        (concatenated-stream-streams hoge))))
  => (#<string-input stream 48042632>
      #<string-input stream 48042544>)

SeeAlso: make-concatenated-stream
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

echo-stream-input-stream

Type: Function
Arguments: echo-stream-input-stream ECHO-STREAM
Package: lisp
File: builtin.l
make-echo-streamで作られたECHO-STREAMの入力元のストリームを返します。

SeeAlso: make-echo-stream
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

echo-stream-output-stream

Type: Function
Arguments: echo-stream-output-stream ECHO-STREAM
Package: lisp
File: builtin.l
make-echo-streamで作られたECHO-STREAMの出力先のストリームを返します。

SeeAlso: make-echo-stream
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

file-position

Type: Function
Arguments: file-position FILE-STREAM &optional POSITION
Package: lisp
File: builtin.l
FILE-STREAM上の現在位置を取得・変更します。
POSITIONを省略すると、FILE-STREAMの現在位置を返します。
POSITIONを指定すると、FILE-STREAMの現在位置を変更します。

  FILE-STREAM : 入出力するストリームを指定します。
  POSITION    : ストリームの先頭からの位置を指定します。
                0を基底とするインデックスです。

POSITIONには負の数値を指定することはできません。
また、ストリームの終端を越えた数値を指定すると、
その間はNUL文字が詰められます。

使用例:
  ;;; "01234567"と出力後、移動して"abc"と出力します。
  (setq foo (open "abc.txt" :direction :output))
  => #<file-output stream: C:/applications/xyzzy/abc.txt>
  (princ "0123456" foo)         => "0123456"
  (file-position foo 10)        => t
  (princ "abc" foo)             => "abc"
  (close foo)                   => t

SeeAlso: buffer-stream-point
SeeAlso: buffer-stream-set-point
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

format

Type: Function
Arguments: format DESTINATION CONTROL-STRING &rest ARGUMENTS
Package: lisp
File: builtin.l
出力書式に従って出力します。

  DESTINATION : 出力先を指定します。
        t       標準出力に出力
        nil     文字列として結果を返す
        fp      指定のストリームに出力

  CONTROL-STRING : 以下の出力指定子で整形します。
        ~A      Ascii(アスキー指示)。princタイプで出力。
        ~S      S-Expression(S式指示)。prin1タイプで出力。
        ~%      改行。~n%はn個の改行
        ~&      出力ストリームが行頭でなければ改行。fresh-line参照。
        ~|      改ページ
        ~~      Tilde(チルダ指示)
        ~改行   改行とそれに続く空白文字を無視する
        ~T      Tabulate(タブ指示)
        ~*      次のargumentを無視
        ~?      Indirection(間接指示)
        ~D      10進数
        ~B      Binary(2進指示)
        ~O      Octal(8進指示)
        ~X      Hexadecimal(16進指示)
        ~R      Radix(基数指示)
        ~P      Plural(複数形指示)
        ~C      Character(文字指示)
        ~F      Fixed-format floating-point(固定小数点形式浮動小数指示)
        ~E      Exponential floating-point(指数形式浮動小数指示)
        ~G      General floating-point(一般浮動小数点指示)
        ~$      Dollars floating-point(ドル浮動小数点指示)
        ~(      Case conversion(ケース変換指示)
        ~)      ~(を閉じる
        ~[      Conditional expression(条件選択指示)
        ~]      ~[を閉じる
        ~{      Iteration(反復指示)
        ~}      ~{を閉じる
        ~^      Up and out(ゼロ終了指示)

使用例:
  ;;; 整数に0を付けて出力 ("~[最小桁数][,パディング文字][,桁区切り文字]D")
  (format nil "~5,'0D" 4)
  => "00004"

  ;;; 整数を3桁ごとにカンマで区切って出力
  (format nil "~:D" 1234567890)
  => "1,234,567,890"

  ;;; 文字列を最低桁カラムになるように空白を追加して出力
  (format nil "~10A" "foo")
  => "       foo"
  (format nil "~10@A" "foo")
  => "foo       "

  ;;; ケース変換の例
  (format nil "~(~A~)" "FOO BAR")  ;全て小文字
  => "foo bar"
  (format nil "~:(~A~)" "foo bar") ;単語の先頭の文字を大文字
  => "Foo Bar"
  (format nil "~@(~A~)" "foo bar") ;先頭の文字を大文字
  => "Foo bar"
  (format nil "~:@(~A~)" "foo bar");全て大文字
  => "FOO BAR"

  ;;; 間接指示の例
  (format nil "~? ~D" "[~A ~D]" '("foo" 2) 3)
  => "[foo 2] 3"
  (format nil "~@? ~D" "[~A ~D]" "foo" 2 3)
  => "[foo 2] 3"

  ;;; 条件選択指示の例
  (format nil "Windows ~[NT~;98~;95~]" 0)
  => "Windows NT"
  (format nil "Windows ~[NT~;98~;95~]" 1)
  => "Windows 98"
  ;デフォルト値 "~:;"
  (format nil "Windows ~[NT~;98~;95~:;3.1~]" 5)
  => "Windows 3.1"

  ;;; 反復指示の例
  ; "~{" 引数はリスト
  (format nil "~{ ~A~}" '("dog" "cat" "pig"))
  => " dog cat pig"
  ; "~:{"  引数はリストのリスト
  (format nil "~:{[~A ~D]~}" '(("a" 1) ("b" 2) ("c" 3)))
  => "[a 1][b 2][c 3]"
  ; "~@{" 残りの引数をリストとして用いる
  (format nil "~@{[~A ~D]~}" "a" 1 "b" 2 "c" 3)
  => "[a 1][b 2][c 3]"
  ; "~@:{" 引数のリストをリストとして用いる
  (format nil "~:@{[~A ~D]~}" '("a" 1) '("b" 2) '("c" 3))
  => "[a 1][b 2][c 3]"

  ;;; ゼロ終了指示の例
  ;引数がなければ終了
  (format nil "Done.~^ ~D warning~:P.~^ ~D error~:P.")
  => "Done."
  (format nil "Done.~^ ~D warning~:P.~^ ~D error~:P." 3)
  => "Done. 3 warnings."
  (format nil "Done.~^ ~D warning~:P.~^ ~D error~:P." 3 5)
  => "Done. 3 warnings. 5 errors."

  ;;; 反復指示とゼロ終了指示
  ;副リストの中の引数がもうなければ "~{" をそこで閉じる
  (format nil "~:{/~S~^ ...~}" '((hot dog) (hamburger) (ice cream) (french fries)))
  => "/hot .../hamburger/ice .../french ..."
  ;リストが終わりならそこで ":{" 全体を終了
  (format nil "~:{/~S~:^ ...~}" '((hot dog) (hamburger) (ice cream) (french fries)))
  => "/hot .../hamburger .../ice .../french"
  ;副リストの中の引数がもうなければ全体を終了
  (format nil "~:{/~S~#:^ ...~}" '((hot dog) (hamburger) (ice cream) (french fries)))
  => "/hot .../hamburger"

  ;;; 16進数のformat書式の書き方
  (format nil "~2,'0x" 10)
  => "0a"
  (format nil "~:@(~2,'0x~)" 10)
  => "0A"

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

fresh-line

Type: Function
Arguments: fresh-line &optional OUTPUT-STREAM
Package: lisp
File: builtin.l
OUTPUT-STREAM が行の先頭ではないときだけ改行 (#\LFD) を出力します。

SeeAlso: terpri
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

listen

Type: Function
Arguments: listen &optional INPUT-STREAM
Package: lisp
File: builtin.l
指定された入力ストリームに何か入力がある状態ならばt、ないならばnilを返します。

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

make-broadcast-stream

Type: Function
Arguments: make-broadcast-stream &rest STREAMS
Package: lisp
File: builtin.l
ブロードキャスト用の出力ストリームを作成します。
STREAMS に指定した複数のストリームに対して同時に出力することができます。

参考:
                        OUTPUT━━┓
                    ┌→┃STREAM1 ┠→
                    │  ┗━━━━┛
        BROADCAST ┓│  OUTPUT━━┓
    ─→┃STREAM  ┠┼→┃STREAM2 ┠→
        ┗━━━━┛│  ┗━━━━┛
                    │  OUTPUT━━┓
                    └→┃STREAM3 ┠→
                        ┗━━━━┛
使用例:
  ;;; fooとbarという出力ストリームを作ってから、
  ;;; hogeというブロードキャスト用ストリームを作り一括して出力
  (with-open-stream (foo (open "foo.txt" :direction :output))
    (with-open-stream (bar (open "bar.txt" :direction :output))
      (with-open-stream (hoge (make-broadcast-stream foo bar))
        (princ "abc" hoge))))
  => "abc"

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

make-buffer-stream

Type: Function
Arguments: make-buffer-stream BUFFER &optional POINT EOB
Package: editor
File: builtin.l
バッファ上にbuffer-streamを作成します。

  BUFFER : buffer-streamを作成するバッファを指定します。
  POINT  : 入出力を開始するポイントを指定します。
        nil     バッファの先頭が開始位置
        nil以外 指定されたポイントが開始位置
  EOB    : 終端のポイントを指定します。
        nil     バッファの最後が終端
        nil以外 指定されたポイントが終端

SeeAlso: buffer-stream-buffer
SeeAlso: buffer-stream-point
SeeAlso: buffer-stream-set-point
SeeAlso: xyzzyで提供されているストリームの種類
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

make-concatenated-stream

Type: Function
Arguments: make-concatenated-stream &rest STREAMS
Package: lisp
File: builtin.l
STREAMS に指定した複数の入力ストリームをくっつけて、順番に読み出すための
一つの入力ストリームを作ります。

参考:
                        INPUT ━━┓    
                      ┌┨STREAM1 ┃←─
                      │┗━━━━┛    
        CONCAT━━┓  │INPUT ━━┓    
    ←─┨STREAM  ┃←┼┨STREAM2 ┃←─
        ┗━━━━┛  │┗━━━━┛    
                      │INPUT ━━┓    
                      └┨STREAM3 ┃←─
                        ┗━━━━┛    

使用例:
  ;;; 文字列の入力ストリームを二本作った後、一本に連接してみる。
  (with-open-stream (foo (make-string-input-stream "foo"))
    (with-open-stream (bar (make-string-input-stream "bar"))
      (with-open-stream (hoge (make-concatenated-stream foo bar))
        (while (setq in (read-char hoge nil))
          (write-char in)))))

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

make-echo-stream

Type: Function
Arguments: make-echo-stream INPUT-STREAM OUTPUT-STREAM
Package: lisp
File: builtin.l
INPUT-STREAM からの入力を OUTPUT-STREAM に出力するストリームを作成します。
make-two-way-stream と異なり、 INPUT-STREAM から入力された内容は、全て
OUTPUT-STREAM にエコーされます。

参考:

     ECHO STREAM━┓    INPUT ━━┓
    ←─┨←───┨←─┨STREAM  ┃←─
        ┃    ┌─┨    ┗━━━━┛
        ┃    └→┃    OUTPUT━━┓
    ─→┠───→┠─→┃STREAM  ┠─→
        ┗━━━━┛    ┗━━━━┛

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

make-string-input-stream

Type: Function
Arguments: make-string-input-stream STRING &optional START END
Package: lisp
File: builtin.l
文字列からの入力用ストリームを作成します。
以後、このストリームからは文字列の内容を順番に取得可能です。

  STRING : 対象の文字列を指定します。
  START  : 入力ストリームとする開始位置です。
  END    : 入力ストリームとする終了位置です。

複数の入力ストリームを使用するのでなければ、with-input-from-string を使
用する方が簡単です。

使用例:
  ;;; 文字列の入力用ストリームからひとつ読み出してみる。
  (with-open-stream (foo (make-string-input-stream "abc def"))
    (read foo))
  => abc  

  ;;; with-input-from-stringを使って同じ事をしてみる。
  (with-input-from-string (foo "abc def")
    (read foo))
  => abc

SeeAlso: with-input-from-string
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

make-two-way-stream

Type: Function
Arguments: make-two-way-stream INPUT-STREAM OUTPUT-STREAM
Package: lisp
File: builtin.l
入力をINPUT-STREAM、出力をOUTPUT-STREAMにする入出力ストリームを作成します。

参考:
        TWO WAY
          STREAM━┓    INPUT ━━┓
    ←─┨←───┨←─┨STREAM  ┃←─
        ┃        ┃    ┗━━━━┛
        ┃        ┃    OUTPUT━━┓
    ─→┠───→┠─→┃STREAM  ┠─→
        ┗━━━━┛    ┗━━━━┛

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

message

Type: Function
Arguments: message FMT &rest ARGS
Package: lisp
File: misc.l
メッセージをステータスバーに出力します。

  FMT  : format同様の書式が指定できます。
  ARGS : 出力書式へのパラメタとなります。

SeeAlso: clear-message
SeeAlso: msgbox
SeeAlso: message-box
SeeAlso: minibuffer-message
SeeAlso: with-interval-message
SeeAlso: format
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

open

Type: Function
Arguments: open FILENAME &key :direction :if-exists :if-does-not-exist :encoding :share
Package: lisp
File: builtin.l
ファイルへのストリームを作成して返します。ストリームのクローズには close 
を使いますが、 with-open-stream を使えば close の手間が省ける上に安全です。

  FILENAME           : ストリームを作成するファイル名を指定します。
  :direction         : ストリームの入出力の方向を指定します。
        :input          入力(省略時)
        :output         出力
        :io             入出力
        :probe          ファイルテスト?
                        戻り値のストリームは無効になっています。
  :if-exists         : ファイルが存在する場合の動作を指定します。
        :error          エラーを出力します。(省略時)
        :skip           エラーは出力せず、nilを返します。
        :append         既存ファイルに追加します。
                        ストリームの位置はファイル終端になります。
        :overwrite      上書きします。
        :new-version    ファイルを作成します。
                        既にあれば上書きされます。
        ---- 以下詳細不明 ----
        :supersede      更新?
        :rename         リネーム用にストリームを開く?
        :rename-and-delete  リネーム用にストリームを開く?
  :if-does-not-exist : ファイルが存在しない場合の動作を指定します。
        :error          エラーを出力します。(省略時)
        :create         エラーは出力せず、入力ファイルを作成します。
  :encoding          : エンコーディングのモードを指定します。
        :binary         バイナリモードです。
        :text           テキストモードです。(省略時は:text)
                        改行がコードが*default-fileio-encoding*に依存します。
        :canonical      :text と同じ意味になります。
        :raw            改行コードの扱いが、LF のみになります。
                        それ以外は :text と同じです。
  :share             : ファイルの共有モードを指定します。
        省略時     :direction が :input または :probe なら :read に、
                        それ以外は共有不可になります。
        :read           読み取りの共有が可能になります。
        :write          書き込みの共有が可能になります。
        :read-write     読み書きの共有が可能になります。

使用例:
  ;;; ストリーム経由でファイルに書き出してみる。
  (setq foo (open "abc.txt" :direction :output))
  => #<file-output stream: C:/applications/xyzzy/abc.txt>
  (princ "test" foo)
  => "test"
  (close foo)
  => t

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

parse-integer

Type: Function
Arguments: parse-integer STRING &key :start :end :radix :junk-allowed
Package: lisp
File: builtin.l
文字列を整数に変換して返します。数値そのものと、元の文字列の有効な桁数を
多値で返します。

--- 原文 ---
Description: examines the characters of string specified by :start and 
:end, and attempts to parse an integer ignoring whitespace characters. 
The keyword :radix defines the base to which the integer is to be parsed 
and must be in the range 2 to 36. If :junk-allowed is non-nil, the first 
value returned is the integer parsed or nil if no acceptable digits were 
found. If :junk-allowed is nil, an error is signaled if the substring is 
not an integer in the appropriate base, with optional sign. Note that 
radix specifiers #o, #b, #x and #nR are not recognized, nor is the decimal 
point.

--- 意訳 ---
parse-integer は :start と :end で示された文字の並びをチェックし、空白
文字を無視して整数の読み込みを試みます。 :radix キーワードは数値が読み込
まれるべき基数を定義します。基数は 2 から 36 までの範囲になければなりま
せん。もし、 :junk-allowed が nil 以外で読み込めない文字があれば nil と
なります。もし、 :junk-allowed が nil で読み込めない文字があればエラーを
発生します。なお、基数として#o #b #x 及び #nR は認識できないので注意する
こと。

# となっていますが、空白は入ってはだめみたい。

使用例:
  (parse-integer "123")
  => 123
     3
  (parse-integer "123+23")
  => 不正な数値の形式です: "123+23"
  (parse-integer "123+23" :junk-allowed t)
  => nil
     3
  (parse-integer "a" :radix 16)
  => 10

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

peek-char

Type: Function
Arguments: peek-char &optional PEEK-TYPE INPUT-STREAM EOF-ERROR-P EOF-VALUE RECURSIVE-P
Package: lisp
File: builtin.l
ストリームから文字を覗き見ます。read-charしてunread-charするようなもんです。

使用例:
  ;;; 標準入力の文字を除き見る。
  (peek-char *standard-input* nil nil nil)

SeeAlso: read-char
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

prin1

Type: Function
Arguments: prin1 OBJECT &optional STREAM
Package: lisp
File: stream.l
オブジェクトをストリームに出力します。

  OBJECT : 出力するオブジェクトを指定します。
  STREAM : ストリームを指定します。

STREAMを省略されたときは、標準出力に出力します。princでの出力とよく似て
いますが、エスケープ文字を出力することや文字列が引用符で囲まれる点が異な
ります。

使用例:
  ;;; princとprin1の出力の違い
  (princ "abc") => abc  (prin1 "abc") => "abc"
  (princ #\a)   => a    (prin1 #\a)   => #\a

SeeAlso: princ
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

princ

Type: Function
Arguments: princ OBJECT &optional STREAM
Package: lisp
File: stream.l
オブジェクトをストリームに出力します。

  OBJECT : 出力するオブジェクトを指定します。
  STREAM : ストリームを指定します。

STREAMを省略されたときは、標準出力に出力します。prin1での出力とよく似て
いますが、エスケープ文字を出力しないことや文字列が引用符で囲まれない点が
異なります。
※CLtL2(Common Lisp the Language, 2nd edition)によると人間に読み易いよう
  に意図しているそうです。

使用例:
  ;;; princとprin1の出力の違い
  (princ "abc") => abc  (prin1 "abc") => "abc"
  (princ #\a)   => a    (prin1 #\a)   => #\a

SeeAlso: prin1
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

read

Type: Function
Arguments: read &optional INPUT-STREAM EOF-ERROR-P EOF-VALUE RECURSIVE-P
Package: lisp
File: builtin.l
INPUT-STREAM から Lisp のオブジェクトを読み込んで返します。

  INPUT-STREAM : 入力元のストリーム
  EOF-ERROR-P  : EOFの状態でread-charしたときにどうするか?
        t               エラーとする。
        nil             エラーとせず、nilを返します。
  EOF-VALUE    : EOFの状態でreadしたときにnilの代わりに返す文字を指定します。
  RECURSIVE-P  : (詳細不明)

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

read-char

Type: Function
Arguments: read-char &optional INPUT-STREAM EOF-ERROR-P EOF-VALUE RECURSIVE-P
Package: lisp
File: builtin.l
指定された入力ストリームから一文字読み込んで、文字を返します。

  INPUT-STREAM : 入力ストリーム
  EOF-ERROR-P  : EOFの状態でread-charしたときにどうするか?
        t               エラーとする。
        nil             エラーとせず、nilを返します。
  EOF-VALUE    : EOFの状態でread-charしたときにnilの代わりに返す文字を指定します。
  RECURSIVE-P  : (詳細不明)

使用例:
  (read-char *keyboard*) <-- "a"を入力
  => #\a

補足:
  蛇足ですが、EOFはEnd Of Fileの略です。ファイルやストリームをすっかり読
  み終わってしまった状態を指します。

---- Common Lisp ------
Description: reads one character from the current stream and returns it 
as an object. If end of file is encountered, the operation of read-char 
is determined by the eof-error-p and eof-value arguments (see read).

SeeAlso: read-char-no-hang
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

read-char-no-hang

Type: Function
Arguments: read-char-no-hang &optional INPUT-STREAM EOF-ERROR-P EOF-VALUE
Package: lisp
File: builtin.l
read-char と同じです。ただし、入力がなければ待たずに nil を返します。

SeeAlso: read-char
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

read-from-string

Type: Function
Arguments: read-from-string STRING &optional EOF-ERROR-P EOF-VALUE &key :start :end :preserve-whitespace
Package: lisp
File: stream.l
文字列を読み、多値で2つの値を返します。1つ目の戻り値は Lisp Reader が読
み込んだオブジェクトそのもの、2つ目の戻り値は文字列中において読まなかっ
た最初の文字の位置です。文字列を最後まで読んだ場合、2つ目の戻り値はその
文字列の長さと等しくなります。

  STRING               : 読む対象である文字列
  EOF-ERROR-P          : EOFの状態でread-from-stringしたときにどうするか?
                non-nil    エラーとします。(デフォルト)
                nil        エラーとせず、nilを返します。
  EOF-VALUE            : EOFの状態でread-from-stringしたときにnilの代わ
                         りに返す文字を指定します。
  :start               : 読み始める位置(デフォルトは0)
  :end                 : 読み終わる位置(デフォルトは文字列の長さ)
  :preserve-whitespace : (詳細不明)
                non-nil    
                nil

SeeAlso: parse-integer
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

read-line

Type: Function
Arguments: read-line &optional INPUT-STREAM EOF-ERROR-P EOF-VALUE RECURSIVE-P
Package: lisp
File: builtin.l
--- 原文 ---
Description: is usually used to read text from the keyboard. It reads 
characters from input-stream until the #\newline character is encountered, 
and collects them into a string without the #\newline character. This 
function returns two values. The first is the string collected.  The 
second is non-nil if the operation is terminated on end of file and nil 
otherwise. If end of file is encountered immediately, operation of read-line 
is determined by the eof-error-p and eof-value arguments.

--- 意訳 ---
read-lineはキーボードからテキストを読み込むのに使われます。#\LFDが出てく
るまでINPUT-STREAMから文字を読み込みます。そして、#\LFD以外を集めて文字
列にします。read-lineは二つの値を返します。最初の値は集めた文字列そのも
のです。二つ目の値は、ファイルの終端まできてしまったらnon-nilを返します。
そうでなければnilを返します。もしファイルの終端が直ぐに現れたら、
read-lineはEOF-ERROR-PとEOF-VALUEにより終了させられます。

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

set-macro-character

Type: Function
Arguments: set-macro-character CHAR FUNCTION &optional NON-TERMINATING-P READTABLE
Package: lisp
File: builtin.l
(詳細不明)

使用例:
  (set-macro-character #\? 'read-test)
  (defun read-test (stream ch)
    (list '*question* (read stream)))

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

si:*stream-line-number

Type: Misc
Arguments: *stream-line-number &optional STREAM
Package: system
File: builtin.l
(詳細不明)
(si:*stream-line-number *standard-input*)

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

streamp

Type: Function
Arguments: streamp OBJECT
Package: lisp
File: builtin.l
OBJECTがストリームか否かを返します。
  t    OBJECTはストリームである。
  nil  OBJECTはストリームでない。

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

terpri

Type: Function
Arguments: terpri &optional OUTPUT-STREAM
Package: lisp
File: builtin.l
OUTPUT-STREAM に改行 (#\LFD) を出力して nil を返します。

SeeAlso: fresh-line
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

two-way-stream-input-stream

Type: Function
Arguments: two-way-stream-input-stream TWO-WAY-STREAM
Package: lisp
File: builtin.l
make-two-way-stream で作られた TWO-WAY-STREAM の入力元のストリームを返します。

SeeAlso: make-two-way-stream
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

two-way-stream-output-stream

Type: Function
Arguments: two-way-stream-output-stream TWO-WAY-STREAM
Package: lisp
File: builtin.l
make-two-way-stream で作られた TWO-WAY-STREAM の出力先のストリームを返します。

SeeAlso: make-two-way-stream
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

unread-char

Type: Function
Arguments: unread-char CHARACTER &optional INPUT-STREAM
Package: lisp
File: builtin.l
入力ストリームに一文字戻します。

  CHARACTER    : 入力ストリームに戻す文字
  INPUT-STREAM : 入力ストリーム

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-input-from-buffer

Type: Macro
Arguments: with-input-from-buffer (BUFFER &optional POINT EOB) &rest BODY
Package: editor
File: misc.l
バッファを入力ストリームとして扱えるようになり、
*standard-input*から読み込まれるようになります。

使用例:
  ;;; *scratch*の内容を*Output*に吐き出す。
  (with-output-to-buffer ((switch-to-buffer "*Output*"))
    (with-input-from-buffer ((switch-to-buffer "*scratch*"))
      (while (setq line (read-line *standard-input* nil))
        (princ line)
        (princ "\n"))))

SeeAlso: with-output-to-buffer
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-input-from-selected-buffer

Type: Macro
Arguments: with-input-from-selected-buffer &rest BODY
Package: editor
File: misc.l
現在のバッファを標準入力にして読み込みます。

使用例:
  ;;; 現在のバッファから読み込んで変数に入れる。
  (with-input-from-selected-buffer
    (setq name (read) count (read) exp (read)))

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-input-from-string

Type: Macro
Arguments: with-input-from-string (VAR STRING &key :index :start :end) &body BODY
Package: lisp
File: stream.l
文字列を標準入力にして読み込みます。

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-interval-message

Type: Macro
Arguments: with-interval-message (INTERVAL) &body BODY
Package: editor
File: misc.l
BODY 内で message コマンドによる表示の更新間隔を制限します。

  INTERVAL : 表示の最低更新間隔(ミリ秒)。
             前回 message を実行したときから INTERVAL ミリ秒以上経過していない場合、
             新たなメッセージを表示しません。

使用例:
  ;; 更新間隔を 100 ミリ秒にしてみる。
  (with-interval-message (100)
    (dotimes (i 100000)
      (message "~D" i)))

SeeAlso: message
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-open-file

Type: Macro
Arguments: with-open-file (STREAM FILENAME &rest OPTIONS) &body BODY
Package: lisp
File: stream.l
--- 原文 ---
Description: evaluates the forms of the body as an implicit progn. stream 
is bound to a stream that is the result of applying open
 to filename and the options. If the stream cannot be opened, stream may 
be bound to nil. The file is automatically closed if the body is exited, 
even in error.

--- 意訳 ---
prognがあるかのようにBODYのフォームを順番に評価します。STREAMは、FILEと
OPTIONにopenを適用した結果のストリームに束縛されます。もしストリームの
openに失敗したら、STREAMはnilに束縛されます。FILEはBODYから抜けた場合に
自動的にクローズされます。たとえそれがエラーの場合であっても。

使用例:
  (with-open-file (fp (merge-pathnames "lisp/henmi/c++-kwd.txt" (si:system-root)))
    (let ((line nil))
      (while (setq line (read-line fp nil nil nil))
        (push line *kekka*))))

SeeAlso: open
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-open-stream

Type: Macro
Arguments: with-open-stream (VAR STREAM) &body BODY
Package: lisp
File: stream.l
出力ストリームを開きます。

--- 原文 ---
evaluates the form stream to return a stream with dynamic extent. The 
value of the stream is bound to var, and then the body forms are 
evaluated as an implicit progn. The value of with-open-stream is that of 
the last form evaluated. On termination, whether normal or otherwise, 
the stream is closed by close.

--- 意訳 ---
STREAMのフォームを評価して動的エクステントのストリームを返します。返され
たストリームの値はVARに束縛されます。そして、BODYのフォームは暗黙のprogn
の中で評価されます。with-open-streamの値は、最後のBODYのフォームのものに
なります。正常終了か否かにかかわらず、終了時にストリームはクローズされます。

参考:
  connectの例を参照のこと

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-output-to-buffer

Type: Macro
Arguments: with-output-to-buffer (BUFFER &optional POINT) &rest BODY
Package: editor
File: misc.l
標準出力を指定されたバッファにリダイレクトします。

  BUFFER : 出力するバッファ
  POINT  : 出力をするポイントを指定します。
           指定しない場合には、バッファの先頭から出力されます。
  BODY   : 実行するフォーム

使用例:
  ;;; *scratch*に書き出してみる。
  (with-output-to-buffer ((find-buffer "*scratch*"))
     (format t "foo~%")
     (format t "bar~%"))

SeeAlso: with-output-to-selected-buffer
SeeAlso: with-output-to-temp-buffer
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-output-to-selected-buffer

Type: Function
Arguments: with-output-to-selected-buffer &rest BODY
Package: editor
File: misc.l
標準出力をカレントバッファにリダイレクトします。
ポイントがある位置から出力されます。
  
使用例:
  ;;; カレントバッファに書き出してみる。
  (with-output-to-selected-buffer
     (format t "foo~%")
     (format t "bar~%"))

SeeAlso: with-output-to-buffer
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-output-to-string

Type: Macro
Arguments: with-output-to-string (VAR &optional STRING) &body BODY
Package: lisp
File: stream.l
文字列を出力するストリームを作成します。

使用例:
  ;;; ストリームを使って文字列を出力してみる。
  (setq var
        (with-output-to-string (out)
          (prin1 "test" out)))
  => "test"

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

with-output-to-temp-buffer

Type: Macro
Arguments: with-output-to-temp-buffer (BUFNAME &optional (POPUP t)) &rest BODY
Package: editor
File: misc.l
指定されたバッファを作成し、標準出力をそのバッファにリダイレクトします。
同じ名前のバッファがあった場合には、そのバッファの内容は破棄されます。
単に処理結果だけを書き込むような場合に便利です。

  BUFNAME : バッファの名前を指定します。
  POPUP   : バッファを分割表示する際の行数/列数を指定します。
        t       ニ分割します。
        整数    指定行数/列数で分割します。
        nil     バッファを分割表示しません。
  VERT-P  : バッファの分割方法を指定します。
            POPUP が nil の場合は意味を持ちません。
        non-nil 左右にバッファを分割します。
        nil     上下にバッファを分割します。

使用例:
  ;;; *Help*を作ってそこに書き出してみる。
  (with-output-to-temp-buffer ("*Help*")
     (format t "foo~%")
     (format t "bar~%"))

互換性:
   muleにもCommon Lispにもありません。

SeeAlso: with-output-to-buffer
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

write

Type: Function
Arguments: write OBJECT &key :stream :escape :pretty :base :radix :circle :level :length :readably
Package: lisp
File: builtin.l
OBJECTを印字表現でストリームに出力します。:streamを省略すると
*standard-output*に出力します。
(詳細不明)

SeeAlso: read
[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

write-char

Type: Function
Arguments: write-char CHARACTER &optional OUTPUT-STREAM
Package: lisp
File: builtin.l
OUTPUT-STREAM に CHARACTER を出力し、その CHARACTER を返します。

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]

xyzzyで提供されているストリームの種類

Type: Tips
(途中)
以下はxyzzyで提供されているストリームの種類です。

  Commonと同じ
  ---------------------------------------------
  file-input-stream       open
  file-output-stream      open
  file-io-stream          open
  string-input-stream     make-string-input-stream
  string-output-stream    make-string-output-stream
  synonym-stream          make-synonym-stream
  broadcast-stream        make-broadcast-stream
  concatenated-stream     make-concatenated-stream
  echo-stream             make-echo-stream
  two-way-stream          make-two-way-stream
  ---------------------------------------------

synonym-stream以降は使ったことないんで(^^;、動くかどうか分からないんです
が多分動くでしょう(^^)。

  独自
  ---------------------------------------------
  buffer-stream           make-buffer-stream
  status-window-stream    なし
  keyboard-stream         なし
  wstreams-stream         なし
  ---------------------------------------------

独自ストリームの概要:
  buffer-stream
    バッファをストリームとみなして入出力どっちでもできます。  
  status-window-stream
    ステータスウィンドウをストリームとみなして出力ができます。
    グローバル変数*status-window*の値です。
  keyboard-stream
    キーボードをストリームとみなして入力ができます。
    グローバル変数*keyboard*の値です。
  wstreams-stream
    formatからコールバックが呼ばれたときのstreamの実体。

[ Intro | 目次 | 索引 | 目的別 | 入出力 ]