aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-11-25 00:44:49 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-11-25 00:44:49 +0000
commit8a46c6f7d6c862eaac43cc3b9d70c5c25d575f2c (patch)
treebc1c48e7e421add848555cde2f11665ddc62341f
parentb586f599d588836cc6b9e1a42b0d51f6e4086c6c (diff)
visit takes an argument
-rw-r--r--sx.el25
1 files changed, 13 insertions, 12 deletions
diff --git a/sx.el b/sx.el
index 018b1ec..0bab861 100644
--- a/sx.el
+++ b/sx.el
@@ -170,18 +170,19 @@ Return the result of BODY."
(and (derived-mode-p 'sx-question-list-mode)
(tabulated-list-get-id))))
-(defun sx-visit ()
- "Visit in a web browser the object under point.
-Object can be a question, answer, or comment."
- (interactive)
- (let ((data (sx--data-here)))
- (sx-assoc-let data
- (when (stringp .link)
- (browse-url .link))
- (when .title
- (sx-question--mark-read data)
- (when (derived-mode-p 'sx-question-list-mode)
- (sx-question-list-refresh 'redisplay 'no-update))))))
+(defun sx-visit (data)
+ "Visit DATA in a web browser.
+DATA can be a question, answer, or comment. Interactively, it is
+derived from point position.
+If DATA is a question, also mark it as read."
+ (interactive (list (sx--data-here)))
+ (sx-assoc-let data
+ (when (stringp .link)
+ (browse-url .link))
+ (when (and .title (fboundp 'sx-question--mark-read))
+ (sx-question--mark-read data)
+ (when ((derived-mode-p 'sx-question-list-mode))
+ (sx-question-list-refresh 'redisplay 'no-update)))))
;;; Assoc-let