Skip to content

Instantly share code, notes, and snippets.

@ganmacs
Last active November 11, 2016 05:17
Show Gist options
  • Save ganmacs/4cbaf2dc54d6a3235ba7 to your computer and use it in GitHub Desktop.
Save ganmacs/4cbaf2dc54d6a3235ba7 to your computer and use it in GitHub Desktop.
add-to-listを複数指定するマクロ
(defmacro append-to-list (mode-list &rest body)
(let ((lst (gensym)))
`(dolist (,lst ',body)
(add-to-list ,mode-list ,lst))))
; Unit Test
(dont-compile
(require 'ert)
(require 'cl)
(message "Running tests on Emacs %s" emacs-version)
(ert-deftest append-to-list-test ()
"第2引数以降に受け取ったものをリストに追加する"
"append-to-list is "
(let ((lst nil))
(append-to-list 'lst
'h
(f . g)
(d e)
c
"b"
a
)
(should (equal lst '(a "b" c (d e) (f . g) 'h)))))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment