]> code.delx.au - gnu-emacs-elpa/commitdiff
Closes #440: don't use `make-variable-buffer-local' for `yas--extra-modes'
authorJoao Tavora <joaotavora@gmail.com>
Tue, 3 Dec 2013 15:19:37 +0000 (15:19 +0000)
committerJoao Tavora <joaotavora@gmail.com>
Tue, 3 Dec 2013 15:20:53 +0000 (15:20 +0000)
yasnippet-tests.el
yasnippet.el

index 1d770b47f5637c5bf55ec5bdb490be36f80ac493..4e2f1bc06f813be195f0707a44e71366d9cc6ee4 100644 (file)
@@ -605,26 +605,24 @@ TODO: be meaner"
   "Given a symbol, `yas-activate-extra-mode' should be able to
 add the snippets associated with the given mode."
   (with-temp-buffer
-    (emacs-lisp-mode)
-    (yas-minor-mode-on)
-    (yas-activate-extra-mode 'markdown-mode)
-    (should (eq 'markdown-mode (car yas--extra-modes)))
-    (yas-should-expand '(("_" . "_Text_ ")))
-    (yas-should-expand '(("car" . "(car )")))))
-
-(ert-deftest test-yas-deactivate-extra-modes ()
-  "Given a symbol, `yas-deactive-extra-mode' should be able to
-remove one of the extra modes that is present in the current
-buffer."
-  (with-temp-buffer
-    (emacs-lisp-mode)
-    (yas-minor-mode-on)
-    (yas-activate-extra-mode 'markdown-mode)
-    (should (eq 'markdown-mode (car yas--extra-modes)))
-    (yas-deactivate-extra-mode 'markdown-mode)
-    (should-not (eq 'markdown-mode (car yas--extra-modes)))
-    (yas-should-not-expand '("_"))
-    (yas-should-expand '(("car" . "(car )")))))
+    (yas-saving-variables
+     (yas-with-snippet-dirs
+       '((".emacs.d/snippets"
+          ("markdown-mode"
+           ("_" . "_Text_ "))
+          ("emacs-lisp-mode"
+           ("car" . "(car )"))))
+       (yas-reload-all)
+       (emacs-lisp-mode)
+       (yas-minor-mode-on)
+       (yas-activate-extra-mode 'markdown-mode)
+       (should (eq 'markdown-mode (car yas--extra-modes)))
+       (yas-should-expand '(("_" . "_Text_ ")))
+       (yas-should-expand '(("car" . "(car )")))
+       (yas-deactivate-extra-mode 'markdown-mode)
+       (should-not (eq 'markdown-mode (car yas--extra-modes)))
+       (yas-should-not-expand '("_"))
+       (yas-should-expand '(("car" . "(car )")))))))
 
 \f
 ;;; Helpers
index cbb4c2b6d1c5ad0aa087ca554bbc5aac7fd7f99d..85715fd24dbfe4215e65c8f0230e71aff1bf6623 100644 (file)
@@ -778,8 +778,7 @@ activate snippets associated with that mode."
       (when (not (string= "" symbol))
         (intern symbol)))))
   (when mode
-    (make-variable-buffer-local 'yas--extra-modes)
-    (add-to-list 'yas--extra-modes mode)
+    (add-to-list (make-local-variable 'yas--extra-modes) mode)
     (yas--load-pending-jits)))
 
 (defun yas-deactivate-extra-mode (mode)
@@ -788,9 +787,9 @@ activate snippets associated with that mode."
    (list (intern
           (completing-read
            "Deactivate mode: " (mapcar #'list yas--extra-modes) nil t))))
-  (setq yas--extra-modes
-        (remove mode
-                yas--extra-modes)))
+  (set (make-local-variable 'yas--extra-modes)
+       (remove mode
+               yas--extra-modes)))
 
 (defvar yas-dont-activate '(minibufferp)
   "If non-nil don't let `yas-global-mode' affect some buffers.