From 1a753e05930e464baffc727ec99c4b8e1a1013f4 Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Sun, 12 Mar 2017 12:50:48 +0100 Subject: [PATCH] [Fix #720] [Fix #719] Do not eval keyword arguments in `sp-pair` with lexical-binding. --- smartparens.el | 4 +-- test/smartparens-settings-sp-pair-test.el | 36 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 test/smartparens-settings-sp-pair-test.el diff --git a/smartparens.el b/smartparens.el index 97065c67..532c7b6c 100644 --- a/smartparens.el +++ b/smartparens.el @@ -2208,9 +2208,9 @@ modes, use this property on `sp-local-pair' instead." ;; already exists in the pair. In that case, we will set it to ;; nil. This allows for removing properties in global ;; definitions. - (when (or (eval (cdr arg)) + (when (or (cdr arg) (sp-get-pair-definition open t (car arg))) - (plist-put pair (car arg) (eval (cdr arg))))) + (plist-put pair (car arg) (cdr arg)))) (sp--update-pair-list pair t)) (when (or wrap bind) (global-set-key (read-kbd-macro (or wrap bind)) `(lambda (&optional arg) diff --git a/test/smartparens-settings-sp-pair-test.el b/test/smartparens-settings-sp-pair-test.el new file mode 100644 index 00000000..a66b8383 --- /dev/null +++ b/test/smartparens-settings-sp-pair-test.el @@ -0,0 +1,36 @@ +(ert-deftest sp-test-add-global-pair () + (let ((sp-pairs nil)) + (sp-pair "(" ")") + (should (equal sp-pairs '((t (:open "(" :close ")" :actions (wrap insert autoskip navigate)))))))) + +(ert-deftest sp-test-add-global-pair-with-a-when-condition () + (let ((sp-pairs nil)) + (sp-pair "(" ")" :when '(ignore)) + (should (equal sp-pairs '((t (:open "(" :close ")" + :actions (wrap insert autoskip navigate) + :when (ignore)))))))) + +(ert-deftest sp-test-remove-global-pair-when-condition () + (let ((sp-pairs '((t (:open "(" :close ")" + :actions (wrap insert autoskip navigate) + :when (ignore)))))) + (sp-pair "(" ")" :when nil) + (should (equal sp-pairs '((t (:open "(" :close ")" + :actions (wrap insert autoskip navigate) + :when nil))))))) + +(ert-deftest sp-test-replace-global-pair-actions () + (let ((sp-pairs '((t (:open "(" :close ")" + :actions (wrap insert autoskip navigate) + :when (ignore)))))) + (sp-pair "(" ")" :actions '(wrap insert)) + (should (equal sp-pairs '((t (:open "(" :close ")" + :actions (wrap insert) + :when nil))))))) + +(ert-deftest sp-test-remove-global-pair-nonexisting-when-condition () + (let ((sp-pairs '((t (:open "(" :close ")" + :actions (wrap insert autoskip navigate)))))) + (sp-pair "(" ")" :when nil) + (should (equal sp-pairs '((t (:open "(" :close ")" + :actions (wrap insert autoskip navigate))))))))