(yas--all-parents): delete-dups for fundamental-mode

Before this commit,

(yas--all-parents 'lisp-mode) would return:

`(lisp-mode lisp-data-mode prog-mode fundamental-mode fundamental-mode)`

which would cause duplicated entries when prompting,
if the snippet were for fundamental-mode.
This commit is contained in:
Vito Van 2024-04-02 13:47:04 +08:00
parent 33587a8551
commit e23a80177a
No known key found for this signature in database
GPG Key ID: E1D45DF7D5583BA7

View File

@ -848,18 +848,19 @@ which decides on the snippet to expand.")
(cons (if (eq mode 'fundamental-mode) () (cons (if (eq mode 'fundamental-mode) ()
(append (cdr ap) '(fundamental-mode))) (append (cdr ap) '(fundamental-mode)))
extras)))) extras))))
(cons mode (delete-dups
(yas--merge-ordered-lists (cons mode
(mapcar #'yas--all-parents (yas--merge-ordered-lists
(remq nil (mapcar #'yas--all-parents
`(,(or (get mode 'derived-mode-parent) (remq nil
;; Consider `fundamental-mode' `(,(or (get mode 'derived-mode-parent)
;; as ultimate ancestor. ;; Consider `fundamental-mode'
'fundamental-mode) ;; as ultimate ancestor.
,(let ((alias (symbol-function mode))) 'fundamental-mode)
(when (symbolp alias) alias)) ,(let ((alias (symbol-function mode)))
,@(get mode 'derived-mode-extra-parents) (when (symbolp alias) alias))
,@(gethash mode yas--parents))))))))) ,@(get mode 'derived-mode-extra-parents)
,@(gethash mode yas--parents))))))))))
(dolist (parent all-parents) (dolist (parent all-parents)
(cl-pushnew mode (get parent 'yas--cached-children))) (cl-pushnew mode (get parent 'yas--cached-children)))
(put mode 'yas--all-parents all-parents))))) (put mode 'yas--all-parents all-parents)))))