From b4bd8dd1b1c94a880372872560f32839807c56a0 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 23 Dec 2014 15:13:36 -0200 Subject: Implement sx-tab-meta-or-main command --- sx-tab.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sx-tab.el') diff --git a/sx-tab.el b/sx-tab.el index 6c5e21e..d2e278f 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -189,5 +189,20 @@ If SITE is nil, use `sx-default-site'." (file-name-directory load-file-name))) nil t) + +;;; Inter-modes navigation +(defun sx-tab-meta-or-main () + "Switch to the meta version of a main site, or vice-versa. +Inside a question, go to the frontpage of the site this question +belongs to." + (interactive) + (if (and (derived-mode-p 'sx-question-list-mode) + sx-question-list--site) + (sx-question-list-switch-site + (if (string-match "\\`meta\\." sx-question-list--site) + (replace-match "" :fixedcase nil sx-question-list--site) + (concat "meta." sx-question-list--site))) + (sx-tab-frontpage nil (sx--site (sx--data-here 'question))))) + (provide 'sx-tab) ;;; sx-tab.el ends here -- cgit v1.2.3 From 635c863b0c0d19db45d44ce0f25f41f0be650c92 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Tue, 23 Dec 2014 23:33:37 -0200 Subject: 3 more tabs: unanswered, unanswered my tags, featured --- sx-tab.el | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'sx-tab.el') diff --git a/sx-tab.el b/sx-tab.el index d2e278f..4b9d50b 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -189,6 +189,48 @@ If SITE is nil, use `sx-default-site'." (file-name-directory load-file-name))) nil t) + +;;; Unanswered +(sx-tab--define "Unanswered" + (lambda (page) + (sx-question-get-questions + sx-question-list--site page nil 'unanswered))) +;;;###autoload +(autoload 'sx-tab-unanswered + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + + +;;; Unanswered My-tags +(sx-tab--define "Unanswered-my-tags" + (lambda (page) + (sx-question-get-questions + sx-question-list--site page nil 'unanswered/my-tags))) +;;;###autoload +(autoload 'sx-tab-unanswered + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + + +;;; Featured +(sx-tab--define "Featured" + (lambda (page) + (sx-question-get-questions + sx-question-list--site page nil 'featured))) +;;;###autoload +(autoload 'sx-tab-featured + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + ;;; Inter-modes navigation (defun sx-tab-meta-or-main () -- cgit v1.2.3 From c37022ffbc52b900d81eee05f3c2c3d5fe6fee01 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 27 Dec 2014 23:06:00 -0200 Subject: Initial implementation of sx-completing-read --- sx-interaction.el | 8 ++++---- sx-question-list.el | 3 +-- sx-tab.el | 8 ++++---- sx.el | 5 +++++ 4 files changed, 14 insertions(+), 10 deletions(-) (limited to 'sx-tab.el') diff --git a/sx-interaction.el b/sx-interaction.el index 372a5b1..9ced1ab 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -340,10 +340,10 @@ from context at point." (let ((default (or sx-question-list--site (sx-assoc-let sx-question-mode--data .site) sx-default-site))) - (funcall (if ido-mode #'ido-completing-read #'completing-read) - (format "Site (%s): " default) - (sx-site-get-api-tokens) nil t nil nil - default))) + (sx-completing-read + (format "Site (%s): " default) + (sx-site-get-api-tokens) nil t nil nil + default))) ;;;###autoload (defun sx-ask (site) diff --git a/sx-question-list.el b/sx-question-list.el index 4bd6478..d84d1ea 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -559,12 +559,11 @@ This does not update `sx-question-mode--window'." (defun sx-question-list-switch-site (site) "Switch the current site to SITE and display its questions. -Use `ido-completing-read' if variable `ido-mode' is active. Retrieve completions from `sx-site-get-api-tokens'. Sets `sx-question-list--site' and then call `sx-question-list-refresh' with `redisplay'." (interactive - (list (funcall (if ido-mode #'ido-completing-read #'completing-read) + (list (sx-completing-read "Switch to site: " (sx-site-get-api-tokens) (lambda (site) (not (equal site sx-question-list--site))) t))) diff --git a/sx-tab.el b/sx-tab.el index 6c5e21e..32a7784 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -34,10 +34,10 @@ (defun sx-tab-switch (tab) "Switch to another question-list tab." (interactive - (list (funcall (if ido-mode #'ido-completing-read #'completing-read) - "Switch to tab: " sx-tab--list - (lambda (tab) (not (equal tab sx-question-list--current-tab))) - t))) + (list (sx-completing-read + "Switch to tab: " sx-tab--list + (lambda (tab) (not (equal tab sx-question-list--current-tab))) + t))) (funcall (intern (format "sx-tab-%s" (downcase tab))))) diff --git a/sx.el b/sx.el index a63c155..c2d1164 100644 --- a/sx.el +++ b/sx.el @@ -183,6 +183,11 @@ See `sx-question-get-questions' and `sx-question-get-question'.") ;;; Utility Functions +(defun sx-completing-read (&rest args) + "Like `completing-read', but possibly use ido. +All ARGS are passed to `completing-read' or `ido-completing-read'." + (apply (if ido-mode #'ido-completing-read #'completing-read) + args)) (defmacro sx-sorted-insert-skip-first (newelt list &optional predicate) "Inserted NEWELT into LIST sorted by PREDICATE. -- cgit v1.2.3 From e1a57f49379fa9345b662a721941edd7371db60b Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 4 Jan 2015 16:20:00 -0200 Subject: Implement listing starred questions. Fix #14 --- sx-switchto.el | 1 + sx-tab.el | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'sx-tab.el') diff --git a/sx-switchto.el b/sx-switchto.el index 1a2c3a0..76804e4 100644 --- a/sx-switchto.el +++ b/sx-switchto.el @@ -47,6 +47,7 @@ ("U" sx-tab-unanswered-my-tags) ("v" sx-tab-topvoted) ("w" sx-tab-week) + ("*" sx-tab-starred) )) diff --git a/sx-tab.el b/sx-tab.el index 6a2552f..f97119a 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -231,6 +231,24 @@ If SITE is nil, use `sx-default-site'." (file-name-directory load-file-name))) nil t) + +;;; Starred +(sx-tab--define "Starred" + (lambda (page) + (sx-method-call 'me + :page page + :site sx-question-list--site + :auth t + :submethod 'favorites + :filter sx-browse-filter))) +;;;###autoload +(autoload 'sx-tab-featured + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + ;;; Inter-modes navigation (defun sx-tab-meta-or-main () -- cgit v1.2.3