From 382fd490f71e00cc293e2ab98cfb7b7b1c59c201 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Fri, 27 Feb 2015 17:48:59 -0300 Subject: Print a header for closed questions. --- sx-question-print.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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." -- cgit v1.2.3 From e63a29e71d645e67275cb962ec0839e61da90863 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Fri, 27 Feb 2015 17:59:54 -0300 Subject: Add mode-line info for closed questions. --- sx-question-print.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sx-question-print.el b/sx-question-print.el index 32a0813..9e726b4 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -201,6 +201,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'." @@ -213,6 +217,7 @@ QUESTION must be a data structure returned by `json-read'." ;; Print everything (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 -- cgit v1.2.3 From dc106bbfdab8ed87847218e0216cc75f5b10cad1 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 2 Mar 2015 20:37:34 -0300 Subject: Swap date and reason --- sx-question-print.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sx-question-print.el b/sx-question-print.el index 9e726b4..3309f3a 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -235,7 +235,7 @@ QUESTION must be a data structure returned by `json-read'." DATE is an integer." (insert "\n " (propertize - (format "Closed %s ago because %s" reason (sx-time-since date)) + (format "Closed %s ago because %s" (sx-time-since date) reason) 'face 'sx-question-mode-closed) "\n\n")) -- cgit v1.2.3 From 5ca0e4fe40410555ee38bde39390a501689ef025 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 2 Mar 2015 20:41:00 -0300 Subject: Improved grammar --- sx-question-print.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sx-question-print.el b/sx-question-print.el index 3309f3a..aaa3cd0 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -235,9 +235,9 @@ QUESTION must be a data structure returned by `json-read'." DATE is an integer." (insert "\n " (propertize - (format "Closed %s ago because %s" (sx-time-since date) reason) + (format " Closed %s ago. Reason: %s " (sx-time-since date) reason) 'face 'sx-question-mode-closed) - "\n\n")) + "\n")) (defun sx-question-mode--print-section (data) "Print a section corresponding to DATA. -- cgit v1.2.3