diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-03-02 21:25:14 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-03-02 21:25:14 +0000 |
commit | 15f8ff56312f16f79a2520c08a184f8d79732d1f (patch) | |
tree | a3842ed2d1651f26a73144b3223a144294f9a42f | |
parent | 61cb89278b8bf3349af1944c0cd3f9f3fa93545c (diff) | |
parent | 5c0f594a5ee0cab2a277fe1a1541b44a492e57fb (diff) |
Merge pull request #270 from vermiculus/closed-questions
Closed questions
-rw-r--r-- | sx-filter.el | 3 | ||||
-rw-r--r-- | sx-question-print.el | 42 |
2 files changed, 37 insertions, 8 deletions
diff --git a/sx-filter.el b/sx-filter.el index 1ccf611..5848e34 100644 --- a/sx-filter.el +++ b/sx-filter.el @@ -111,6 +111,9 @@ return the compiled filter." bounty_amount comments creation_date + closed_reason + closed_date + closed_details answers answer_count score diff --git a/sx-question-print.el b/sx-question-print.el index 20f312a..69a5090 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -146,6 +146,15 @@ the editor's name." "Face used for closed question header in the question buffer." :group 'sx-question-mode-faces) +(defface sx-question-mode-closed-reason + `((t :box (:line-width 2 :color ,(face-attribute 'sx-question-mode-closed + :foreground nil t)) + :inherit sx-question-mode-title)) + "Face used for closed question header in the question buffer. +Aesthetically, it's important that the color of this face's :box +attribute match the color of the face `sx-question-mode-closed'." + :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 @@ -223,7 +232,7 @@ QUESTION must be a data structure returned by `json-read'." (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-close-reason .closed_reason .closed_date .closed_details)) (sx-question-mode--print-section question) (mapc #'sx-question-mode--print-section (cl-remove-if @@ -235,14 +244,31 @@ 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) +(defun sx-question-mode--print-close-reason (reason date &optional details) "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")) +DATE is an integer. + +DETAILS, when given is an alist further describing the close." + (let ((l (point))) + (let-alist details + (insert "\n " + (propertize (format " %s as %s, %s ago. " + (if .on_hold "Put on hold" "Closed") + reason + (sx-time-since date)) + 'face 'sx-question-mode-closed) + "\n") + (when .description + (insert (replace-regexp-in-string "<[^>]+>" "" .description) + "\n"))) + (save-excursion + (goto-char l) + (search-forward " as " nil 'noerror) + (setq l (point)) + (skip-chars-forward "^,") + (let ((ov (make-overlay l (point)))) + (overlay-put ov 'face 'sx-question-mode-closed-reason) + (push ov sx--overlays))))) (defun sx-question-mode--print-section (data) "Print a section corresponding to DATA. |