From 6987b0424a209227956d2be8aaa84c1303fd25fd Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 15 Dec 2014 18:16:03 -0200 Subject: time-to-seconds is obsolete. --- sx-time.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" -- cgit v1.2.3 From e33d4bca3d610a77ef33f3c5dcaab7f7b4119900 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 15 Dec 2014 18:18:02 -0200 Subject: Unused variable --- sx-question.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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. -- cgit v1.2.3 From ceaee4e85d44caad2db8adacdff2e2772bf254c0 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 15 Dec 2014 18:18:08 -0200 Subject: _ indicates a variable is ignored. --- sx-request.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. -- cgit v1.2.3 From 6956c17e1e7ef2899026ad365a0acdd4ce63cb80 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 15 Dec 2014 18:27:33 -0200 Subject: user-error is "not known to be defined" in emacs 24.2 --- sx-button.el | 2 +- sx-interaction.el | 4 ++-- sx-method.el | 2 +- sx-question-list.el | 4 ++-- sx.el | 5 +++++ 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sx-button.el b/sx-button.el index dbadc2e..1727a3d 100644 --- a/sx-button.el +++ b/sx-button.el @@ -96,7 +96,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-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..e94c689 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) 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'." -- cgit v1.2.3 From 8bccdce22f50dad70232a4e902e5770576e8e830 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 15 Dec 2014 18:37:09 -0200 Subject: sx-display-question is not known to be defined. It was the wrong function to use anyway. --- sx-question-list.el | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sx-question-list.el b/sx-question-list.el index e94c689..94b5be4 100644 --- a/sx-question-list.el +++ b/sx-question-list.el @@ -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 () -- cgit v1.2.3 From aebe7265612230aafa9ce41ebb36436f1e2c9406 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 15 Dec 2014 18:38:32 -0200 Subject: split-string used to take only 3 args --- sx-compose.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- cgit v1.2.3 From 0a2f984d0771b9a921696af1fe3bad10cdbb7b54 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 15 Dec 2014 18:39:38 -0200 Subject: `sx-custom-button' fails to specify containing group --- sx-button.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sx-button.el b/sx-button.el index 1727a3d..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 -- cgit v1.2.3