From 42f302ab616264348a22107d6fb4d41632ec52a2 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 14 Jan 2015 22:22:36 -0200 Subject: Move sx-question-mode--goto-property-change to sx.el --- sx-question-mode.el | 20 ++------------------ sx.el | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/sx-question-mode.el b/sx-question-mode.el index 5303ebb..6125416 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -121,10 +121,10 @@ Prefix argument N moves N sections down or up." (while (> count 0) ;; This will either move us to the next section, or move out of ;; the current one. - (unless (sx-question-mode--goto-property-change 'section n) + (unless (sx--goto-property-change 'sx-question-mode--section n) ;; If all we did was move out the current one, then move again ;; and we're guaranteed to reach the next section. - (sx-question-mode--goto-property-change 'section n)) + (sx--goto-property-change 'sx-question-mode--section n)) (unless (get-char-property (point) 'invisible) (cl-decf count)))) (when (equal (selected-window) (get-buffer-window)) @@ -140,22 +140,6 @@ Prefix argument moves N sections up or down." (interactive "p") (sx-question-mode-next-section (- (or n 1)))) -(defun sx-question-mode--goto-property-change (prop &optional direction) - "Move forward to the next change of text-property sx-question-mode--PROP. -Return the new value of PROP at point. - -If DIRECTION is negative, move backwards instead." - (let ((prop (intern (format "sx-question-mode--%s" prop))) - (func (if (and (numberp direction) - (< direction 0)) - #'previous-single-property-change - #'next-single-property-change)) - (limit (if (and (numberp direction) - (< direction 0)) - (point-min) (point-max)))) - (goto-char (funcall func (point) prop nil limit)) - (get-text-property (point) prop))) - (defun sx-question-mode-hide-show-section (&optional _) "Hide or show section under point. Optional argument _ is for `push-button'." diff --git a/sx.el b/sx.el index 36ecfca..af4ab4d 100644 --- a/sx.el +++ b/sx.el @@ -259,6 +259,21 @@ whenever BODY evaluates to nil." :filter (lambda (&optional _) (when (progn ,@body) ,def))))) +(defun sx--goto-property-change (prop &optional direction) + "Move forward to the next change of text-property PROP. +Return the new value of PROP at point. + +If DIRECTION is negative, move backwards instead." + (let ((func (if (and (numberp direction) + (< direction 0)) + #'previous-single-property-change + #'next-single-property-change)) + (limit (if (and (numberp direction) + (< direction 0)) + (point-min) (point-max)))) + (goto-char (funcall func (point) prop nil limit)) + (get-text-property (point) prop))) + ;;; Printing request data (defvar sx--overlays nil -- cgit v1.2.3 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(-) 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(-) 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 cd215e056fd092bef5c0867ecd151107516cac09 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 14 Jan 2015 22:47:44 -0200 Subject: Implement sx--find-in-buffer --- sx.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sx.el b/sx.el index af4ab4d..d6c5335 100644 --- a/sx.el +++ b/sx.el @@ -274,6 +274,26 @@ If DIRECTION is negative, move backwards instead." (goto-char (funcall func (point) prop nil limit)) (get-text-property (point) prop))) +(defun sx--find-in-buffer (type id) + "Move point to an object of TYPE and ID. +That is, move forward from beginning of buffer until +`sx--data-here' is an object of type TYPE with the respective id +ID. + +TYPE is either question, answer, or comment. +ID is an integer." + (goto-char (point-min)) + (let (done) + (while (not done) + (let-alist (sx--goto-property-change 'sx--data-here 1) + (setq done (or (eobp) + (= id (cl-case type + (answer .answer_id) + (comment .comment_id) + (question .question_id))))))) + (unless done + (sx-message "Can't find the specified %s" type)))) + ;;; Printing request data (defvar sx--overlays nil -- 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(-) 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(-) 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 acd7a66c79878275e7bda307ee07825877b85bbf Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 14 Jan 2015 23:13:28 -0200 Subject: Fix find in buffer --- sx.el | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/sx.el b/sx.el index d6c5335..8ae7a65 100644 --- a/sx.el +++ b/sx.el @@ -282,17 +282,22 @@ ID. TYPE is either question, answer, or comment. ID is an integer." - (goto-char (point-min)) - (let (done) - (while (not done) - (let-alist (sx--goto-property-change 'sx--data-here 1) - (setq done (or (eobp) - (= id (cl-case type - (answer .answer_id) - (comment .comment_id) - (question .question_id))))))) - (unless done - (sx-message "Can't find the specified %s" type)))) + (let* ((id-symbol (cl-case type + (answer 'answer_id) + (comment 'comment_id) + (question 'question_id))) + (pos + (save-excursion + (goto-char (point-min)) + (while (not (or (eobp) + (let ((data (sx--data-here type t))) + (and data + (= id (or (cdr (assq id-symbol data)))))))) + (forward-char 1)) + (point)))) + (if (equal pos (point-max)) + (sx-message "Can't find the specified %s" type) + (goto-char pos)))) ;;; Printing request data -- cgit v1.2.3 From a36ab1aecfdf62d7d3763cff2490c61cf63d4930 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 14:10:55 -0200 Subject: sx--find-in-buffer moves over end of line --- sx.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sx.el b/sx.el index 8ae7a65..950bbf0 100644 --- a/sx.el +++ b/sx.el @@ -278,7 +278,7 @@ If DIRECTION is negative, move backwards instead." "Move point to an object of TYPE and ID. That is, move forward from beginning of buffer until `sx--data-here' is an object of type TYPE with the respective id -ID. +ID. If point is left at the of a line, move over the line break. TYPE is either question, answer, or comment. ID is an integer." @@ -297,7 +297,9 @@ ID is an integer." (point)))) (if (equal pos (point-max)) (sx-message "Can't find the specified %s" type) - (goto-char pos)))) + (goto-char pos) + (when (looking-at-p "$") + (forward-char 1))))) ;;; Printing request data -- 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(-) 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 96e421160c5e682cedb8786b8a4bdbf59d7790d5 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 14:28:45 -0200 Subject: Add comment support on sx--link-to-data --- sx.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sx.el b/sx.el index 950bbf0..ff481c1 100644 --- a/sx.el +++ b/sx.el @@ -93,6 +93,17 @@ with a `link' property)." (let ((result (list (cons 'site_par (sx--site link))))) ;; Try to strip a question or answer ID (when (or + ;; Comment + (and (string-match + ;; From inbox items + (rx "/posts/comments/" + ;; Comment ID + (group-n 1 (+ digit)) + ;; Stuff at the end + (or (sequence (any "?#") (* any)) "") + string-end) + link) + (push '(type . comment) result)) ;; Answer (and (or (string-match ;; From 'Share' button -- cgit v1.2.3 From 679894374c9c537ec4404b80d2828ef123695391 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 15:11:12 -0200 Subject: Use cond in sx--link-to-data and better regexps --- sx.el | 106 +++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 57 insertions(+), 49 deletions(-) diff --git a/sx.el b/sx.el index ff481c1..ab39202 100644 --- a/sx.el +++ b/sx.el @@ -92,57 +92,65 @@ with a `link' property)." "Convert string LINK into data that can be displayed." (let ((result (list (cons 'site_par (sx--site link))))) ;; Try to strip a question or answer ID - (when (or - ;; Comment - (and (string-match - ;; From inbox items - (rx "/posts/comments/" - ;; Comment ID - (group-n 1 (+ digit)) - ;; Stuff at the end - (or (sequence (any "?#") (* any)) "") - string-end) - link) - (push '(type . comment) result)) + (when (cond ;; Comment + ((string-match ;; From inbox items + (rx "/posts/comments/" + ;; Comment ID + (group-n 1 (+ digit)) + ;; Optional stuff at the end + (or (and (any "?#") (* any)) "") + string-end) + link) + (push '(type . comment) result)) ;; Answer - (and (or (string-match - ;; From 'Share' button - (rx "/a/" - ;; Question ID - (group (+ digit)) - ;; User ID - "/" (+ digit) - ;; Answer ID - (group (or (sequence "#" (* any)) "")) - string-end) link) - (string-match - ;; From URL - (rx "/questions/" (+ digit) "/" - (+ (not (any "/"))) "/" - ;; User ID - (optional (group (+ digit))) - (optional "/") - (group (or (sequence "#" (* any)) "")) - string-end) link)) - (push '(type . answer) result)) + ((or ;; If there's a #NUMBER at the end, we know it's an + ;; answer with that ID. + (string-match (rx "#" (group-n 1 (+ digit)) string-end) link) + ;; From 'Share' button + (string-match (rx "/a/" + ;; Answer ID + (group-n 1 (+ digit)) "/" + ;; User ID + (+ digit) + ;; Garbage at the end + (optional (and (any "?#") (* any))) + string-end) + link) + ;; From URL + (string-match (rx "/questions/" (+ digit) "/" + ;; Question title + (+ (not (any "/"))) "/" + ;; Answer ID. If this is absent, we match on + ;; Question clause below. + (group-n 1 (+ digit)) + (opt "/") + ;; Garbage at the end + (optional (and (any "?#") (* any))) + string-end) + link)) + (push '(type . answer) result)) ;; Question - (and (or (string-match - ;; From 'Share' button - (rx "/q/" - ;; Question ID - (group (+ digit)) - ;; User ID - (optional "/" (+ digit)) - ;; Answer or Comment ID - (group (or (sequence "#" (* any)) "")) - string-end) link) - (string-match - ;; From URL - (rx "/questions/" - ;; Question ID - (group (+ digit)) - "/") link)) - (push '(type . question) result))) + ((or ;; From 'Share' button + (string-match (rx "/q/" + ;; Question ID + (group-n 1 (+ digit)) + ;; User ID + (optional "/" (+ digit)) + ;; Garbage at the end + (optional (and (any "?#") (* any))) + string-end) + link) + ;; From URL + (string-match (rx "/questions/" + ;; Question ID + (group-n 1 (+ digit)) "/" + ;; Optional question title + (optional (+ (not (any "/"))) "/") + ;; Garbage at the end + (optional (and (any "?#") (* any))) + string-end) + link)) + (push '(type . question) result))) (push (cons 'id (string-to-number (match-string-no-properties 1 link))) result)) result)) -- cgit v1.2.3 From 872e2bea0220b36a6dc9a4fdd8c08b1fde3cf61f Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 15:14:12 -0200 Subject: Add support for another type of comment on sx--link-to-data --- sx.el | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sx.el b/sx.el index ab39202..785e0c4 100644 --- a/sx.el +++ b/sx.el @@ -93,14 +93,19 @@ with a `link' property)." (let ((result (list (cons 'site_par (sx--site link))))) ;; Try to strip a question or answer ID (when (cond ;; Comment - ((string-match ;; From inbox items - (rx "/posts/comments/" - ;; Comment ID - (group-n 1 (+ digit)) - ;; Optional stuff at the end - (or (and (any "?#") (* any)) "") - string-end) - link) + ((or ;; If there's a #commentNUMBER_NUMBER at the end, we + ;; know it's a comment with that ID. + (string-match (rx "#comment" (group-n 1 (+ digit)) + "_" (+ digit) string-end) + link) + ;; From inbox items + (string-match (rx "/posts/comments/" + ;; Comment ID + (group-n 1 (+ digit)) + ;; Optional stuff at the end + (or (and (any "?#") (* any)) "") + string-end) + link)) (push '(type . comment) result)) ;; Answer ((or ;; If there's a #NUMBER at the end, we know it's an -- cgit v1.2.3 From a212dc9a11540446cbdda24cf84387171cb989e7 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 15:15:23 -0200 Subject: Add tests for link-to-data --- test/test-util.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test-util.el b/test/test-util.el index 1e3dc2b..b466c08 100644 --- a/test/test-util.el +++ b/test/test-util.el @@ -43,3 +43,29 @@ (lambda (path) (intern (mapconcat #'symbol-name path "/"))) '(a b (c d (e f g) h i (j k) l) m (n o) p)) '(a b c/d c/e/f c/e/g c/h c/i c/j/k c/l m n/o p)))) + +(ert-deftest link-to-data () + (should + (equal + (sx--link-to-data "http://meta.emacs.stackexchange.com/posts/comments/510?noredirect=1") + '((id . 510) (type . comment) (site_par . "meta.emacs")))) + (should + (equal + (sx--link-to-data "http://emacs.stackexchange.com/questions/7409/is-there-a-generic-toggle-previous-window-function#comment10965_7409") + '((id . 10965) (type . comment) (site_par . "emacs")))) + (should + (equal + (sx--link-to-data "http://emacs.stackexchange.com/q/7409/50") + '((id . 7409) (type . question) (site_par . "emacs")))) + (should + (equal + (sx--link-to-data "http://emacs.stackexchange.com/a/7410/50") + '((id . 7410) (type . answer) (site_par . "emacs")))) + (should + (equal + (sx--link-to-data "http://emacs.stackexchange.com/questions/7409/is-there-a-generic-toggle-previous-window-function/9999#7410") + '((id . 7410) (type . answer) (site_par . "emacs")))) + (should + (equal + (sx--link-to-data "http://emacs.stackexchange.com/questions/7409/is-there-a-generic-toggle-previous-window-function/7410") + '((id . 7410) (type . answer) (site_par . "emacs"))))) -- cgit v1.2.3 From 94096714aef5088cce1a1c75aadf925e82d82a40 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Thu, 15 Jan 2015 16:26:36 -0200 Subject: Implement question-get-from-comment --- sx-question.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sx-question.el b/sx-question.el index 1adbc24..35eabc8 100644 --- a/sx-question.el +++ b/sx-question.el @@ -72,6 +72,26 @@ If ANSWER-ID doesn't exist on SITE, raise an error." (error "Couldn't find answer %S in %S" answer-id site)))) +(defun sx-question-get-from-comment (site comment-id) + "Get question from SITE to which COMMENT-ID belongs. +If COMMENT-ID doesn't exist on SITE, raise an error. + +Note this requires two API requests. One for the comment and one +for the post." + (let ((res (sx-method-call 'comments + :id comment-id + :site site + :auth t + :filter sx-browse-filter))) + (unless (vectorp res) + (error "Couldn't find comment %S in %S" comment-id site)) + (sx-assoc-let (elt res 0) + (funcall (if (string= .post_type "answer") + #'sx-question-get-from-answer + #'sx-question-get-question) + .site_par + .post_id)))) + ;;; Question Properties -- 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(+) 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(-) 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(-) 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(-) 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