next up previous
Next: 2 ソフトウェア管理 Up: 1 ファイル編集エディタ Emacs Previous: 1.2 Shellの実行

1.3 Emacs Lispの実行

Emacs の*scratch*バッファの中で Emacs Lispの関数評価を行うことができる. カッコ開からカッコ閉の関数フォームを入力した後, C-jを打つことによりそのフォームの評価がなされる. Emacs Lispの基本関数には,数値計算, リスト処理,関数定義などが使える.
(+ 1 2 3)
-> 6
(- 3 5 6)
-> -8
(- (* 3 5) (/ 4 2))
-> 13
(setq a (list 1 2 3))
-> (1 2 3)
(setq b (list 4 5))
-> (4 5)
(setq c (append a b))
-> (1 2 3 4 5)
c
-> (1 2 3 4 5)

(setq d '(1 2))
-> (1 2)
(defun test (a b)
  (append a b))
-> test
(test a b)
-> (1 2 3 4 5)
(test d b)
-> (1 2 4 5)
(test '(1 2) '(3 4))
-> (1 2 3 4)

(defun testl (a b)
  (list a b))
-> testl
(defun testa (a b)
  (append a b))
-> testa
(testl a b)
-> ((1 2 3) (4 5))
(testa a b)
-> (1 2 3 4 5)
(testl 1 2)
-> (1 2)
(testa (testl 1 2) (testl 3 4))
-> (1 2 3 4)


generated through LaTeX2HTML. M.Inaba 平成18年5月7日