diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-04-19 13:46:21 +0100 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-04-19 13:46:31 +0100 |
commit | 706530f8f96dec5725a46774d85fe98c6b54912a (patch) | |
tree | 829c2d3ffeb8a992598d45e1f3e5dc94f29056af /sx-question-print.el | |
parent | 48887789f077b0a9d810f6c9dc9694899d873514 (diff) |
Add Accept button to answers. Fixes #276
Diffstat (limited to 'sx-question-print.el')
-rw-r--r-- | sx-question-print.el | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sx-question-print.el b/sx-question-print.el index 3dcb4ae..f99b4be 100644 --- a/sx-question-print.el +++ b/sx-question-print.el @@ -28,6 +28,8 @@ (require 'sx-babel) (require 'sx-user) +(defvar sx-question-mode--data) + (defgroup sx-question-mode nil "Customization group for sx-question-mode." :prefix "sx-question-mode-" @@ -275,6 +277,14 @@ DETAILS, when given is an alist further describing the close." (overlay-put ov 'face 'sx-question-mode-closed-reason) (push ov sx--overlays))))) +(defun sx-question-mode--maybe-print-accept-button () + "Print accept button if you own this question." + (when (sx-assoc-let sx-question-mode--data + (= .owner.user_id + (cdr (assq 'user_id (sx-network-user .site_par))))) + (insert " ") + (insert-text-button "Accept" :type 'sx-button-accept))) + (defun sx-question-mode--print-section (data) "Print a section corresponding to DATA. DATA can represent a question or an answer." @@ -294,6 +304,8 @@ DATA can represent a question or an answer." 'face (if .is_accepted 'sx-question-mode-accepted 'sx-question-mode-title) :type 'sx-question-mode-title) + (when (not (or .title .is_accepted)) + (sx-question-mode--maybe-print-accept-button)) ;; Sections can be hidden with overlays (sx--wrap-in-overlay |