aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-11-25 00:29:35 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-11-25 00:29:35 +0000
commitb9988e7ae3df4503d30da36f749b8537eaa6465b (patch)
tree057bab026910680dda89c9224de8d31fdabe5b2e
parentfb1058921f841f92e99dce56206b79b22684b9a6 (diff)
Refactor visit from question-list to sx
-rw-r--r--sx-question-list.el12
-rw-r--r--sx.el16
2 files changed, 13 insertions, 15 deletions
diff --git a/sx-question-list.el b/sx-question-list.el
index 4d80305..ddc04c7 100644
--- a/sx-question-list.el
+++ b/sx-question-list.el
@@ -287,7 +287,7 @@ into consideration.
("K" sx-question-list-previous-far)
("g" sx-question-list-refresh)
(":" sx-question-list-switch-site)
- ("v" sx-question-list-visit)
+ ("v" sx-visit)
("h" sx-question-list-hide)
("m" sx-question-list-mark-read)
([?\r] sx-question-list-display-question)))
@@ -383,16 +383,6 @@ a new list before redisplaying."
(cl-remove-if #'sx-question--hidden-p question-list))))
(when redisplay (tabulated-list-print 'remember)))
-(defun sx-question-list-visit (&optional data)
- "Visits question under point (or from DATA) using `browse-url'."
- (interactive)
- (unless data (setq data (tabulated-list-get-id)))
- (unless data (error "No question here!"))
- (sx-assoc-let data
- (browse-url .link))
- (sx-question--mark-read data)
- (sx-question-list-refresh 'redisplay 'no-update))
-
(defcustom sx-question-list-ago-string " ago"
"String appended to descriptions of the time since something happened.
Used in the questions list to indicate a question was updated
diff --git a/sx.el b/sx.el
index cae5b29..018b1ec 100644
--- a/sx.el
+++ b/sx.el
@@ -27,6 +27,7 @@
;; StackMode.
;;; Code:
+(require 'tabulated-list)
(defconst sx-version "0.1" "Version of the `sx' package.")
@@ -165,15 +166,22 @@ Return the result of BODY."
;;; Using data in buffer
(defun sx--data-here ()
"Get the text property `sx--data-here'."
- (get-text-property (point) 'sx--data-here))
+ (or (get-text-property (point) 'sx--data-here)
+ (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)
- (sx-assoc-let (sx--data-here)
- (when (stringp .link)
- (browse-url .link))))
+ (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))))))
;;; Assoc-let