diff options
-rw-r--r-- | stack-exchange.el | 30 | ||||
-rw-r--r-- | sx-favorites.el | 3 | ||||
-rw-r--r-- | sx-method.el | 20 | ||||
-rw-r--r-- | sx-question-list.el | 24 | ||||
-rw-r--r-- | sx-question-mode.el | 10 | ||||
-rw-r--r-- | sx-time.el | 6 |
6 files changed, 42 insertions, 51 deletions
diff --git a/stack-exchange.el b/stack-exchange.el deleted file mode 100644 index bca777b..0000000 --- a/stack-exchange.el +++ /dev/null @@ -1,30 +0,0 @@ -;;; stack-exchange.el --- A StackExchange Mode -*- lexical-binding: t; -*- - -;; Copyright (C) 2014 Sean Allred - -;; Author: Sean Allred <code@seanallred.com> -;; Keywords: help, hypermedia, mail, news, tools - -;; 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 <http://www.gnu.org/licenses/>. - -;;; Commentary: - -;; - -;;; Code: - -(mapc #'load (file-expand-wildcards "sx*.el")) - -(provide 'stack-exchange) -;;; stack-exchange.el ends here diff --git a/sx-favorites.el b/sx-favorites.el index aaf2734..d957167 100644 --- a/sx-favorites.el +++ b/sx-favorites.el @@ -52,7 +52,8 @@ Added as hook to initialization." (defun sx-favorites--retrieve-favorites (site) "Obtain list of starred QUESTION_IDs for SITE." (sx-method-call 'me - :submethod (format "favorites?site=%s" site) + :submethod 'favorites + :site site :filter sx-favorite-list-filter :auth t)) diff --git a/sx-method.el b/sx-method.el index 04d973d..1b20cbf 100644 --- a/sx-method.el +++ b/sx-method.el @@ -35,7 +35,7 @@ (cl-defun sx-method-call (method &key id submethod keywords - (filter 'none) + (filter '(())) auth (url-method "GET") site) @@ -75,8 +75,14 @@ Return the entire response as a complex alist." (when id (format "/%s" id)) (when submethod - (format "/%s" submethod)))) - (call 'sx-request-make)) + (format "/%s" submethod)) + ;; On GET methods site is buggy, so we + ;; need to provide it as a url argument. + (when (and site (string= url-method "GET")) + (prog1 + (format "?site=%s" site) + (setq site nil))))) + (call #'sx-request-make)) (lwarn "sx-call-method" :debug "A: %S T: %S. M: %S,%s. F: %S" (equal 'warn auth) access-token method-auth full-method filter-auth) (unless access-token @@ -96,10 +102,10 @@ Return the entire response as a complex alist." (error "This request requires authentication.")))) ;; Concatenate all parameters now that filter is ensured. (setq parameters - (cons `(site . ,site) - (cons (cons 'filter - (sx-filter-get-var filter)) - keywords))) + (cons (cons 'filter (sx-filter-get-var filter)) + keywords)) + (when site + (setq parameters (cons (cons 'site site) parameters))) (funcall call full-method parameters diff --git a/sx-question-list.el b/sx-question-list.el index 2965ede..fbed4ea 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -371,19 +371,25 @@ a new list before redisplaying." (setq sx-question-list--unread-count 0) (unless no-update (setq sx-question-list--pages-so-far 1)) - (let ((question-list - (or (and no-update sx-question-list--dataset) - (and (functionp sx-question-list--refresh-function) - (funcall sx-question-list--refresh-function)) - (and (functionp sx-question-list--next-page-function) - (funcall sx-question-list--next-page-function 1)) - sx-question-list--dataset))) + (let* ((question-list + (or (and no-update sx-question-list--dataset) + (and (functionp sx-question-list--refresh-function) + (funcall sx-question-list--refresh-function)) + (and (functionp sx-question-list--next-page-function) + (funcall sx-question-list--next-page-function 1)) + sx-question-list--dataset)) + ;; Preserve window positioning. + (window (get-buffer-window (current-buffer))) + (old-start (when window (window-start window)))) (setq sx-question-list--dataset question-list) ;; Print the result. (setq tabulated-list-entries (mapcar sx-question-list--print-function - (cl-remove-if #'sx-question--hidden-p question-list)))) - (when redisplay (tabulated-list-print 'remember))) + (cl-remove-if #'sx-question--hidden-p question-list))) + (when redisplay (tabulated-list-print 'remember)) + (when window + (set-window-start window old-start))) + (sx-message "Done.")) (defcustom sx-question-list-ago-string " ago" "String appended to descriptions of the time since something happened. diff --git a/sx-question-mode.el b/sx-question-mode.el index 19930e7..f3ef8e5 100644 --- a/sx-question-mode.el +++ b/sx-question-mode.el @@ -616,15 +616,19 @@ With non-nil prefix argument NO-UPDATE, just redisplay, don't query the api." (interactive "P") (sx-question-mode--ensure-mode) - (let ((point (point))) + (let ((point (point)) + (line (count-screen-lines + (window-start) (point)))) (sx-question-mode--erase-and-print-question (if no-update sx-question-mode--data (sx-assoc-let sx-question-mode--data (sx-question-get-question .site .question_id)))) (goto-char point) - (when (get-buffer-window (current-buffer)) - (recenter)))) + (when (equal (selected-window) + (get-buffer-window (current-buffer))) + (recenter line))) + (sx-message "Done.")) (defun sx-question-mode--ensure-mode () "Ensures we are in question mode, erroring otherwise." @@ -29,10 +29,14 @@ ;; (LIMIT NAME VALUE) ;; We use an entry if the number of seconds in question is less than ;; LIMIT, but more than the previous entry's LIMIT. + ;; For instance, if time is less than 100 sec, we write it in seconds; + ;; if it is between 100 and 6000 sec, we use minutes. + ;; VALUE is the actual number of seconds which NAME represents. '((100 "s" 1) (6000 "m" 60.0) (108000 "h" 3600.0) - (34560000 "d" 86400.0) + (3456000 "d" 86400.0) + (31622400 "mo" 2628000.0) (nil "y" 31557600.0)) "Auxiliary variable used by `sx-time-since'.") |