mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
(yas--all-parents): Fix stale cache issue #1180
* yasnippet.el (yas--all-parents): Record children in `yas--all-children`. (yas--define-parents): Use it to flush the caches of the affected modes.
This commit is contained in:
parent
ae36504a5f
commit
d7f55c7501
@ -819,7 +819,7 @@ which decides on the snippet to expand.")
|
|||||||
(or (get mode 'yas--all-parents) ;; FIXME: Use `with-memoization'?
|
(or (get mode 'yas--all-parents) ;; FIXME: Use `with-memoization'?
|
||||||
(progn
|
(progn
|
||||||
(put mode 'yas--all-parents (list mode)) ;; Stop inf-loop with cycles.
|
(put mode 'yas--all-parents (list mode)) ;; Stop inf-loop with cycles.
|
||||||
(put mode 'yas--all-parents
|
(let ((all-parents
|
||||||
(if (fboundp 'derived-mode-all-parents)
|
(if (fboundp 'derived-mode-all-parents)
|
||||||
(let* ((ap (derived-mode-all-parents mode))
|
(let* ((ap (derived-mode-all-parents mode))
|
||||||
(extras
|
(extras
|
||||||
@ -840,7 +840,10 @@ which decides on the snippet to expand.")
|
|||||||
'fundamental-mode)
|
'fundamental-mode)
|
||||||
,(let ((alias (symbol-function mode)))
|
,(let ((alias (symbol-function mode)))
|
||||||
(when (symbolp alias) alias))
|
(when (symbolp alias) alias))
|
||||||
,@(gethash mode yas--parents)))))))))))
|
,@(gethash mode yas--parents)))))))))
|
||||||
|
(dolist (parent all-parents)
|
||||||
|
(cl-pushnew mode (get parent 'yas--all-children)))
|
||||||
|
(put mode 'yas--all-parents all-parents)))))
|
||||||
|
|
||||||
(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' and friends."
|
"Compute list of mode symbols that are active for `yas-expand' and friends."
|
||||||
@ -1854,6 +1857,8 @@ the current buffers contents."
|
|||||||
|
|
||||||
(defun yas--define-parents (mode parents)
|
(defun yas--define-parents (mode parents)
|
||||||
"Add PARENTS to the list of MODE's 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.
|
||||||
(puthash mode (cl-remove-duplicates
|
(puthash mode (cl-remove-duplicates
|
||||||
(append parents
|
(append parents
|
||||||
(gethash mode yas--parents)))
|
(gethash mode yas--parents)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user