]> code.delx.au - gnu-emacs-elpa/commitdiff
Build a single `explored' list.
authorNoam Postavsky <npostavs@users.sourceforge.net>
Sun, 11 Oct 2015 16:40:17 +0000 (12:40 -0400)
committerNoam Postavsky <npostavs@users.sourceforge.net>
Sun, 11 Oct 2015 17:08:59 +0000 (13:08 -0400)
* 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.

yasnippet.el

index 1311cd0a9eade37427d3e6ba04ed42bd071dd5cb..c38b9db2391ec75c6c6d2242dc28d1d1feb8ef79 100644 (file)
@@ -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.")