Previous: Interactive Codes, Up: Defining Commands


20.2.3 interactiveの使用例

ここではinteractiveの例を示します。

     
     
     (defun foo1 ()              ; foo1は引数なし
         (interactive)           ; 2単語分先へ進める
         (forward-word 2))
          ⇒ foo1
     
     
     
     (defun foo2 (n)             ; foo2は1引数
         (interactive "p")       ; 数値前置引数
         (forward-word (* 2 n)))
          ⇒ foo2
     
     
     
     (defun foo3 (n)             ; foo3は1引数
         (interactive "nCount:") ; ミニバッファで読む
         (forward-word (* 2 n)))
          ⇒ foo3
     
     (defun three-b (b1 b2 b3)
       "Select three existing buffers.
     Put them into three windows, selecting the last one."
         (interactive "bBuffer1:\nbBuffer2:\nbBuffer3:")
         (delete-other-windows)
         (split-window (selected-window) 8)
         (switch-to-buffer b1)
         (other-window 1)
         (split-window (selected-window) 8)
         (switch-to-buffer b2)
         (other-window 1)
         (switch-to-buffer b3))
          ⇒ three-b
     (three-b "*scratch*" "declarations.texi" "*mail*")
          ⇒ nil