Closes #492, closes #494: Consider defalias when calculating parent modes

* yasnippet-tests.el (issue-492-and-494): New test.

* yasnippet.el (yas--modes-to-activate): Consider each mode's
symbol-function as a neighbour in case it's a symbol as well.
This commit is contained in:
João Távora 2014-07-28 11:37:46 +01:00
parent 2b24aeaf80
commit 0b7b34a333
2 changed files with 24 additions and 5 deletions

View File

@ -426,6 +426,24 @@ TODO: correct this bug!"
(should (= (length expected)
(length observed))))))))
(ert-deftest issue-492-and-494 ()
(defalias 'yas--phony-c-mode 'c-mode)
(define-derived-mode yas--test-mode yas--phony-c-mode "Just a test mode")
(yas-with-snippet-dirs '((".emacs.d/snippets"
("yas--test-mode")))
(yas-reload-all)
(with-temp-buffer
(let* ((major-mode 'yas--test-mode)
(expected `(c-mode
,@(if (fboundp 'prog-mode)
'(prog-mode))
yas--phony-c-mode
yas--test-mode))
(observed (yas--modes-to-activate)))
(should (null (cl-set-exclusive-or expected observed)))
(should (= (length expected)
(length observed)))))))
(defun yas--basic-jit-loading-1 ()
(with-temp-buffer
(should (= 4 (hash-table-count yas--scheduled-jit-loads)))

View File

@ -699,11 +699,12 @@ and friends."
(push mode explored)
(cons mode
(loop for neighbour
in (remove nil (cons (get mode
'derived-mode-parent)
(gethash mode yas--parents)))
unless (memq neighbour explored)
in (cl-list* (get mode 'derived-mode-parent)
(ignore-errors (symbol-function mode))
(gethash mode yas--parents))
when (and neighbour
(not (memq neighbour explored))
(symbolp neighbour))
append (funcall dfs neighbour explored)))))
(remove-duplicates (append yas--extra-modes
(funcall dfs major-mode)))))