aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-12-17 13:23:58 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-12-17 13:49:46 -0200
commita5cb69f2937500e5c035ff6588c1f25a5a611833 (patch)
treefea2e33f42dd6b4b0db2deb77996024a96e1600d
parent6d8a8d5dc07fb8a58344775632716dbe781479a3 (diff)
Hotfix filling code blocks. Fix #163
When filling a paragraph, narrow to region after point, so we don't affect anything behind point (the code block).
-rw-r--r--sx-question-print.el34
1 files changed, 19 insertions, 15 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index dc853ba..223049a 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -362,10 +362,11 @@ E.g.:
(while (null (eobp))
;; Don't fill pre blocks.
(unless (sx-question-mode--dont-fill-here)
- (skip-chars-forward "\r\n[:blank:]")
- (fill-paragraph)
- (forward-paragraph)))
- (buffer-string)))
+ (let ((beg (point)))
+ (skip-chars-forward "\r\n[:blank:]")
+ (forward-paragraph)
+ (fill-region beg (point)))))
+ (string-trim-right (buffer-string))))
(defun sx-question-mode--dont-fill-here ()
"If text shouldn't be filled here, return t and skip over it."
@@ -429,18 +430,21 @@ If ID is nil, use FALLBACK-ID instead."
"If there's a pre block ahead, handle it, skip it and return t.
Handling means to turn it into a button and remove erroneous
font-locking."
- (let (beg end)
- (when (markdown-match-pre-blocks
+ (let ((before (point))
+ beg end)
+ (if (markdown-match-pre-blocks
+ (save-excursion
+ (skip-chars-forward "\r\n[:blank:]")
+ (setq beg (point))))
+ (progn
+ (setq end (point))
+ (sx-babel--make-pre-button
(save-excursion
- (skip-chars-forward "\r\n[:blank:]")
- (setq beg (point))))
- (setq end (point))
- (sx-babel--make-pre-button
- (save-excursion
- (goto-char beg)
- (line-beginning-position))
- end))))
+ (goto-char beg)
+ (line-beginning-position))
+ end))
+ (goto-char before)
+ nil)))
(provide 'sx-question-print)
;;; sx-question-print.el ends here
-