aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2014-12-01 03:08:52 +0000
committerArtur Malabarba <bruce.connor.am@gmail.com>2014-12-01 03:08:52 +0000
commit10597c39adbcf775841f908452082ed344110ce9 (patch)
treef5c5bfac2e9f90eb1c870b88ce8d58b38bcca1b9
parent3e4386a0ec6383eb92ae5535db165c82ed7092b2 (diff)
Define command for changing tab
-rw-r--r--sx-tab.el21
1 files changed, 18 insertions, 3 deletions
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