From 7bbd9ff872e23e111951101d66e355379853507a Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 14 Jan 2015 22:28:09 -0200 Subject: sx-open-link complains if it doesn't know what to do. --- sx-interaction.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 97c68b6..21dde10 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -144,7 +144,11 @@ Element can be a question, answer, or comment." (sx-question-get-from-answer .site_par .id) 'focus)) (question (sx-display-question - (sx-question-get-question .site_par .id) 'focus)))))) + (sx-question-get-question .site_par .id) 'focus)) + (t (sx-message + "Don't know how to open this link, please file a bug report: %s" + link) + nil))))) ;;; Displaying -- cgit v1.2.3 From 344db027640cde39888c5fe4e4e4228b1308f95d Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 14 Jan 2015 22:36:24 -0200 Subject: Reorder sx-display --- sx-interaction.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 21dde10..f122f13 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -163,14 +163,20 @@ likes." (interactive (list (sx--data-here))) (sx-assoc-let data (cond - (.notification_type - (sx-message "Viewing notifications is not yet implemented")) - (.item_type (sx-open-link .link)) + ;; If we have a `title', then we have the question object itself, + ;; and there's no need to fetch anything. + (.title + (sx-display-question data 'focus)) (.answer_id (sx-display-question - (sx-question-get-from-answer .site_par .id) 'focus)) - (.title - (sx-display-question data 'focus))))) + (sx-question-get-from-answer .site_par .id) + 'focus)) + (.question_id + (sx-display-question + (sx-question-get-question .site_par .id) 'focus)) + (.notification_type + (sx-message "Viewing notifications is not yet implemented")) + (.item_type (sx-open-link .link))))) (defun sx-display-question (&optional data focus window) "Display question given by DATA, on WINDOW. -- cgit v1.2.3 From 58280041655c3bd940ea1721af0d4f73e736ca05 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 14 Jan 2015 22:48:38 -0200 Subject: Navigate to answer after printing question --- sx-interaction.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index f122f13..09fa112 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -141,7 +141,8 @@ Element can be a question, answer, or comment." (cl-case .type (answer (sx-display-question - (sx-question-get-from-answer .site_par .id) 'focus)) + (sx-question-get-from-answer .site_par .id) 'focus) + (sx--find-in-buffer 'answer .id)) (question (sx-display-question (sx-question-get-question .site_par .id) 'focus)) @@ -170,7 +171,8 @@ likes." (.answer_id (sx-display-question (sx-question-get-from-answer .site_par .id) - 'focus)) + 'focus) + (sx--find-in-buffer 'answer .answer_id)) (.question_id (sx-display-question (sx-question-get-question .site_par .id) 'focus)) -- cgit v1.2.3 From fc5f8f95844c0cc00ee7038c5a577b641de68939 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 14 Jan 2015 22:56:00 -0200 Subject: Fix sx-display --- sx-interaction.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 09fa112..da9c4aa 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -164,13 +164,17 @@ likes." (interactive (list (sx--data-here))) (sx-assoc-let data (cond - ;; If we have a `title', then we have the question object itself, - ;; and there's no need to fetch anything. - (.title + ;; This is an attempt to identify when we have the question + ;; object itself, so there's no need to fetch anything. This + ;; happens inside the question-list, but it can be easily + ;; confused with the inbox (whose items have a title, a body, and + ;; a question_id. + ((and .title .question_id .score + (not .item_type) (not .notification_type)) (sx-display-question data 'focus)) (.answer_id (sx-display-question - (sx-question-get-from-answer .site_par .id) + (sx-question-get-from-answer .site_par .answer_id) 'focus) (sx--find-in-buffer 'answer .answer_id)) (.question_id -- cgit v1.2.3 From 028d30609b6109b682308c405b586e1eebe65972 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 14:20:29 -0200 Subject: sx-open-link redirects chat links to browser --- sx-interaction.el | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index da9c4aa..d6fdb7f 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -136,20 +136,24 @@ Element can be a question, answer, or comment." (save-excursion (yank)) (thing-at-point 'url)))) (list (read-string (concat "Link (" def "): ") nil nil def)))) - (let ((data (sx--link-to-data link))) - (sx-assoc-let data - (cl-case .type - (answer - (sx-display-question - (sx-question-get-from-answer .site_par .id) 'focus) - (sx--find-in-buffer 'answer .id)) - (question - (sx-display-question - (sx-question-get-question .site_par .id) 'focus)) - (t (sx-message - "Don't know how to open this link, please file a bug report: %s" - link) - nil))))) + ;; For now, we have no chance of handling chat links, let's just + ;; send them to the browser. + (if (string-match (rx string-start "http" (opt "s") "://chat.")) + (sx-visit-externally link) + (let ((data (sx--link-to-data link))) + (sx-assoc-let data + (cl-case .type + (answer + (sx-display-question + (sx-question-get-from-answer .site_par .id) 'focus) + (sx--find-in-buffer 'answer .id)) + (question + (sx-display-question + (sx-question-get-question .site_par .id) 'focus)) + (t (sx-message + "Don't know how to open this link, please file a bug report: %s" + link) + nil)))))) ;;; Displaying -- cgit v1.2.3 From fc1b05b512442db7bf5d7b8a2ee72d1f466a048f Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 16:26:58 -0200 Subject: Add support for opening comments in sx-open-link --- sx-interaction.el | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index d6fdb7f..7c686b5 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -143,6 +143,10 @@ Element can be a question, answer, or comment." (let ((data (sx--link-to-data link))) (sx-assoc-let data (cl-case .type + (comment + (sx-display-question + (sx-question-get-from-comment .site_par .id) 'focus) + (sx--find-in-buffer 'comment .id)) (answer (sx-display-question (sx-question-get-from-answer .site_par .id) 'focus) -- cgit v1.2.3 From ff6af8104166de4dc77842ef1d23079eb38dfaa2 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 16:28:14 -0200 Subject: Missing parentheses --- sx-interaction.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 7c686b5..4f4e31f 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -176,7 +176,7 @@ likes." ;; object itself, so there's no need to fetch anything. This ;; happens inside the question-list, but it can be easily ;; confused with the inbox (whose items have a title, a body, and - ;; a question_id. + ;; a question_id). ((and .title .question_id .score (not .item_type) (not .notification_type)) (sx-display-question data 'focus)) -- cgit v1.2.3 From f37fd1cd03d15aeba44c05d83c515da8196fe889 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 18:25:04 -0200 Subject: Implement comment viewing in sx-display --- sx-interaction.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 4f4e31f..74602f2 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -184,10 +184,20 @@ likes." (sx-display-question (sx-question-get-from-answer .site_par .answer_id) 'focus) - (sx--find-in-buffer 'answer .answer_id)) + (if .comment_id + (sx--find-in-buffer 'comment .comment_id) + (sx--find-in-buffer 'answer .answer_id))) (.question_id (sx-display-question - (sx-question-get-question .site_par .id) 'focus)) + (sx-question-get-question .site_par .question_id) 'focus) + (when .comment_id + (sx--find-in-buffer 'comment .comment_id))) + ;; `sx-question-get-from-comment' takes 2 api requests, so we + ;; test it last. + (.comment_id + (sx-display-question + (sx-question-get-from-comment .site_par .id) 'focus) + (sx--find-in-buffer 'comment .comment_id)) (.notification_type (sx-message "Viewing notifications is not yet implemented")) (.item_type (sx-open-link .link))))) -- cgit v1.2.3 From 6378af6a432f42b99487631117d3ee781fa17b0b Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 19:03:26 -0200 Subject: fix .id -> .comment_id --- sx-interaction.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 74602f2..75b51ab 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -196,7 +196,7 @@ likes." ;; test it last. (.comment_id (sx-display-question - (sx-question-get-from-comment .site_par .id) 'focus) + (sx-question-get-from-comment .site_par .comment_id) 'focus) (sx--find-in-buffer 'comment .comment_id)) (.notification_type (sx-message "Viewing notifications is not yet implemented")) -- cgit v1.2.3