aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-02-15 12:57:04 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-02-15 12:57:04 -0200
commite19068da5bc6ab29b3a0cd21daed3cf98708df39 (patch)
treef9fea4e250f3aa73ff82255f2ce4161491067a67
parentdc4d2bee678428eb004d963bd21e08a347ef622e (diff)
Fix paragraph filling
-rw-r--r--sx-question-print.el34
1 files changed, 20 insertions, 14 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index 160074d..e42e983 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -352,20 +352,26 @@ E.g.:
This does not do Markdown font-locking. Instead, it fills text,
propertizes links, inserts images, cleans up html comments, and
font-locks code-blocks according to mode."
- (save-restriction
- (save-excursion
- (narrow-to-region beg end)
- ;; Compact links.
- (sx-question-mode--process-links-in-buffer)
- ;; And now the filling and other handlings.
- (goto-char (point-min))
- (while (null (eobp))
- ;; Don't fill pre blocks.
- (unless (sx-question-mode--dont-fill-here)
- (let ((beg (point)))
- (skip-chars-forward "\r\n[:blank:]")
- (forward-paragraph)
- (fill-region beg (point))))))))
+ ;; Paragraph filling
+ (let ((paragraph-start
+ "\f\\|[ \t]*$\\|[ \t]*[*+-] \\|[ \t]*[0-9]+\\.[ \t]\\|[ \t]*: ")
+ (paragraph-separate "\\(?:[ \t\f]*\\|.* \\)$")
+ (adaptive-fill-first-line-regexp "\\`[ \t]*>[ \t]*?\\'")
+ (adaptive-fill-function #'markdown-adaptive-fill-function))
+ (save-restriction
+ (save-excursion
+ (narrow-to-region beg end)
+ ;; Compact links.
+ (sx-question-mode--process-links-in-buffer)
+ ;; And now the filling and other handlings.
+ (goto-char (point-min))
+ (while (null (eobp))
+ ;; Don't fill pre blocks.
+ (unless (sx-question-mode--dont-fill-here)
+ (let ((beg (point)))
+ (skip-chars-forward "\r\n[:blank:]")
+ (forward-paragraph)
+ (fill-region beg (point)))))))))
(defun sx-question-mode--insert-markdown (text)
"Return TEXT fontified according to `markdown-mode'."