From fafda82d046c3735a5e6d5e188622be40fe707d0 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 29 Nov 2014 00:19:43 +0000 Subject: Autoload sx-tab-frontpage --- sx-tab.el | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sx-tab.el') diff --git a/sx-tab.el b/sx-tab.el index 154a90f..5b3f3c4 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -97,6 +97,9 @@ If SITE is nil, use `sx-tab-default-site'." (lambda (page) (sx-question-get-questions sx-question-list--site page))) +;;;###autoload +(autoload 'sx-tab-frontpage (expand-file-name load-file-name) + nil t) (provide 'sx-tab) ;;; sx-tab.el ends here -- cgit v1.2.3 From 73e37ca539fe7b620f066f4dd56ef97f0e4b91c7 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 29 Nov 2014 01:08:30 +0000 Subject: Autoload sx-tab-frontpage correctly --- sx-tab.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sx-tab.el') diff --git a/sx-tab.el b/sx-tab.el index 5b3f3c4..7ccbf18 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -98,7 +98,11 @@ If SITE is nil, use `sx-tab-default-site'." (sx-question-get-questions sx-question-list--site page))) ;;;###autoload -(autoload 'sx-tab-frontpage (expand-file-name load-file-name) +(autoload 'sx-tab-frontpage + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) nil t) (provide 'sx-tab) -- cgit v1.2.3 From 3e4386a0ec6383eb92ae5535db165c82ed7092b2 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 1 Dec 2014 03:07:32 +0000 Subject: Define 5 new tabs, as per http://api.stackexchange.com/docs/questions --- sx-tab.el | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) (limited to 'sx-tab.el') diff --git a/sx-tab.el b/sx-tab.el index 7ccbf18..1152528 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -96,7 +96,7 @@ If SITE is nil, use `sx-tab-default-site'." (sx-tab--define "FrontPage" (lambda (page) (sx-question-get-questions - sx-question-list--site page))) + sx-question-list--site page '((sort . activity))))) ;;;###autoload (autoload 'sx-tab-frontpage (expand-file-name @@ -105,5 +105,79 @@ If SITE is nil, use `sx-tab-default-site'." (file-name-directory load-file-name))) nil t) + +;;; Newest +(sx-tab--define "Newest" + (lambda (page) + (sx-question-get-questions + sx-question-list--site page '((sort . creation))))) +;;;###autoload +(autoload 'sx-tab-newest + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + + + +;;; TopVoted +(sx-tab--define "TopVoted" + (lambda (page) + (sx-question-get-questions + sx-question-list--site page '((sort . votes))))) +;;;###autoload +(autoload 'sx-tab-topvoted + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + + + +;;; Hot +(sx-tab--define "Hot" + (lambda (page) + (sx-question-get-questions + sx-question-list--site page '((sort . hot))))) +;;;###autoload +(autoload 'sx-tab-hot + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + + + +;;; Week +(sx-tab--define "Week" + (lambda (page) + (sx-question-get-questions + sx-question-list--site page '((sort . week))))) +;;;###autoload +(autoload 'sx-tab-week + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + + + +;;; Month +(sx-tab--define "Month" + (lambda (page) + (sx-question-get-questions + sx-question-list--site page '((sort . month))))) +;;;###autoload +(autoload 'sx-tab-month + (expand-file-name + "sx-tab" + (when load-file-name + (file-name-directory load-file-name))) + nil t) + (provide 'sx-tab) ;;; sx-tab.el ends here -- cgit v1.2.3 From 10597c39adbcf775841f908452082ed344110ce9 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 1 Dec 2014 03:08:52 +0000 Subject: Define command for changing tab --- sx-tab.el | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'sx-tab.el') diff --git a/sx-tab.el b/sx-tab.el index 1152528..b497ce0 100644 --- a/sx-tab.el +++ b/sx-tab.el @@ -32,6 +32,18 @@ :type 'string :group 'sx) +(defvar sx-tab--list nil + "List of the names of all defined tabs.") + +(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))) + (funcall (intern (format "sx-tab-%s" (downcase tab))))) + (defmacro sx-tab--define (tab pager &optional printer refresher &rest body) "Define a StackExchange tab called TAB. @@ -55,7 +67,7 @@ variables, but before refreshing the display." `(progn (defvar ,buffer-variable nil ,(format "Buffer where the %s questions are displayed." - tab)) + tab)) (defun ,(intern (concat "sx-tab-" name)) (&optional no-update site) @@ -63,7 +75,7 @@ variables, but before refreshing the display." NO-UPDATE (the prefix arg) is passed to `sx-question-list-refresh'. If SITE is nil, use `sx-tab-default-site'." - tab) + tab) (interactive (list current-prefix-arg (funcall (if ido-mode #'ido-completing-read #'completing-read) @@ -89,7 +101,10 @@ If SITE is nil, use `sx-tab-default-site'." (setq sx-question-list--current-tab ,tab) ,@body (sx-question-list-refresh 'redisplay no-update)) - (switch-to-buffer ,buffer-variable))))) + (switch-to-buffer ,buffer-variable)) + ;; Add this tab to the list of existing tabs. So we can prompt + ;; the user with completion and stuff. + (add-to-list 'sx-tab--list ,tab)))) ;;; FrontPage -- cgit v1.2.3