I've got a lot of:

(desktop-save-mode 1)
(show-paren-mode 1)

which I'd like to collapse into:

(mapcar (lambda (fn) (fn 1)) '(desktop-save-mode show-paren-mode))

but I get an error:

Symbol’s function definition is void: fn

How can I call a list of functions with the same argument?

  • 2
    You don't need to pass 1 to enable a minor mode, so (mapc #'funcall '(...)) will do the trick.
    – Stefan
    Nov 21 '19 at 20:30
  • 2
    I'm certain this is a duplicate (for learning about funcall and friends), but I seem to be failing at searching. Refer to C-h i g (elisp)Calling Functions for the details.
    – phils
    Nov 22 '19 at 1:07

(mapcar (lambda (fn) (funcall fn 1)) '(desktop-save-mode show-paren-mode))


is defined thusly:

(define-minor-mode desktop-save-mode

so its not a function...

  • I'd still like to clean up my init file, any suggestions on how I could do that?
    – ftravers
    Nov 21 '19 at 18:41
  • 2
    Hmm... define-minor-mode defines a function (and a variable as well), so yes it is a function.
    – Stefan
    Nov 21 '19 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.