EMACS-DOCUMENT

=============>随便,谢谢

Part 2: 简单的ASCII艺术

使用 random

ELISP> (dotimes (i (random 10))
     (dotimes (j (random (+ i 5)))
       (insert "&"))
     (insert "^"))
nil
ELISP> &&^&&&&^&&&&^&&&&^&&&&&&&&^&&&&&&&^

使用 if 偶尔插入换行符

ELISP> (dotimes (i (random 30))
     (if (= (random 5) 0)
         (newline))
     (dotimes (j (random 10))
       (insert "?"))
     (insert " <  "))
nil
ELISP> ?? <  
?? <  ?? <   <  ?? <  ????? <  
???????? <  ?????? <  
 <  ??????? <  
????????? <  ???????? <  ??????? <  
 <  ???????? <  ?? <  ???????? <  ???? <  ????????? <  ???????? <  ??? <  ????????? <  ?? <  ????? <  ??? <  
??? <  ????????? <  

使用 sit-for 控制时间

ELISP> (dotimes (i 10)
     (dotimes (j (random 20))
       (insert ",,"))
     (insert "#")
     (sit-for (* 0.1 (random 4))))
nil
ELISP> ,,,,,,,,,,#,,,,##,,,,,,,,#,,,,,,,,,,,,#,,,,,,,,,,#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#,,,,,,,,,,,,,,,,,,,,,,,,,,,,#,,,,,,,,,,,,,,#

插入的同时移动光标

ELISP> (dotimes (i 20)
     (dotimes (j (random 5))
       (insert ",,"))
     (goto-char (- (point) (random 4)))
     (insert "#")
     (if (= (random 3) 0)
         (newline))
     (sit-for (* 0.1 (random 3))))#
,,,,,,,,#
,,,,,#
,,,,,,#,,##,,,#,,#
,,,,#,,,#,,,,,,#,,,#,#
,,,#,,,#,,,,,,,,,,,#
#,,#,,,#,,,,,,,,#,,,,,
nil
ELISP> 

上面的简易版本

ELISP> (dotimes (i 20)
     (dotimes (j (random 5))
       (insert ",,"))
     (backward-char (random 4))
     (insert "#")
     (if (= (random 3) 0)
         (newline))
     (sit-for (* 0.1 (random 3))))
nil
ELISP> ,,##,,,#
#,,,,,,,,##
,,#,,,,,,#,#,,,,,##,#,#,,,#,,,,,,#
#
,,#,,,,,,,,,
,,,#,#,,,,,,,,,,,
,#,