I want to hook {whitespace and yas/minor-mode} minor modes to some major modes. Of course that could be done, manually, but I want a loop. So I tried to write it:
(progn
(setq modes-to-be-hooked '(lisp-mode-hook rst-mode-hook python-mode-hook emacs-lisp-mode-hook text-mode-hook tcl-mode-hook c-mode-hook fortran-mode-hook))
(while modes-to-be-hooked
(setq my-hooks '( yas/minor-mode whitespace-mode ))
(while my-hooks
(add-hook '(pop modes-to-be-hooked) '(pop my-hooks)))
)
)
The problem with this loop is that the last element of list is "nil" and (add-hook 'nil 'nil) gives an error. Then I tried to escape nils with if, but it doesn't work:
(progn
(setq mylist '(a b c))
(while mylist
(progn
(setq temp (pop mylist))
(if temp (message "%s" temp) (message "It's nil!") )
(sleep-for 1)
)
)
)
prints nil :(