From 33587a8551b8f6991b607d3532062a384c010ce1 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 8 Mar 2024 03:15:33 -0500 Subject: [PATCH] (yas-reload-all): Flush the `all-parents` caches (issue #1194) * yasnippet.el (yas--flush-all-parents): New function. (yas-reload-all): Use it. * yasnippet.el (issue-492-and-494): Don't flush the all=parents cache any more since `yas-reload-all` does it for us. --- yasnippet-tests.el | 1 - yasnippet.el | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/yasnippet-tests.el b/yasnippet-tests.el index 7e10095..e8d2847 100644 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -1438,7 +1438,6 @@ hello ${1:$(when (stringp yas-text) (funcall func yas-text))} foo${1:$$(concat \ (yas-with-snippet-dirs '((".emacs.d/snippets" ("yas--test-mode"))) (yas-reload-all) - (put 'c-mode 'yas--all-parents nil) (with-temp-buffer (let* ((major-mode 'yas--test-mode) (expected `(fundamental-mode diff --git a/yasnippet.el b/yasnippet.el index 35b4887..fa36be7 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -824,6 +824,10 @@ which decides on the snippet to expand.") ;; Prevent sharing the tail. (append lists '(()) ))))))) +(defun yas--flush-all-parents (mode) + (if (get mode 'yas--all-parents) + (put mode 'yas--all-parents nil))) + (defun yas--all-parents (mode) "Like `derived-mode-all-parents' but obeying `yas--parents'." (or (get mode 'yas--all-parents) ;; FIXME: Use `with-memoization'? @@ -2010,6 +2014,9 @@ prefix argument." (with-current-buffer buffer yas--editing-template)) (buffer-list)))) + + (mapatoms #'yas--flush-all-parents) + ;; Warn if there are buffers visiting snippets, since reloading will break ;; any on-line editing of those buffers. ;;