Created
January 12, 2012 07:05
-
-
Save takaxp/1599131 to your computer and use it in GitHub Desktop.
my-find-headings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my-find-headings () | |
(let ((eob (point-max)) | |
(head-list '())) | |
(save-excursion | |
(goto-char (point-min)) | |
(while (when (search-forward-regexp "^\*\\([^*]\\|$\\)" eob t) | |
(setq head-list (cons (match-beginning 0) head-list)) | |
(forward-line)))) | |
(reverse head-list))) |
うう.たくさんのコメントありがとうございます(T-T)
ノウハウを色々と教えていただいたので本当に勉強になりますっ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'()
を使うのは、(これから値を追加していく)空のリストであることを強調したつもりです。nil
だとnil
であることに(真偽などの)意味があるような気がしてしまうので…。スライド数が多くなるなら、
cons
で結合しておいて最後にnreverse
するのが一番速いと思います。append
にしてもadd-to-list
にしても毎ループごとにリストの末尾まで辿らないといけませんから。add-to-list
は破壊的なので、add-to-list
とappend
ならadd-to-list
の方が速いと思います。