(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) ()
(append (cdr ap) '(fundamental-mode)))
extras))))
(cons mode
(yas--merge-ordered-lists
(mapcar #'yas--all-parents
(remq nil
`(,(or (get mode 'derived-mode-parent)
;; Consider `fundamental-mode'
;; as ultimate ancestor.
'fundamental-mode)
,(let ((alias (symbol-function mode)))
(when (symbolp alias) alias))
,@(get mode 'derived-mode-extra-parents)
,@(gethash mode yas--parents)))))))))
(delete-dups
(cons mode
(yas--merge-ordered-lists
(mapcar #'yas--all-parents
(remq nil
`(,(or (get mode 'derived-mode-parent)
;; Consider `fundamental-mode'
;; as ultimate ancestor.
'fundamental-mode)
,(let ((alias (symbol-function mode)))
(when (symbolp alias) alias))
,@(get mode 'derived-mode-extra-parents)
,@(gethash mode yas--parents))))))))))
(dolist (parent all-parents)
(cl-pushnew mode (get parent 'yas--cached-children)))
(put mode 'yas--all-parents all-parents)))))