aboutsummaryrefslogtreecommitdiff
path: root/sx-question-mode.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2014-11-17 08:46:35 -0500
committerSean Allred <code@seanallred.com>2014-11-17 08:46:35 -0500
commit329cd7a67415f3c0092497ebdb714d3446819175 (patch)
tree9bba30d45cbdc150d60cd5ba037ffc0e54cc5a2d /sx-question-mode.el
parentabb70f545aa7594a7c37e8335614c23a692b8a03 (diff)
parent2e527f3e3c4802602c9f1cff659f0c36a39fce2f (diff)
Merge pull request #68 from vermiculus/question-mode-keybindings
Question mode keybindings
Diffstat (limited to 'sx-question-mode.el')
-rw-r--r--sx-question-mode.el17
1 files changed, 15 insertions, 2 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el
index 03647bc..aa15f85 100644
--- a/sx-question-mode.el
+++ b/sx-question-mode.el
@@ -192,6 +192,7 @@ Second \"%s\" is replaced with the comment."
(defun sx-question-mode--print-question (question)
"Print a buffer describing QUESTION.
QUESTION must be a data structure returned by `json-read'."
+ (setq sx-question-mode--data question)
;; Clear the overlays
(mapc #'delete-overlay sx-question-mode--overlays)
(setq sx-question-mode--overlays nil)
@@ -544,6 +545,7 @@ Letters do not insert themselves; instead, they are commands.
`(("n" sx-question-mode-next-section)
("p" sx-question-mode-previous-section)
("g" sx-question-mode-refresh)
+ ("v" sx-question-mode-visit)
("q" quit-window)
(" " scroll-up-command)
(,(kbd "S-SPC") scroll-down-command)
@@ -554,18 +556,29 @@ Letters do not insert themselves; instead, they are commands.
(,(kbd "<backtab>") backward-button)
([return] push-button)))
+(defun sx-question-mode-visit ()
+ "Visit the currently displayed question."
+ (interactive)
+ (sx-question-mode--ensure-mode)
+ (sx-assoc-let sx-question-mode--data
+ (browse-url .link)))
+
(defun sx-question-mode-refresh ()
"Refresh currently displayed question.
Queries the API for any changes to the question or its answers or
comments, and redisplays it."
(interactive)
- (unless (derived-mode-p 'sx-question-mode)
- (error "Not in `sx-question-mode'"))
+ (sx-question-mode--ensure-mode)
(sx-assoc-let sx-question-mode--data
(sx-question-mode--display
(sx-question-get-question
sx-question-list--current-site .question_id)
(selected-window))))
+(defun sx-question-mode--ensure-mode ()
+ "Ensures we are in question mode, erroring otherwise."
+ (unless (derived-mode-p 'sx-question-mode)
+ (error "Not in `sx-question-mode'")))
+
(provide 'sx-question-mode)
;;; sx-question-mode.el ends here