aboutsummaryrefslogtreecommitdiff
path: root/sx-question-mode.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-11-17 11:33:53 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-11-17 11:33:53 +0000
commit34d28e79f4a6049dc4ceb44397a2ca0725cecd5f (patch)
tree74df45a8c97a39c96283c304f8068ae0d1b0d428 /sx-question-mode.el
parent7052a69347e965ac94ea691c8bfe88a1f3825855 (diff)
Define -visit to use answer link if available.
Diffstat (limited to 'sx-question-mode.el')
-rw-r--r--sx-question-mode.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/sx-question-mode.el b/sx-question-mode.el
index 2c4adb3..20d93c4 100644
--- a/sx-question-mode.el
+++ b/sx-question-mode.el
@@ -324,6 +324,16 @@ Return the result of BODY."
(push ov sx-question-mode--overlays))
result))
+(defmacro sx-question-mode--wrap-in-text-property (properties &rest body)
+ "Execute BODY and PROPERTIES to any inserted text.
+Return the result of BODY."
+ (declare (indent 1)
+ (debug t))
+ `(let ((p (point-marker))
+ (result (progn ,@body)))
+ (add-text-properties p (point) ,properties)
+ result))
+
(defun sx-question-mode--insert-header (&rest args)
"Insert HEADER and VALUE.
HEADER is given `sx-question-mode-header' face, and value is given FACE.
@@ -564,7 +574,13 @@ Letters do not insert themselves; instead, they are commands.
"Visit the currently displayed question."
(interactive)
(sx-question-mode--ensure-mode)
- (sx-assoc-let sx-question-mode--data
+ (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-question-mode--data-here)
+ sx-question-mode--data)
(browse-url .link)))
(defun sx-question-mode-refresh ()