4

When I'm writing the docstring for a defun or a defvar, if hit M-q the paragraph always gets filled to 65 characters, regardless of the value of fill-column.

Q. How can I get fill-paragraph to always respect the configured fill-column inside emacs-lisp-mode?

6

Change emacs-lisp-docstring-fill-column to nil. From the docstring (emphasis mine):

Value of fill-column to use when filling a docstring. Any non-integer value means do not use a different value of `fill-column' when filling docstrings.

Please don't do this, though. There is a reason for this setting: Emacs shows docstrings exactly like the appear in your code. If you fill your docstrings at 80 characters, you force your readers to read them filled at 80 characters. Even those readers, who view docstrings on their 11 inch laptops in horizontally split buffers. And they have no chance to change the filling in any way.

  • Actually, I want to reduce the width so that they fit in my blog's code blocks. It's not for actual development. – Malabarba Mar 3 '15 at 17:20
  • @Malabarba Well, that's a valid reason, of course, but I'll leave the warning in my answer, for other readers. – lunaryorn Mar 4 '15 at 9:02
3

In emacs-lisp-mode the fill-paragraph-function is set to lisp-fill-paragraph. There is a separate fill column used specifically for docstrings, seeemacs-lisp-docstring-fill-column.

From the variable documentation, you can set emacs-lisp-docstring-fill-column to any non-integer value to make it use the current fill-column instead.

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.