I'm using a minor mode for my key bindings. But I want to set the documentation string dynamically. Instead of:

    (define-minor-mode mesys-mode

I want something like this:

    (define-minor-mode mesys-mode

How to do that? I'm still a newbie to Elisp and macros in Elisp. I experimented with (concat "This" " and that"), yes, it seems to expand without error but no description is shown only 'Not documented', if I use (describe-mode "mesys-mode") I think there is a problem with expansion....

1 Answer 1


The syntax of constructs like defun and define-minor-mode requires that a string literal is used.

If you want to generate the doc string programmatically, you can use (at least) two methods:

  • Create an data structure that corresponds to the call to define-minor-mode, with the resulting docstring in place. Then apply eval to it. Something like:

    (eval `(define-minor-mode mesys-mode ,my-document-string ...))
  • Define it using a dummy docstring and set the function-documentation documentation of the minor mode symbol.

Unfortunately, I think it's hard to get either variant working properly with autoload:s.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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