branch: master commit 7d4e4aa34c4c1935813e93a74063be812d3de365 Author: Joao Tavora <joaotav...@gmail.com> Commit: Joao Tavora <joaotav...@gmail.com>
Closes #440: don't use `make-variable-buffer-local' for `yas--extra-modes' --- yasnippet-tests.el | 38 ++++++++++++++++++-------------------- yasnippet.el | 9 ++++----- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/yasnippet-tests.el b/yasnippet-tests.el index 1d770b4..4e2f1bc 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 cbb4c2b..85715fd 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.