Closes #440: don't use make-variable-buffer-local' for yas--extra-modes'

This commit is contained in:
Joao Tavora 2013-12-03 15:19:37 +00:00
parent 0a9885eb62
commit 7d4e4aa34c
2 changed files with 22 additions and 25 deletions

View 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 )")))))))
;;; Helpers

View 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.