Last active
November 11, 2016 05:17
-
-
Save ganmacs/4cbaf2dc54d6a3235ba7 to your computer and use it in GitHub Desktop.
add-to-listを複数指定するマクロ
This file contains 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
(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