How can I use dolist
to repeat an operation for each item in a list?
I have a sequence of statements:
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'narrow-to-defun 'disabled nil)
(put 'narrow-to-region 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'set-goal-column 'disabled nil)
that I want to re-factor by putting each name into a list, then repeating the operation for each name.
So I think the dolist
function can achieve this.
This fails:
(dolist (command
(
'downcase-region
'upcase-region
'narrow-to-defun
'narrow-to-region
'narrow-to-page
'set-goal-column
)
(put command 'disabled nil)))
with an error
Invalid function: 'downcase-region
Why is that an “invalid function” in one instance but not the other?
How should that dolist
be written to achieve the same effect as the first example?
elisp-demos
helps you with such kind of questions. Here is the entry of dolist