emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master e56aa6f 28/60: Build a single `explored' list.


From: João Távora
Subject: [elpa] master e56aa6f 28/60: Build a single `explored' list.
Date: Thu, 21 Jan 2016 22:35:58 +0000

branch: master
commit e56aa6f7b335e34788f479cc5816f4789ed45b9c
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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.
---
 yasnippet.el |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/yasnippet.el b/yasnippet.el
index 1311cd0..c38b9db 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.")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]