From 0b8fd6291719c4913f64a9e322abcb025fbf5e40 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 7 Nov 2014 17:37:29 -0500 Subject: Rename sx-network to sx-site According to the documentation, it's the appropriate terminology. --- sx-network.el | 36 ------------------------------------ sx-site.el | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 36 deletions(-) delete mode 100644 sx-network.el create mode 100644 sx-site.el diff --git a/sx-network.el b/sx-network.el deleted file mode 100644 index dcd2349..0000000 --- a/sx-network.el +++ /dev/null @@ -1,36 +0,0 @@ -;;; sx-network.el --- browsing networks -*- lexical-binding: t; -*- - -;; Copyright (C) 2014 Sean Allred - -;; Author: Sean Allred - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; - -;;; Code: - -(require 'sx-request) - -(defun sx-network-get-networks () - (sx-request-make "sites")) - -(provide 'sx-network) -;;; stack-network.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/sx-site.el b/sx-site.el new file mode 100644 index 0000000..8d78e8a --- /dev/null +++ b/sx-site.el @@ -0,0 +1,36 @@ +;;; sx-site.el --- browsing sites -*- lexical-binding: t; -*- + +;; Copyright (C) 2014 Sean Allred + +;; Author: Sean Allred + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; + +;;; Code: + +(require 'sx-request) + +(defun sx-site-get-sites () + (sx-request-make "sites")) + +(provide 'sx-site) +;;; stack-site.el ends here + +;; Local Variables: +;; indent-tabs-mode: nil +;; End: -- cgit v1.2.3 From 60a07cd274e80d9dfbb37f4d87a51e7b1d8af536 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Mon, 10 Nov 2014 23:10:23 -0500 Subject: Use narrow filter for site list --- sx-site.el | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sx-site.el b/sx-site.el index 8d78e8a..3c326e4 100644 --- a/sx-site.el +++ b/sx-site.el @@ -23,10 +23,26 @@ ;;; Code: -(require 'sx-request) +(require 'sx-method) + +(defvar sx-site-browse-filter + '((.backoff + .error_id + .error_message + .error_name + .has_more + .items + .quota_max + .quota_remaining + site.site_type + site.name + site.site_url + site.api_site_parameter) + nil + none)) (defun sx-site-get-sites () - (sx-request-make "sites")) + (sx-method-call "sites" nil sx-site-browse-filter)) (provide 'sx-site) ;;; stack-site.el ends here -- cgit v1.2.3 From f6699988fd521703c1d44489e3d89c6f71d418df Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Tue, 11 Nov 2014 12:12:30 -0500 Subject: Move question sorting function to sx.el It is not specific to questions -- it is generally applicable to any alist. --- sx-question-list.el | 2 +- sx-question.el | 6 ------ sx.el | 7 +++++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sx-question-list.el b/sx-question-list.el index caf24b1..a164706 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -120,7 +120,7 @@ Letters do not insert themselves; instead, they are commands. (defun sx-question-list--date-more-recent-p (x y) "Non-nil if tabulated-entry X is newer than Y." - (sx-question--< + (sx--< sx-question-list-date-sort-method (car x) (car y) #'>)) diff --git a/sx-question.el b/sx-question.el index 20a71cc..601875f 100644 --- a/sx-question.el +++ b/sx-question.el @@ -56,12 +56,6 @@ "Mark QUESTION as being read, until it is updated again." nil) -(defun sx-question--< (property x y &optional pred) - "Non-nil if PROPERTY attribute of question X is less than that of Y. -With optional argument predicate, use it instead of `<'." - (funcall (or pred #'<) - (cdr (assoc property x)) - (cdr (assoc property y)))) ;;; Displaying a question (defvar sx-question--window nil diff --git a/sx.el b/sx.el index 6165714..0a1b046 100644 --- a/sx.el +++ b/sx.el @@ -160,6 +160,13 @@ Run after `sx-init--internal-hook'.") This is used internally to set initial values for variables such as filters.") +(defun sx--< (property x y &optional pred) + "Non-nil if PROPERTY attribute of question X is less than that of Y. +With optional argument predicate, use it instead of `<'." + (funcall (or pred #'<) + (cdr (assoc property x)) + (cdr (assoc property y)))) + (defmacro sx-init-variable (variable value &optional setter) "Set VARIABLE to VALUE using SETTER. SETTER should be a function of two arguments. If SETTER is nil, -- cgit v1.2.3 From 90492e76951164e3e1bc30e41e6c112fb9b00564 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Tue, 11 Nov 2014 12:43:41 -0500 Subject: Don't need to hexify filter --- sx-filter.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sx-filter.el b/sx-filter.el index aa815a2..c053070 100644 --- a/sx-filter.el +++ b/sx-filter.el @@ -54,7 +54,7 @@ or string." "filter/create" keyword-arguments))) (sx-assoc-let (elt response 0) - (url-hexify-string filter))))) + filter)))) ;;; Storage and Retrieval -- cgit v1.2.3 From 768dc0e2a4d924bdb3d4908233e27de236861005 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Tue, 11 Nov 2014 12:44:29 -0500 Subject: Include more fields in the sites filter --- sx-site.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sx-site.el b/sx-site.el index 3c326e4..fcdc383 100644 --- a/sx-site.el +++ b/sx-site.el @@ -37,7 +37,10 @@ site.site_type site.name site.site_url - site.api_site_parameter) + site.api_site_parameter + site.related_sites + related_site.api_site_parameter + related_site.relation) nil none)) -- cgit v1.2.3 From 9f679fdadce15381efba781e8561d4cdc172319c Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Tue, 11 Nov 2014 12:44:42 -0500 Subject: Add favorite sites customization --- sx-site.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sx-site.el b/sx-site.el index fcdc383..840bbca 100644 --- a/sx-site.el +++ b/sx-site.el @@ -47,6 +47,11 @@ (defun sx-site-get-sites () (sx-method-call "sites" nil sx-site-browse-filter)) +(defcustom sx-site-favorites + nil + "Favorite sites." + :group 'sx-site) + (provide 'sx-site) ;;; stack-site.el ends here -- cgit v1.2.3 From 0cb05d17c806fb268343dcf932e355dba13cfb3c Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Tue, 11 Nov 2014 12:45:06 -0500 Subject: Convenience argument for `cache-get' Allows for setting the cache if it does not exist. --- sx-cache.el | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sx-cache.el b/sx-cache.el index 098c292..e3b356b 100644 --- a/sx-cache.el +++ b/sx-cache.el @@ -38,18 +38,21 @@ (concat (symbol-name filename) ".el") sx-cache-directory)) -(defun sx-cache-get (cache) +(defun sx-cache-get (cache &optional form) "Return the data within CACHE. +If CACHE does not exist, evaluate FORM and set it to its return. + As with `sx-cache-set', CACHE is a file name within the context of `sx-cache-directory'." (unless (file-exists-p sx-cache-directory) (mkdir sx-cache-directory)) (let ((file (sx-cache-get-file-name cache))) - (when (file-exists-p file) - (with-temp-buffer - (insert-file-contents (sx-cache-get-file-name cache)) - (read (buffer-string)))))) + (if (file-exists-p file) + (with-temp-buffer + (insert-file-contents (sx-cache-get-file-name cache)) + (read (buffer-string))) + (sx-cache-set cache (eval form))))) (defun sx-cache-set (cache data) "Set the content of CACHE to DATA. -- cgit v1.2.3 From 403c021d92bb036be5d95735bc1403056db3780b Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Tue, 11 Nov 2014 12:46:13 -0500 Subject: Use smart caching --- sx-site.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sx-site.el b/sx-site.el index 840bbca..c8de938 100644 --- a/sx-site.el +++ b/sx-site.el @@ -24,6 +24,7 @@ ;;; Code: (require 'sx-method) +(require 'sx-cache) (defvar sx-site-browse-filter '((.backoff @@ -44,8 +45,14 @@ nil none)) -(defun sx-site-get-sites () - (sx-method-call "sites" nil sx-site-browse-filter)) +(defun sx-site-get-sites ()) + +(defun sx-site--get-site-list () + (sx-cache-get + 'site-list + '(sx-method-call + "sites" '((pagesize . 999)) + sx-site-browse-filter))) (defcustom sx-site-favorites nil -- cgit v1.2.3 From 7881572c09281785c1d0303d13305b583b3803cd Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 14 Nov 2014 17:44:55 -0500 Subject: Fix comment --- sx-site.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sx-site.el b/sx-site.el index 2243fa8..6bef91f 100644 --- a/sx-site.el +++ b/sx-site.el @@ -64,7 +64,7 @@ (sx-site--get-site-list))) (provide 'sx-site) -;;; stack-site.el ends here +;;; sx-site.el ends here ;; Local Variables: ;; indent-tabs-mode: nil -- cgit v1.2.3