aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sx-question-mode.el18
-rw-r--r--sx.el14
2 files changed, 16 insertions, 16 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el
index abea6bf..59313d1 100644
--- a/sx-question-mode.el
+++ b/sx-question-mode.el
@@ -217,8 +217,7 @@ QUESTION must be a data structure returned by `json-read'."
(defun sx-question-mode--print-section (data)
"Print a section corresponding to DATA.
DATA can represent a question or an answer."
- ;; This makes `data' accessible through
- ;; `(get-text-property (point) 'sx--data-here)'
+ ;; This makes `data' accessible through `sx--data-here'.
(sx-assoc-let data
(sx--wrap-in-text-property
(list 'sx--data-here data)
@@ -542,7 +541,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)
+ ("v" sx-visit)
("q" quit-window)
(" " scroll-up-command)
(,(kbd "S-SPC") scroll-down-command)
@@ -553,19 +552,6 @@ 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
- ;; This allows us to visit the thing-at-point. Which could be a
- ;; question or an answer. We use `append', so that if one
- ;; doesn't have a `link' item we can fallback to
- ;; `sx-question-mode--data'.
- (append (get-text-property (point) 'sx--data-here)
- 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
diff --git a/sx.el b/sx.el
index ef6bea7..cae5b29 100644
--- a/sx.el
+++ b/sx.el
@@ -162,6 +162,20 @@ Return the result of BODY."
result))
+;;; Using data in buffer
+(defun sx--data-here ()
+ "Get the text property `sx--data-here'."
+ (get-text-property (point) 'sx--data-here))
+
+(defun sx-visit ()
+ "Visit in a web browser the object under point.
+Object can be a question, answer, or comment."
+ (interactive)
+ (sx-assoc-let (sx--data-here)
+ (when (stringp .link)
+ (browse-url .link))))
+
+
;;; Assoc-let
(defun sx--deep-dot-search (data)
"Find symbols somewhere inside DATA which start with a `.'.