From 8a46c6f7d6c862eaac43cc3b9d70c5c25d575f2c Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 25 Nov 2014 00:44:49 +0000 Subject: visit takes an argument --- sx.el | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'sx.el') 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 -- cgit v1.2.3