練習
emacsぐらい知っとけよとかいう話なので、さっそく「入門GNU Emacs第3版」を読んでみた。
11章のelispを何とはなしに読み進める。
SICPを読んでいたので、lispには慣れている気がする。
そんなんで、練習問題。
基礎的なことをこつこつしていこうと思った。
- count-lines-buffer
- バッファ中の行数を表示する。
(defun count-lines-buffer() "Count the number of lines in the current buffer; print a message in the minibuffer with the result." (interactive) (save-excursion (let ((count 0)) (goto-char (point-min)) (while (< (point) (point-max)) (forward-line 1) (setq count (1+ count))) (message "buffer containes %d lines." count))))
- count-words-region
- region中の単語数を表示する
(defun count-words-region (from to) "Count the number of words in the regions; print a message in the minibuffer with the result." (interactive "nStart-point: \nnEnd-point:") (save-excursion (let ((count 0)) (goto-char from) (while (< (point) to) (forward-word 1) (setq count (1+ count))) (message "buffer contains %d words." count))))
- what-line
- ポイントが置かれている行の行番号を表示する
(defun what-line() "Print the number of line at the current point in the minibuffer" (interactive) (save-excursion (let ((count 0) (current-point (point))) (goto-char (point-min)) (while (< (point) current-point) (forward-line 1) (setq count (1+ count))) (message "The number of line at the current point is %d." count))))