From: Joao Tavora Date: Tue, 3 Dec 2013 15:19:37 +0000 (+0000) Subject: Closes #440: don't use `make-variable-buffer-local' for `yas--extra-modes' X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/7d4e4aa34c4c1935813e93a74063be812d3de365 Closes #440: don't use `make-variable-buffer-local' for `yas--extra-modes' --- diff --git a/yasnippet-tests.el b/yasnippet-tests.el index 1d770b47f..4e2f1bc06 100644 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -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 )"))))))) ;;; Helpers diff --git a/yasnippet.el b/yasnippet.el index cbb4c2b6d..85715fd24 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -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.