Emacs
受到lloyd大大的影響,
基本上最近我也加入了拜lisp教之Emacs分會.
剛好Stevey的blog也寫了一篇有關Emacs的文章, 就拿來試一試吧.
果然, lisp在Emacs底下寫很有感覺啊...
(defun blog-column-length ()
"Print stats on current blog column, or blogollum, or whatever"
(interactive)
(save-excursion
(goto-char (point-min))
(let ((char-count 0))
(while (not (eobp))
(unless (looking-at "[ \t\r\n]")
(setq char-count (+ 1 char-count)))
(forward-char 1))
(message "%d chars, %d words" char-count (/ char-count 5)))))
ps:不過我這邊的ntemacs23沒有(require 'cl)
所以就把原本的incf改成了setq.
update: 剛看了這段Emacs Screencast, 非常令人讚嘆.
update2: 又學會一招
http://www.gnu.org/software/emacs/elisp/html_node/Simple-Macro.html#Simple-Macro
(defmacro incf (var)
(list 'setq var (list '1+ var)))
沒有留言:
張貼留言