aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-02-27 17:48:59 -0300
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-02-27 18:51:28 -0300
commit382fd490f71e00cc293e2ab98cfb7b7b1c59c201 (patch)
treeef3216a4b24c901327e7f0d30090e04f478f4697
parentaa1368c104aebf837fd7654deea8d244428616a2 (diff)
Print a header for closed questions.
-rw-r--r--sx-question-print.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index 5799c96..32a0813 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -136,6 +136,11 @@ the editor's name."
"Face used for accepted answers in the question buffer."
:group 'sx-question-mode-faces)
+(defface sx-question-mode-closed
+ '((t :box 2 :inherit font-lock-warning-face))
+ "Face used for closed question header in the question buffer."
+ :group 'sx-question-mode-faces)
+
(defcustom sx-question-mode-answer-accepted-title "Accepted Answer"
"Title used at the start of accepted \"Answer\" section."
:type 'string
@@ -206,8 +211,10 @@ QUESTION must be a data structure returned by `json-read'."
(mapc #'delete-overlay sx--overlays)
(setq sx--overlays nil)
;; Print everything
- (sx-question-mode--print-section question)
(sx-assoc-let question
+ (when .closed_reason
+ (sx-question-mode--print-close-reason .closed_reason .closed_date))
+ (sx-question-mode--print-section question)
(mapc #'sx-question-mode--print-section
(cl-remove-if
#'sx--deleted-p
@@ -218,6 +225,15 @@ QUESTION must be a data structure returned by `json-read'."
(goto-char (point-min))
(sx-question-mode-next-section))
+(defun sx-question-mode--print-close-reason (reason date)
+ "Print a header explaining REASON and DATE.
+DATE is an integer."
+ (insert "\n "
+ (propertize
+ (format "Closed %s ago because %s" reason (sx-time-since date))
+ 'face 'sx-question-mode-closed)
+ "\n\n"))
+
(defun sx-question-mode--print-section (data)
"Print a section corresponding to DATA.
DATA can represent a question or an answer."