Skip to content

Commit

Permalink
[Fix #720] [Fix #719] Do not eval keyword arguments in sp-pair with…
Browse files Browse the repository at this point in the history
… lexical-binding.
  • Loading branch information
Fuco1 committed Mar 12, 2017
1 parent 76311ef commit 1a753e0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions smartparens.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 36 additions & 0 deletions test/smartparens-settings-sp-pair-test.el
Original file line number Diff line number Diff line change
@@ -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))))))))

0 comments on commit 1a753e0

Please sign in to comment.