aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-12-17 15:44:45 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-12-20 16:58:24 -0200
commit8d1c9e8a29e890d1d37c5caa649a0861b1621bfa (patch)
treef26c15116fbd7505a72f744c6904b34932206571
parente39a909dc722dfdb48ecc4533cf061dbb209abf1 (diff)
sx-open-link: command to visit links inside SX
-rw-r--r--sx-interaction.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/sx-interaction.el b/sx-interaction.el
index 2c392e1..38efe5d 100644
--- a/sx-interaction.el
+++ b/sx-interaction.el
@@ -128,6 +128,19 @@ If DATA is a question, also mark it as read."
(sx-question--mark-read data)
(sx--maybe-update-display))))
+(defun sx-open-link (link)
+ "Visit element given by LINK inside Emacs.
+Element can be a question, answer, or comment."
+ (interactive "sLink: ")
+ (let ((data (sx--link-to-data link)))
+ (sx-assoc-let data
+ (cl-case .type
+ (answer
+ (sx-display-question
+ (sx-question-get-from-answer .site .id) 'focus))
+ (question
+ (sx-display-question
+ (sx-question-get-question .site .id) 'focus))))))
;;; Displaying