4

I'm relatively new to Emacs, but have been experimenting with it to see if it would be worth switching. I write in Markdown and use pandoc to convert to whatever I need. In case it matters, I'm running Emacs 23.3.1 on Ubuntu 12.04.

I'm a graduate student in the humanities, so my writing is heavy on the footnotes. Footnotes, in pandoc, are formatted within square brackets. The problem I'm having is that auto-fill mode seems to ignore text within brackets, so my footnotes end up snaking their way across the page--and the only fix I've been able to find is to manually break the lines myself, every time I edit the paragraph. That's obviously less than ideal. (I could also give up on inline footnotes, and leave them all separate references, but I'd prefer not to, and it doesn't seem like that should be necessary.)

So my question is, is there a way to make auto-fill mode operate on text within brackets, too? Is there a reason it doesn't by default?

Many thanks,

-- Brian

Brian Hamilton
  • 349
  • 2
  • 7
  • What major mode are you in? (M-x describe-mode). If you disable all local configurations (by starting emacs with "emacs -Q" from the command-line) does the problem still happen? – David Röthlisberger May 27 '12 at 17:26
  • I'm in Markdown mode, and no: it seems to be confined to that mode. I've sent an email off to the maintainer, but if anyone has any suggestions in the meantime I'd be happy to hear them. – Brian Hamilton May 28 '12 at 16:51

3 Answers3

3

It turns out that markdown-mode, as of v. 1.7, deliberately avoids breaking lines in square brackets in order to avoid breaking links--which is the most common use of brackets for Markdown. See http://jblevins.org/projects/markdown-mode/rev-1-7.

Brian Hamilton
  • 349
  • 2
  • 7
  • The specific commit that avoids breaking lines in square brackets is: http://jblevins.org/git/markdown-mode.git/commit/?id=66566a55 -- so you could redefine markdown-nobreak-p to always return true (hacky but it should work). – David Röthlisberger May 30 '12 at 11:33
  • @DavidRöthlisberger If you explain to me how to redefine this for my own installation in a separate answer, I'd happily mark it as my answer. That would be really helpful. – Brian Hamilton May 31 '12 at 07:22
2

Brian,

Add the following to your init file† to allow auto-fill in markdown-mode to break lines inside square brackets:

(require 'markdown-mode)
(defun markdown-nobreak-p () nil)

What we did is redefine the function "markdown-nobreak-p" (originally defined here: http://jblevins.org/git/markdown-mode.git/commit/?id=66566a55 ) to always return "nil" which means "yes you are allowed to break at this point". The original version of this function would return non-nil for points inside square brackets.

http://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html

David Röthlisberger
  • 1,786
  • 15
  • 20
0

Auto-fill by itself does not prevent filling inside brackets. It can be told to do so by the major-mode, tho, so I guess the problem depends on your major mode. If you're using mardown-mode, then please report this problem to its maintainer. In any case, you may want to try and use M-q to explicitly fill the paragraph, since it does not always follow the same conventions as auto-filling: it's more explicit than auto-fill, but still more automatic than placing the newlines by hand.

Stefan
  • 27,908
  • 4
  • 53
  • 82
  • Thanks, @Stefan. I figured out that it was indeed Markdown mode that was causing the problems, and I'll send an email to the maintainer to figure out how to do. I've tried `M-q`, and unfortunately that doesn't work either. – Brian Hamilton May 28 '12 at 16:41