From e39a909dc722dfdb48ecc4533cf061dbb209abf1 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 17 Dec 2014 15:35:54 -0200 Subject: Implement identifying type, id, and site of a link. --- sx-interaction.el | 1 + 1 file changed, 1 insertion(+) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index e7a4d94..2c392e1 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -128,6 +128,7 @@ If DATA is a question, also mark it as read." (sx-question--mark-read data) (sx--maybe-update-display)))) + ;;; Displaying (defun sx-display-question (&optional data focus window) -- cgit v1.2.3 From 8d1c9e8a29e890d1d37c5caa649a0861b1621bfa Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 17 Dec 2014 15:44:45 -0200 Subject: sx-open-link: command to visit links inside SX --- sx-interaction.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 2c392e1..38efe5d 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -128,6 +128,19 @@ If DATA is a question, also mark it as read." (sx-question--mark-read data) (sx--maybe-update-display)))) +(defun sx-open-link (link) + "Visit element given by LINK inside Emacs. +Element can be a question, answer, or comment." + (interactive "sLink: ") + (let ((data (sx--link-to-data link))) + (sx-assoc-let data + (cl-case .type + (answer + (sx-display-question + (sx-question-get-from-answer .site .id) 'focus)) + (question + (sx-display-question + (sx-question-get-question .site .id) 'focus)))))) ;;; Displaying -- cgit v1.2.3 From abaad8b3c57355be672e13a2f5cdff3d651e91d0 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 20 Dec 2014 16:59:09 -0200 Subject: Refactor sx-visit to sx-visit-externally --- sx-interaction.el | 2 +- sx-question-list.el | 2 +- sx-question-mode.el | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 38efe5d..ed8891b 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -106,7 +106,7 @@ Only fields contained in TO are copied." ;;; Visiting -(defun sx-visit (data &optional copy-as-kill) +(defun sx-visit-externally (data &optional copy-as-kill) "Visit DATA in a web browser. DATA can be a question, answer, or comment. Interactively, it is derived from point position. diff --git a/sx-question-list.el b/sx-question-list.el index 94b5be4..f6a82e2 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -317,7 +317,7 @@ into consideration. (":" sx-question-list-switch-site) ("t" sx-question-list-switch-tab) ("a" sx-ask) - ("v" sx-visit) + ("v" sx-visit-externally) ("u" sx-toggle-upvote) ("d" sx-toggle-downvote) ("h" sx-question-list-hide) diff --git a/sx-question-mode.el b/sx-question-mode.el index b376616..807eeea 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -224,7 +224,7 @@ Letters do not insert themselves; instead, they are commands. ("p" sx-question-mode-previous-section) ("g" sx-question-mode-refresh) ("c" sx-comment) - ("v" sx-visit) + ("v" sx-visit-externally) ("u" sx-toggle-upvote) ("d" sx-toggle-downvote) ("q" quit-window) -- cgit v1.2.3 From 72cdd44dbfe6266f33471012091b58f85d5b7d88 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 20 Dec 2014 17:03:59 -0200 Subject: sx-open-link takes link from clipboard by default --- 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 ed8891b..2b41b35 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -131,7 +131,11 @@ If DATA is a question, also mark it as read." (defun sx-open-link (link) "Visit element given by LINK inside Emacs. Element can be a question, answer, or comment." - (interactive "sLink: ") + (interactive + (let ((def (with-temp-buffer + (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 -- cgit v1.2.3 From fb52d842299e1826915bcae5c6fbb6e0e1f617ec Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 20 Dec 2014 17:04:20 -0200 Subject: whitespace --- sx-interaction.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index 2b41b35..ea494eb 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -152,7 +152,7 @@ Element can be a question, answer, or comment." "Display question given by DATA, on WINDOW. When DATA is nil, display question under point. When FOCUS is non-nil (the default when called interactively), also focus the -relevant window. +relevant window. If WINDOW nil, the window is decided by `sx-question-mode-display-buffer-function'." @@ -260,13 +260,13 @@ TEXT is a string. Interactively, it is read from the minibufer." (defun sx--get-post (type site id) "Find in the database a post identified by TYPE, SITE and ID. -TYPE is `question' or `answer'. +TYPE is `question' or `answer'. SITE is a string. ID is an integer." (let ((db (cons sx-question-mode--data sx-question-list--dataset))) (setq db - (cond + (cond ((string= type "question") db) ((string= type "answer") (apply #'cl-map 'list #'identity -- cgit v1.2.3 From 60bed65f15505261dd297fcf4ad2c71a7c76dbeb Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sat, 27 Dec 2014 09:56:03 -0500 Subject: Add autoload cookie to `sx-ask' --- sx-interaction.el | 1 + 1 file changed, 1 insertion(+) (limited to 'sx-interaction.el') diff --git a/sx-interaction.el b/sx-interaction.el index c6f2639..baf8c13 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -327,6 +327,7 @@ from context at point." (sx-site-get-api-tokens) nil t nil nil default))) +;;;###autoload (defun sx-ask (site) "Start composing a question for SITE. SITE is a string, indicating where the question will be posted." -- cgit v1.2.3