diff options
Diffstat (limited to 'sx-question-print.el')
-rw-r--r-- | sx-question-print.el | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sx-question-print.el b/sx-question-print.el index ca32daf..20f312a 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -141,6 +141,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 @@ -201,6 +206,10 @@ type is not available, images won't work." ;;; Functions ;;;; Printing the general structure +(defconst sx-question-mode--closed-mode-line-string + '(:propertize " [CLOSED] " face font-lock-warning-face) + "String indicating closed questions in the mode-line.") + (defun sx-question-mode--print-question (question) "Print a buffer describing QUESTION. QUESTION must be a data structure returned by `json-read'." @@ -211,8 +220,11 @@ 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 + (add-to-list 'mode-line-format sx-question-mode--closed-mode-line-string) + (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 @@ -223,6 +235,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. Reason: %s " (sx-time-since date) reason) + 'face 'sx-question-mode-closed) + "\n")) + (defun sx-question-mode--print-section (data) "Print a section corresponding to DATA. DATA can represent a question or an answer." |