From 2e527f3e3c4802602c9f1cff659f0c36a39fce2f Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 16 Nov 2014 22:28:50 -0500 Subject: Add function to browse-url in question-mode --- sx-question-mode.el | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'sx-question-mode.el') diff --git a/sx-question-mode.el b/sx-question-mode.el index fdb6487..9653485 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -545,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) @@ -555,18 +556,29 @@ Letters do not insert themselves; instead, they are commands. (,(kbd "") 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 -- cgit v1.2.3