2010/11/16

#p~/.sbclrc

http://twitter.com/#!/quek/status/3278540657131520 の件。

思ったより、ぐちゃぐちゃだぁ。

(set-dispatch-macro-character
#\# #\p
(lambda (stream char num)
(declare (ignore char num))
(pathname
(if (equal #\" (peek-char nil stream t t t))
(read stream t t t)
(with-output-to-string (out)
(loop for c = (peek-char nil stream nil nil t)
while (and c
(not (find c '(#\space #\tab #\cr #\lf)))
(multiple-value-bind (function non-terminating-p)
(get-macro-character c)
(or (null function) non-terminating-p)))
do (read-char stream t t t)
if (char= c #\\)
do (let ((next (read-char stream t t t)))
(when (member next '(#\\ #\"))
(write-char #\\ out))
(write-char next out))
else
do (write-char c out)))))))

(with-open-file (in #p"~/.sbclrc")
(read-line in))
;; => ";;;;; -*-lisp-*-"
;; NIL

(with-open-file (in #p~/.sbclrc)
(read-line in))
;; => ";;;;; -*-lisp-*-"
;; NIL

~/.sbclrc に入れといてみよう。

0 件のコメント: