From d06afce72182573c7ec1834c866fc39213c151cc Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 6 Dec 2014 18:04:56 +0000 Subject: Improve some header comments. --- sx-method.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sx-method.el') diff --git a/sx-method.el b/sx-method.el index 83455b8..5646772 100644 --- a/sx-method.el +++ b/sx-method.el @@ -1,4 +1,4 @@ -;;; sx-method.el --- method calls +;;; sx-method.el --- Main interface for API method calls. -*- lexical-binding: t; -*- ;; Copyright (C) 2014 Sean Allred -- cgit v1.2.3 From 79c03c20d14ddfe546c9f612bd9c8b1b1cb00b2c Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Fri, 12 Dec 2014 15:12:54 +0000 Subject: Autoload sx-authenticate This also removes the sx-authenticate alias and renames sx-auth-authenticate to sx-authenticate. I did this because I felt it wasn't helpful to have both. Whenever I hit `M-x sx-au ` the only completions offered were two identical, but differently named, commands. That's useless at best, confusing at worst. --- sx-auth.el | 5 ++--- sx-method.el | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'sx-method.el') diff --git a/sx-auth.el b/sx-auth.el index b6c0411..fca5392 100644 --- a/sx-auth.el +++ b/sx-auth.el @@ -80,7 +80,8 @@ will be (METHOD . t)") Keywords are of form (OBJECT TYPES) where TYPES is (FILTER FILTER FILTER).") -(defun sx-auth-authenticate () +;;;###autoload +(defun sx-authenticate () "Authenticate this application. Authentication is required to read your personal data (such as notifications) and to write with the API (asking and answering @@ -126,8 +127,6 @@ parsed and displayed prominently on the page)." (error "You must enter this code to use this client fully")) (sx-cache-set 'auth `((access_token . ,sx-auth-access-token))))) -(defalias 'sx-authenticate #'sx-auth-authenticate) - (defun sx-auth--method-p (method &optional submethod) "Check if METHOD is one that may require authentication. If it has `auth-required' SUBMETHODs, or no submethod, return t." diff --git a/sx-method.el b/sx-method.el index 5646772..4575b0f 100644 --- a/sx-method.el +++ b/sx-method.el @@ -91,7 +91,7 @@ Return the entire response as a complex alist." ;; 1. Need auth and warn user (interactive use) ((and method-auth (equal 'warn auth)) (user-error - "This request requires authentication. Please run `M-x sx-auth-authenticate' and try again.")) + "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) (setq call 'sx-request-fallback)) -- 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(-) (limited to 'sx-method.el') 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