diff options
-rw-r--r-- | sx-compose.el | 4 | ||||
-rw-r--r-- | sx-filter.el | 6 | ||||
-rw-r--r-- | sx-interaction.el | 6 | ||||
-rw-r--r-- | sx-method.el | 6 | ||||
-rw-r--r-- | sx-question-list.el | 38 | ||||
-rw-r--r-- | sx-request.el | 4 |
6 files changed, 49 insertions, 15 deletions
diff --git a/sx-compose.el b/sx-compose.el index d27d2f3..8a8637b 100644 --- a/sx-compose.el +++ b/sx-compose.el @@ -188,7 +188,7 @@ respectively added locally to `sx-compose-before-send-hook' and (.comment_id 'comments) (t 'answers)) :auth 'warn - :url-method "POST" + :url-method 'post :filter sx-browse-filter :site site :keywords (sx-compose--generate-keywords is-question) @@ -196,7 +196,7 @@ respectively added locally to `sx-compose-before-send-hook' and :submethod 'edit))) (lambda () (sx-method-call 'questions :auth 'warn - :url-method "POST" + :url-method 'post :filter sx-browse-filter :site site :keywords (sx-compose--generate-keywords is-question) diff --git a/sx-filter.el b/sx-filter.el index d484f43..15bd8a1 100644 --- a/sx-filter.el +++ b/sx-filter.el @@ -106,6 +106,7 @@ return the compiled filter." (defvar sx-browse-filter (sx-filter-from-nil ((question body_markdown + bounty_amount comments answers last_editor @@ -116,7 +117,10 @@ return the compiled filter." downvoted question_id share_link) - (user display_name) + (user display_name + reputation) + (shallow_user display_name + reputation) (comment owner body_markdown body diff --git a/sx-interaction.el b/sx-interaction.el index b85a8db..dc4398e 100644 --- a/sx-interaction.el +++ b/sx-interaction.el @@ -202,7 +202,7 @@ With the UNDO prefix argument, unfavorite the question instead." :submethod (if undo 'favorite/undo 'favorite) :auth 'warn :site .site_par - :url-method "POST" + :url-method 'post :filter sx-browse-filter))) (defalias 'sx-star #'sx-favorite) @@ -243,7 +243,7 @@ changes." :id (or .comment_id .answer_id .question_id) :submethod (concat type (unless status "/undo")) :auth 'warn - :url-method "POST" + :url-method 'post :filter sx-browse-filter :site .site_par)))) ;; The api returns the new DATA. @@ -284,7 +284,7 @@ TEXT is a string. Interactively, it is read from the minibufer." :id (or .post_id .answer_id .question_id) :submethod "comments/add" :auth 'warn - :url-method "POST" + :url-method 'post :filter sx-browse-filter :site .site_par :keywords `((body . ,text))))) diff --git a/sx-method.el b/sx-method.el index e68a4ea..bff6d30 100644 --- a/sx-method.el +++ b/sx-method.el @@ -39,7 +39,7 @@ (pagesize 100) (filter '(())) auth - (url-method "GET") + (url-method 'get) get-all (process-function #'sx-request-response-get-items) @@ -53,7 +53,7 @@ user. :FILTER is the set of filters to control the returned information :AUTH defines how to act if the method or filters require authentication. -:URL-METHOD is either \"POST\" or \"GET\" +:URL-METHOD is either `post' or `get' :SITE is the api parameter specifying the site. :GET-ALL is nil or non-nil :PROCESS-FUNCTION is a response-processing function @@ -102,7 +102,7 @@ Return the entire response as a complex alist." (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")) + (when (and site (eq url-method 'get)) (prog1 (format "?site=%s" site) (setq site nil))))) diff --git a/sx-question-list.el b/sx-question-list.el index a8b9fb3..3354052 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -104,6 +104,21 @@ "" :group 'sx-question-list-faces) +(defface sx-question-list-bounty + '((t :inherit font-lock-warning-face)) + "" + :group 'sx-question-list-faces) + +(defface sx-question-list-reputation + '((t :inherit sx-question-list-date)) + "" + :group 'sx-question-list-faces) + +(defface sx-question-list-user + '((t :inherit font-lock-builtin-face)) + "" + :group 'sx-question-list-faces) + ;;; Backend variables (defvar sx-question-list--print-function #'sx-question-list--print-info @@ -141,20 +156,35 @@ Also see `sx-question-list-refresh'." 'sx-question-list-answers-accepted 'sx-question-list-answers)) (concat + ;; First line (propertize .title 'face (if (sx-question--read-p question-data) 'sx-question-list-read-question 'sx-question-list-unread-question)) (propertize " " 'display "\n ") + ;; Second line (propertize favorite 'face 'sx-question-list-favorite) - " " - (propertize (concat (sx-time-since .last_activity_date) - sx-question-list-ago-string) + (if (and (numberp .bounty_amount) (> .bounty_amount 0)) + (propertize (format "%4d" .bounty_amount) + 'face 'sx-question-list-bounty) + " ") + " " + (propertize (format "%3s%s" + (sx-time-since .last_activity_date) + sx-question-list-ago-string) 'face 'sx-question-list-date) " " - (propertize (mapconcat #'sx-question--tag-format .tags " ") + ;; @TODO: Make this width customizable. (Or maybe just make + ;; the whole thing customizable) + (propertize (format "%-40s" (mapconcat #'sx-question--tag-format .tags " ")) 'face 'sx-question-list-tags) + " " + (let-alist .owner + (format "%15s %5s" + (propertize .display_name 'face 'sx-question-list-user) + (propertize (number-to-string .reputation) + 'face 'sx-question-list-reputation))) (propertize " " 'display "\n"))))))) (defvar sx-question-list--pages-so-far 0 diff --git a/sx-request.el b/sx-request.el index b2aee5d..bab53ec 100644 --- a/sx-request.el +++ b/sx-request.el @@ -134,7 +134,7 @@ access the response wrapper." (defun sx-request-make (method &optional args request-method process-function) "Make a request to the API, executing METHOD with ARGS. You should almost certainly be using `sx-method-call' instead of -this function. REQUEST-METHOD is one of `GET' (default) or `POST'. +this function. REQUEST-METHOD is one of `get' (default) or `post'. Returns the entire response as processed by PROCESS-FUNCTION. This defaults to `sx-request-response-get-items'. @@ -158,7 +158,7 @@ the main content of the response is returned." (url-inhibit-uncompression t) (url-request-data (sx-request--build-keyword-arguments args nil)) (request-url (concat sx-request-api-root method)) - (url-request-method request-method) + (url-request-method (and request-method (symbol-name request-method))) (url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded"))) (response-buffer (url-retrieve-synchronously request-url))) |