From 66566a550dfdf30f8b8e8522d196dd00cfc9ae88 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Wed, 30 Sep 2009 14:44:04 -0600 Subject: [PATCH] Fixed fill-paragraph so that it does not break line inside of square brackets (maruku does not like it when you do that) --- markdown-mode.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/markdown-mode.el b/markdown-mode.el index 6a94a477..773a341c 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -1368,6 +1368,12 @@ This is an exact copy of `line-number-at-pos' for use in emacs21." (forward-line 0) (1+ (count-lines start (point)))))) +(defun markdown-nobreak-p () + "Returns nil if it is ok for fill-paragraph to insert a line + break at point" + ;; are we inside in square brackets + (looking-back "\\[[^]]*")) + ;;; Mode definition ========================================================== @@ -1407,6 +1413,14 @@ This is an exact copy of `line-number-at-pos' for use in emacs21." ;(add-to-list 'auto-mode-alist '("\\.text$" . markdown-mode)) + +(add-hook 'markdown-mode-hook + (lambda () + (make-local-variable 'fill-nobreak-predicate) + (add-hook 'fill-nobreak-predicate 'markdown-nobreak-p))) + + + (provide 'markdown-mode) ;;; markdown-mode.el ends here