From: Noam Postavsky Date: Sun, 11 Oct 2015 16:40:17 +0000 (-0400) Subject: Build a single `explored' list. X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/e56aa6f7b335e34788f479cc5816f4789ed45b9c Build a single `explored' list. * yasnippet.el (yas--modes-to-activate): Make helper dfs function produce the list of modes only by updating a single `explored' list, instead of building up the list by value and having to remove duplicated after. --- diff --git a/yasnippet.el b/yasnippet.el index 1311cd0a9..c38b9db23 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -728,22 +728,23 @@ defined direct keybindings to the command (defun yas--modes-to-activate (&optional mode) "Compute list of mode symbols that are active for `yas-expand' and friends." - (let (dfs) - (setq dfs (lambda (mode &optional explored) - (push mode explored) - (cons mode - (loop for neighbour - 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 (if mode - (funcall dfs mode) - (append yas--extra-modes - (funcall dfs major-mode)))))) + (let (dfs explored) + (setq dfs (lambda (mode) + (unless (memq mode explored) + (push mode explored) + (loop for neighbour + 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)) + do (funcall dfs neighbour))))) + (if mode + (progn (funcall dfs mode) + explored) + (funcall dfs major-mode) + (append yas--extra-modes explored)))) (defvar yas-minor-mode-hook nil "Hook run when `yas-minor-mode' is turned on.")