aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sx-button.el5
-rw-r--r--sx-compose.el4
-rw-r--r--sx-interaction.el4
-rw-r--r--sx-method.el2
-rw-r--r--sx-question-list.el9
-rw-r--r--sx-question.el3
-rw-r--r--sx-request.el2
-rw-r--r--sx-time.el2
-rw-r--r--sx.el5
9 files changed, 20 insertions, 16 deletions
diff --git a/sx-button.el b/sx-button.el
index dbadc2e..283fe0d 100644
--- a/sx-button.el
+++ b/sx-button.el
@@ -51,7 +51,8 @@
'((((type x w32 ns) (class color)) ; Like default mode line
:box (:line-width 2 :style released-button)
:background "lightgrey" :foreground "black"))
- "Face used on buttons such as \"Write an Answer\".")
+ "Face used on buttons such as \"Write an Answer\"."
+ :group 'sx)
;;; Command definitions
@@ -96,7 +97,7 @@ code-block."
(interactive)
(browse-url
(or (get-text-property (or pos (point)) 'sx-button-url)
- (user-error "No url under point: %s" (or pos (point))))))
+ (sx-user-error "No url under point: %s" (or pos (point))))))
;;; Help-echo definitions
diff --git a/sx-compose.el b/sx-compose.el
index d8f3b23..96f47f3 100644
--- a/sx-compose.el
+++ b/sx-compose.el
@@ -225,8 +225,8 @@ other keywords are read from the header "
(unless (search-forward-regexp "^Tags : *\\([^[:space:]].*\\) *$"
header-end 'noerror)
(error "No Tags header found"))
- (push (cons 'tags (split-string (match-string 1) "[[:space:],;]"
- 'omit-nulls "[[:space:]]"))
+ (push (cons 'tags (split-string (match-string 1)
+ "[[:space:],;]" 'omit-nulls))
keywords)
;; And erase the header so it doesn't get sent.
(delete-region
diff --git a/sx-interaction.el b/sx-interaction.el
index 38520a7..7d32094 100644
--- a/sx-interaction.el
+++ b/sx-interaction.el
@@ -85,7 +85,7 @@ If it's not a question, or if it is read, return DATA."
;; If we found a question, we may need to check if it's read.
(if (and (assoc 'title data)
(null (sx-question--read-p data)))
- (user-error "Question not yet read. View it before acting on it")
+ (sx-user-error "Question not yet read. View it before acting on it")
data))
(defun sx--maybe-update-display (&optional buffer)
@@ -286,7 +286,7 @@ from context at point."
;; If we ever make an "Edit" button, first arg is a marker.
(when (markerp data) (setq data (sx--data-here)))
(sx-assoc-let data
- (when .comment_id (user-error "Editing comments is not supported yet"))
+ (when .comment_id (sx-user-error "Editing comments is not supported yet"))
(let ((buffer (current-buffer)))
(pop-to-buffer
(sx-compose-create
diff --git a/sx-method.el b/sx-method.el
index 4575b0f..1078014 100644
--- a/sx-method.el
+++ b/sx-method.el
@@ -90,7 +90,7 @@ Return the entire response as a complex alist."
(cond
;; 1. Need auth and warn user (interactive use)
((and method-auth (equal 'warn auth))
- (user-error
+ (sx-user-error
"This request requires authentication. Please run `M-x sx-authenticate' and try again."))
;; 2. Need auth to populate UI, cannot provide subset
((and method-auth auth)
diff --git a/sx-question-list.el b/sx-question-list.el
index f23310c..94b5be4 100644
--- a/sx-question-list.el
+++ b/sx-question-list.el
@@ -331,7 +331,7 @@ Non-interactively, DATA is a question alist."
(interactive
(list (if (derived-mode-p 'sx-question-list-mode)
(tabulated-list-get-id)
- (user-error "Not in `sx-question-list-mode'"))))
+ (sx-user-error "Not in `sx-question-list-mode'"))))
(sx-question--mark-hidden data)
(when (called-interactively-p 'any)
(sx-question-list-refresh 'redisplay 'noupdate)))
@@ -342,7 +342,7 @@ Non-interactively, DATA is a question alist."
(interactive
(list (if (derived-mode-p 'sx-question-list-mode)
(tabulated-list-get-id)
- (user-error "Not in `sx-question-list-mode'"))))
+ (sx-user-error "Not in `sx-question-list-mode'"))))
(sx-question--mark-read data)
(sx-question-list-next 1)
(when (called-interactively-p 'any)
@@ -447,9 +447,8 @@ Displayed in `sx-question-mode--window', replacing any question
that may currently be there."
(interactive "p")
(sx-question-list-next n)
- (sx-display-question
- (tabulated-list-get-id)
- nil
+ (sx-question-mode--display
+ (tabulated-list-get-id)
(sx-question-list--create-question-window)))
(defun sx-question-list--create-question-window ()
diff --git a/sx-question.el b/sx-question.el
index 0f6d17f..9fb31fc 100644
--- a/sx-question.el
+++ b/sx-question.el
@@ -142,8 +142,7 @@ If no cache exists for it, initialize one with SITE."
(defun sx-question--mark-hidden (question)
"Mark QUESTION as being hidden."
(sx-assoc-let question
- (let ((site-cell (assoc .site sx-question--user-hidden-list))
- cell)
+ (let ((site-cell (assoc .site sx-question--user-hidden-list)))
;; If question already hidden, do nothing.
(unless (memq .question_id site-cell)
;; First question from this site.
diff --git a/sx-request.el b/sx-request.el
index a17a982..2d894f0 100644
--- a/sx-request.el
+++ b/sx-request.el
@@ -156,7 +156,7 @@ the main content of the response is returned."
sx-request-remaining-api-requests))
(sx-encoding-clean-content-deep .items)))))))
-(defun sx-request-fallback (method &optional args request-method)
+(defun sx-request-fallback (_method &optional _args _request-method)
"Fallback method when authentication is not available.
This is for UI generation when the associated API call would
require authentication.
diff --git a/sx-time.el b/sx-time.el
index e65bb50..3de124d 100644
--- a/sx-time.el
+++ b/sx-time.el
@@ -42,7 +42,7 @@
(defun sx-time-since (time)
"Convert the time interval since TIME (in seconds) to a short string."
- (let ((delay (- (time-to-seconds) time)))
+ (let ((delay (- (float-time) time)))
(concat
(if (> 0 delay) "-" "")
(if (= 0 delay) "0s"
diff --git a/sx.el b/sx.el
index 096e20b..c8d4e5b 100644
--- a/sx.el
+++ b/sx.el
@@ -104,6 +104,11 @@ is intentionally skipped."
(setq tail (cdr tail)))
(setcdr tail (cons x (cdr tail)))))
+(defun sx-user-error (format-string &rest args)
+ "Like `user-error', but prepend FORMAT-STRING with \"[sx]\".
+See `format'."
+ (signal 'user-error (list (apply #'format (concat "[sx] " format) args))))
+
(defun sx-message (format-string &rest args)
"Display FORMAT-STRING as a message with ARGS.
See `format'."