emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 9cf9208 32/40: Fix test-rebindings


From: Noam Postavsky
Subject: [elpa] master 9cf9208 32/40: Fix test-rebindings
Date: Wed, 26 Oct 2016 23:06:34 +0000 (UTC)

branch: master
commit 9cf92085e53f579af997f43540a26b4377f07678
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Fix test-rebindings
    
    * yasnippet-tests.el (test-rebindings): Make the rebindings properly
    temporary instead of just setting them back to what the presumed default
    is.
---
 yasnippet-tests.el |   32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index c5fd376..55cd137 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -900,23 +900,21 @@ TODO: be meaner"
     (should (eq (key-binding [backtab]) 'yas-prev-field))))
 
 (ert-deftest test-rebindings ()
-  (unwind-protect
-      (progn
-        (define-key yas-minor-mode-map [tab] nil)
-        (define-key yas-minor-mode-map (kbd "TAB") nil)
-        (define-key yas-minor-mode-map (kbd "SPC") 'yas-expand)
-        (with-temp-buffer
-          (yas-minor-mode 1)
-          (should (not (eq (key-binding (yas--read-keybinding "TAB")) 
'yas-expand)))
-          (should (eq (key-binding (yas--read-keybinding "SPC")) 'yas-expand))
-          (yas-reload-all)
-          (should (not (eq (key-binding (yas--read-keybinding "TAB")) 
'yas-expand)))
-          (should (eq (key-binding (yas--read-keybinding "SPC")) 
'yas-expand))))
-    ;; FIXME: actually should restore to whatever saved values where there.
-    ;;
-    (define-key yas-minor-mode-map [tab] 'yas-expand)
-    (define-key yas-minor-mode-map (kbd "TAB") 'yas-expand)
-    (define-key yas-minor-mode-map (kbd "SPC") nil)))
+  (let* ((yas-minor-mode-map (copy-keymap yas-minor-mode-map))
+         (minor-mode-map-alist
+          (cons `(yas-minor-mode . ,yas-minor-mode-map)
+                (cl-remove 'yas-minor-mode minor-mode-map-alist
+                           :test #'eq :key #'car))))
+    (define-key yas-minor-mode-map [tab] nil)
+    (define-key yas-minor-mode-map (kbd "TAB") nil)
+    (define-key yas-minor-mode-map (kbd "SPC") 'yas-expand)
+    (with-temp-buffer
+      (yas-minor-mode 1)
+      (should-not (eq (key-binding (kbd "TAB")) 'yas-expand))
+      (should (eq (key-binding (kbd "SPC")) 'yas-expand))
+      (yas-reload-all)
+      (should-not (eq (key-binding (kbd "TAB")) 'yas-expand))
+      (should (eq (key-binding (kbd "SPC")) 'yas-expand)))))
 
 (ert-deftest test-yas-in-org ()
   (with-temp-buffer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]