aboutsummaryrefslogtreecommitdiff
path: root/sx-question-print.el
diff options
context:
space:
mode:
Diffstat (limited to 'sx-question-print.el')
-rw-r--r--sx-question-print.el60
1 files changed, 34 insertions, 26 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index 2bfa60d..9f37b10 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -290,18 +290,22 @@ The comment is indented, filled, and then printed according to
(sx--wrap-in-overlay
(list 'sx--data-here comment-data)
(sx-assoc-let comment-data
- (insert
+ (when (> .score 0)
+ (insert (number-to-string .score)
+ (if (eq .upvoted t) "^" "")
+ " "))
+ (insert
(format
- sx-question-mode-comments-format
- (sx-question-mode--propertize-display-name .owner)
- (substring
- ;; We fill with three spaces at the start, so the comment is
- ;; slightly indented.
- (sx-question-mode--fill-and-fontify
- (concat " " .body_markdown))
- ;; Then we remove the spaces from the first line, since we'll
- ;; add the username there anyway.
- 3))))))
+ sx-question-mode-comments-format
+ (sx-question-mode--propertize-display-name .owner)
+ (substring
+ ;; We fill with three spaces at the start, so the comment is
+ ;; slightly indented.
+ (sx-question-mode--fill-and-fontify
+ (concat " " .body_markdown))
+ ;; Then we remove the spaces from the first line, since we'll
+ ;; add the username there anyway.
+ 3))))))
(defun sx-question-mode--insert-header (&rest args)
"Insert propertized ARGS.
@@ -362,10 +366,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)))))
+ (replace-regexp-in-string "[[:blank:]]+\\'" "" (buffer-string))))
(defun sx-question-mode--dont-fill-here ()
"If text shouldn't be filled here, return t and skip over it."
@@ -429,18 +434,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
-