From d4b31d302f82b1d998fd73a8c3742310297060f0 Mon Sep 17 00:00:00 2001 From: Boruch Baum Date: Sun, 11 Feb 2018 22:57:17 -0500 Subject: [PATCH 1/2] Open links for inbox items * This simply performs `browse-url' rather than do something with the SE API. * By observation, when there are more than one link, the first is a reference and the second is the link of interest, so that one is used. --- sx-interaction.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sx-interaction.el b/sx-interaction.el index 2e2ef576..01ed09a1 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -278,7 +278,12 @@ likes." (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")) +; (sx-message "Viewing notifications is not yet implemented")) + (let ((start 0)) + (while (string-match "\\(http[^\"]+\\)\"" .body start) + (setq .link (match-string 1 .body)) + (setq start (match-end 0)))) + (browse-url .link)) (.item_type (sx-open-link .link))))) (defun sx-display-question (&optional data focus window) From d1c1a319d23cdc938d53ded8aecf80c606a45043 Mon Sep 17 00:00:00 2001 From: Boruch Baum Date: Mon, 12 Feb 2018 10:59:51 -0500 Subject: [PATCH 2/2] create defcustom `sx-browser-function' for inbox use. * When either the StackExchange API does or sx.el do not support the link, this function is used to open it. Creation of a special defcustom is justified because StackExchange links are often javascript-heavy and emacs browsers do not support javascript. --- sx-interaction.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sx-interaction.el b/sx-interaction.el index 01ed09a1..bdcdd33c 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -46,6 +46,14 @@ (require 'sx-compose) (require 'sx-cache) + +;;; defcustoms +(defcustom sx-browser-function 'browse-url + "Name of function to be used to open links that are not yet +supported by either the StackExchange API or by this package." + :type 'function + :group 'sx) + ;;; Using data in buffer (defun sx--data-here (&optional type noerror) @@ -283,7 +291,7 @@ likes." (while (string-match "\\(http[^\"]+\\)\"" .body start) (setq .link (match-string 1 .body)) (setq start (match-end 0)))) - (browse-url .link)) + (funcall sx-browser-function .link)) (.item_type (sx-open-link .link))))) (defun sx-display-question (&optional data focus window)