mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
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.
This commit is contained in:
parent
00b84ceaf4
commit
e56aa6f7b3
33
yasnippet.el
33
yasnippet.el
@ -728,22 +728,23 @@ defined direct keybindings to the command
|
|||||||
(defun yas--modes-to-activate (&optional mode)
|
(defun yas--modes-to-activate (&optional mode)
|
||||||
"Compute list of mode symbols that are active for `yas-expand'
|
"Compute list of mode symbols that are active for `yas-expand'
|
||||||
and friends."
|
and friends."
|
||||||
(let (dfs)
|
(let (dfs explored)
|
||||||
(setq dfs (lambda (mode &optional explored)
|
(setq dfs (lambda (mode)
|
||||||
(push mode explored)
|
(unless (memq mode explored)
|
||||||
(cons mode
|
(push mode explored)
|
||||||
(loop for neighbour
|
(loop for neighbour
|
||||||
in (cl-list* (get mode 'derived-mode-parent)
|
in (cl-list* (get mode 'derived-mode-parent)
|
||||||
(ignore-errors (symbol-function mode))
|
(ignore-errors (symbol-function mode))
|
||||||
(gethash mode yas--parents))
|
(gethash mode yas--parents))
|
||||||
when (and neighbour
|
when (and neighbour
|
||||||
(not (memq neighbour explored))
|
(not (memq neighbour explored))
|
||||||
(symbolp neighbour))
|
(symbolp neighbour))
|
||||||
append (funcall dfs neighbour explored)))))
|
do (funcall dfs neighbour)))))
|
||||||
(remove-duplicates (if mode
|
(if mode
|
||||||
(funcall dfs mode)
|
(progn (funcall dfs mode)
|
||||||
(append yas--extra-modes
|
explored)
|
||||||
(funcall dfs major-mode))))))
|
(funcall dfs major-mode)
|
||||||
|
(append yas--extra-modes explored))))
|
||||||
|
|
||||||
(defvar yas-minor-mode-hook nil
|
(defvar yas-minor-mode-hook nil
|
||||||
"Hook run when `yas-minor-mode' is turned on.")
|
"Hook run when `yas-minor-mode' is turned on.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user