aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sx-favorites.el3
-rw-r--r--sx-method.el18
-rw-r--r--sx-question-mode.el27
3 files changed, 38 insertions, 10 deletions
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 4bd98a5..1b20cbf 100644
--- a/sx-method.el
+++ b/sx-method.el
@@ -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-mode.el b/sx-question-mode.el
index a58bc43..db3bb95 100644
--- a/sx-question-mode.el
+++ b/sx-question-mode.el
@@ -392,12 +392,34 @@ where `value' is given `face' as its face.
(goto-char (point-min))
(while (null (eobp))
;; Don't fill pre blocks.
- (unless (sx-question-mode--move-over-pre)
+ (unless (sx-question-mode--dont-fill-here)
(skip-chars-forward "\r\n[:blank:]")
(fill-paragraph)
(forward-paragraph)))
(buffer-string)))
+(defvar sx-question-mode--reference-regexp
+ (rx line-start (0+ blank) "[%s]:" (0+ blank)
+ (group-n 1 (1+ (not blank))))
+ "Regexp used to find the url of labeled links.
+E.g.:
+ [1]: https://...")
+
+(defun sx-question-mode--dont-fill-here ()
+ "If text shouldn't be filled here, return t and skip over it."
+ (or (sx-question-mode--move-over-pre)
+ ;; Skip headers and references
+ (let ((pos (point)))
+ (skip-chars-forward "\r\n[:blank:]")
+ (goto-char (line-beginning-position))
+ (if (or (looking-at-p (format sx-question-mode--reference-regexp ".+"))
+ (looking-at-p "^#"))
+ ;; Returns non-nil
+ (forward-paragraph)
+ ;; Go back and return nil
+ (goto-char pos)
+ nil))))
+
(defvar sx-question-mode--link-regexp
;; Done at compile time.
(rx "[" (group-n 1 (1+ (not (any "]")))) "]"
@@ -459,8 +481,7 @@ If ID is nil, use FALLBACK-ID instead."
(save-match-data
(goto-char (point-min))
(when (search-forward-regexp
- (format (rx line-start (0+ blank) "[%s]:" (0+ blank)
- (group-n 1 (1+ (not blank))))
+ (format sx-question-mode--reference-regexp
(or id fallback-id))
nil t)
(match-string-no-properties 1)))))