[elpa] master 59a4079: * websocket/websocket.el (websocket-server-accept): Mark arg as unused

2016-05-10 Thread Stefan Monnier
branch: master
commit 59a4079b73574eb5ef21103714e47033e61891c7
Author: Stefan Monnier 
Commit: Stefan Monnier 

* websocket/websocket.el (websocket-server-accept): Mark arg as unused

* websocket/websocket-functional-test.el: Fix compilation warnings.
---
 packages/websocket/websocket-functional-test.el |   62 +++
 packages/websocket/websocket.el |2 +-
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/packages/websocket/websocket-functional-test.el 
b/packages/websocket/websocket-functional-test.el
index 1bbd190..e447015 100644
--- a/packages/websocket/websocket-functional-test.el
+++ b/packages/websocket/websocket-functional-test.el
@@ -1,6 +1,6 @@
 ;;; websocket-functional-test.el --- Simple functional testing
 
-;; Copyright (c) 2013  Free Software Foundation, Inc.
+;; Copyright (c) 2013, 2016  Free Software Foundation, Inc.
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
@@ -51,11 +51,11 @@
 (defvar wstest-ws
   (websocket-open
"ws://127.0.0.1:"
-   :on-message (lambda (websocket frame)
+   :on-message (lambda (_websocket frame)
  (push (websocket-frame-payload frame) wstest-msgs)
  (message "ws frame: %S" (websocket-frame-payload frame))
  (error "Test error (expected)"))
-   :on-close (lambda (websocket) (setq wstest-closed t
+   :on-close (lambda (_websocket) (setq wstest-closed t
 
 (defun wstest-pop-to-debug ()
   "Open websocket log buffer. Not used in testing. Just for debugging."
@@ -71,7 +71,7 @@
 
 (sleep-for 0.1)
 (assert (equal (car wstest-msgs) "You said: Hi!"))
-(setf (websocket-on-error wstest-ws) (lambda (ws type err)))
+(setf (websocket-on-error wstest-ws) (lambda (_ws _type _err)))
 (websocket-send-text wstest-ws "Hi after error!")
 (sleep-for 0.1)
 (assert (equal (car wstest-msgs) "You said: Hi after error!"))
@@ -94,19 +94,19 @@
 ;; Remote server test, with wss ;;
 ;;
 
-(when (>= (string-to-int (substring emacs-version 0 2)) 24)
+(when (>= (string-to-number (substring emacs-version 0 2)) 24)
   (message "Testing with wss://echo.websocket.org")
   (when (eq system-type 'windows-nt)
 (message "Windows users must have gnutls DLLs in the emacs bin 
directory."))
   (setq wstest-ws
 (websocket-open
  "wss://echo.websocket.org"
- :on-open (lambda (websocket)
+ :on-open (lambda (_websocket)
 (message "Websocket opened"))
- :on-message (lambda (websocket frame)
+ :on-message (lambda (_websocket frame)
(push (websocket-frame-payload frame) wstest-msgs)
(message "ws frame: %S" (websocket-frame-payload 
frame)))
- :on-close (lambda (websocket)
+ :on-close (lambda (_websocket)
  (message "Websocket closed")
  (setq wstest-closed t)))
 wstest-msgs nil)
@@ -126,30 +126,30 @@
 (message "Testing with emacs websocket server.")
 (message "If this does not pass, make sure your firewall allows the 
connection.")
 (setq wstest-closed nil)
-(setq server-conn (websocket-server
-   9998
-   :host 'local
-   :on-message (lambda (ws frame)
- (message "Server received text!")
- (websocket-send-text ws
-  (websocket-frame-payload frame)))
-   :on-open (lambda (websocket) "Client connection opened!")
-   :on-close (lambda (websocket)
-   (setq wstest-closed t
-
-(setq wstest-msgs nil
-  wstest-ws
-  (websocket-open
-   "ws://localhost:9998"
-   :on-message (lambda (websocket frame)
- (push (websocket-frame-payload frame) wstest-msgs)
- (message "ws frame: %S" (websocket-frame-payload 
frame)
+(let ((server-conn (websocket-server
+9998
+:host 'local
+:on-message (lambda (ws frame)
+  (message "Server received text!")
+  (websocket-send-text ws
+   
(websocket-frame-payload frame)))
+:on-open (lambda (_websocket) "Client connection opened!")
+:on-close (lambda (_websocket)
+(setq wstest-closed t)
+
+  (setq wstest-msgs nil
+wstest-ws
+(websocket-open
+ "ws://localhost:9998"
+ :on-message (lambda (_websocket frame)
+   (push (websocket-frame-payload frame) wstest-msgs)
+   (message "ws frame: %S" (websocket-frame-payload 
frame)
 
-(assert (websocket-openp wstest-ws))
-(websocket-send-text wstest-ws "H

[elpa] master 40fd76b 3/3: Merge commit '7371d05adf4e86f8c6c507d6a8177abac1680d06'

2016-05-10 Thread Artur Malabarba
branch: master
commit 40fd76b14979e4b72cd981cd08236c8922de25e5
Merge: 59a4079 7371d05
Author: Artur Malabarba 
Commit: Artur Malabarba 

Merge commit '7371d05adf4e86f8c6c507d6a8177abac1680d06'
---
 packages/validate/validate.el |   19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/packages/validate/validate.el b/packages/validate/validate.el
index 7dfe45b..286835e 100644
--- a/packages/validate/validate.el
+++ b/packages/validate/validate.el
@@ -5,7 +5,7 @@
 ;; Author: Artur Malabarba 
 ;; Keywords: lisp
 ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
-;; Version: 0.3
+;; Version: 0.4
 
 ;;; Commentary:
 ;;
@@ -64,6 +64,9 @@
   "wrong number of elements"
 (seq-find #'identity (seq-mapn #'validate--check values schemas
 
+(defun validate--indent-by-2 (x)
+  (replace-regexp-in-string "^" "  " x))
+
 (defun validate--check (value schema)
   "Return nil if VALUE matches SCHEMA.
 If they don't match, return an explanation."
@@ -127,8 +130,8 @@ If they don't match, return an explanation."
(error "`choice' needs at least one 
argument")
  (let ((gather (mapcar (lambda (x) 
(validate--check value x)) args)))
(when (seq-every-p #'identity gather)
- (concat "all of the options failed\n  "
- (mapconcat #'identity gather "\n  
"))
+ (concat "all of the options failed\n"
+ (mapconcat 
#'validate--indent-by-2 gather "\n"))
;; TODO: `restricted-sexp'
(set (or (wtype 'list)
 (let ((failed (list t)))
@@ -145,7 +148,10 @@ If they don't match, return an explanation."
 (let ((print-length 4)
   (print-level 2))
   (format "Looking for `%S' in `%S' failed because:\n%s"
-  schema value r))
+  schema value
+  (if (string-match "\\`Looking" r)
+  r
+(validate--indent-by-2 r
 
 
 ;;; Exposed API
@@ -185,7 +191,10 @@ with `validate-value'. NOERROR is passed to 
`validate-value'."
 (defmacro validate-setq (symbol value)
   "Like `setq', but throw an error if validation fails.
 VALUE is validated against SYMBOL's custom type."
-  `(setq ,symbol (validate-value ,value (custom-variable-type ',symbol
+  `(if (boundp ',symbol)
+   (setq ,symbol (validate-value ,value (custom-variable-type ',symbol)))
+ (user-error "Trying to validate a variable that's not defined yet: 
`%s'.\nYou need to require the package before validating"
+ ',symbol)))
 
 (provide 'validate)
 ;;; validate.el ends here



[elpa] master 12e857a 1/3: Improve readability of the error message

2016-05-10 Thread Artur Malabarba
branch: master
commit 12e857ab9562320806fd0f7fe5fa19a1a395556a
Author: Artur Malabarba 
Commit: Artur Malabarba 

Improve readability of the error message
---
 validate.el |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/validate.el b/validate.el
index 7dfe45b..2d66a27 100644
--- a/validate.el
+++ b/validate.el
@@ -64,6 +64,9 @@
   "wrong number of elements"
 (seq-find #'identity (seq-mapn #'validate--check values schemas
 
+(defun validate--indent-by-2 (x)
+  (replace-regexp-in-string "^" "  " x))
+
 (defun validate--check (value schema)
   "Return nil if VALUE matches SCHEMA.
 If they don't match, return an explanation."
@@ -127,8 +130,8 @@ If they don't match, return an explanation."
(error "`choice' needs at least one 
argument")
  (let ((gather (mapcar (lambda (x) 
(validate--check value x)) args)))
(when (seq-every-p #'identity gather)
- (concat "all of the options failed\n  "
- (mapconcat #'identity gather "\n  
"))
+ (concat "all of the options failed\n"
+ (mapconcat 
#'validate--indent-by-2 gather "\n"))
;; TODO: `restricted-sexp'
(set (or (wtype 'list)
 (let ((failed (list t)))
@@ -145,7 +148,10 @@ If they don't match, return an explanation."
 (let ((print-length 4)
   (print-level 2))
   (format "Looking for `%S' in `%S' failed because:\n%s"
-  schema value r))
+  schema value
+  (if (string-match "\\`Looking" r)
+  r
+(validate--indent-by-2 r
 
 
 ;;; Exposed API



[elpa] master updated (59a4079 -> 40fd76b)

2016-05-10 Thread Artur Malabarba
malabarba pushed a change to branch master.

  from  59a4079   * websocket/websocket.el (websocket-server-accept): Mark 
arg as unused
   new  12e857a   Improve readability of the error message
   new  7371d05   Don't try to validate undefined vars
   new  40fd76b   Merge commit '7371d05adf4e86f8c6c507d6a8177abac1680d06'


Summary of changes:
 packages/validate/validate.el |   19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)



[elpa] master 7371d05 2/3: Don't try to validate undefined vars

2016-05-10 Thread Artur Malabarba
branch: master
commit 7371d05adf4e86f8c6c507d6a8177abac1680d06
Author: Artur Malabarba 
Commit: Artur Malabarba 

Don't try to validate undefined vars
---
 validate.el |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/validate.el b/validate.el
index 2d66a27..286835e 100644
--- a/validate.el
+++ b/validate.el
@@ -5,7 +5,7 @@
 ;; Author: Artur Malabarba 
 ;; Keywords: lisp
 ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
-;; Version: 0.3
+;; Version: 0.4
 
 ;;; Commentary:
 ;;
@@ -191,7 +191,10 @@ with `validate-value'. NOERROR is passed to 
`validate-value'."
 (defmacro validate-setq (symbol value)
   "Like `setq', but throw an error if validation fails.
 VALUE is validated against SYMBOL's custom type."
-  `(setq ,symbol (validate-value ,value (custom-variable-type ',symbol
+  `(if (boundp ',symbol)
+   (setq ,symbol (validate-value ,value (custom-variable-type ',symbol)))
+ (user-error "Trying to validate a variable that's not defined yet: 
`%s'.\nYou need to require the package before validating"
+ ',symbol)))
 
 (provide 'validate)
 ;;; validate.el ends here