From 8ce506e32f629b549fd3be8c466fe87819f54d13 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 14 Jan 2024 00:34:22 -0500 Subject: [PATCH] * yasnippet.el (yas--all-parents): Don't add `fundamental-mode` to itself Rename `yas--all-children` to `yas--cached-children` since it doesn't contain "all" children. --- yasnippet.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/yasnippet.el b/yasnippet.el index 26b8ba9..0641d0d 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -829,7 +829,9 @@ which decides on the snippet to expand.") (gethash parent yas--parents)))) ap))) (yas--merge-ordered-lists - (cons (append ap '(fundamental-mode)) extras))) + (cons (if (eq (car ap) 'fundamental-mode) ap + (append ap '(fundamental-mode))) + extras))) (cons mode (yas--merge-ordered-lists (mapcar #'yas--all-parents @@ -842,7 +844,7 @@ which decides on the snippet to expand.") (when (symbolp alias) alias)) ,@(gethash mode yas--parents))))))))) (dolist (parent all-parents) - (cl-pushnew mode (get parent 'yas--all-children))) + (cl-pushnew mode (get parent 'yas--cached-children))) (put mode 'yas--all-parents all-parents))))) (defun yas--modes-to-activate (&optional mode) @@ -1857,8 +1859,9 @@ the current buffers contents." (defun yas--define-parents (mode parents) "Add PARENTS to the list of MODE's parents." - (dolist (child (get mode 'yas--all-children)) - (put child 'yas--all-parents nil)) ;Flush the cache for all children. + (dolist (child (get mode 'yas--cached-children)) + (put child 'yas--all-parents nil)) ;Flush the cache for children. + (put 'mode 'yas--cached-children nil) (puthash mode (cl-remove-duplicates (append parents (gethash mode yas--parents)))