Inlining the uuid function
This commit is contained in:
parent
c0c932ae09
commit
670c8d519d
1 changed files with 5 additions and 14 deletions
|
@ -33,23 +33,14 @@ ignored. This makes it easy to override built-in snippets with private ones."
|
||||||
(make-directory dir t)
|
(make-directory dir t)
|
||||||
(error "%S doesn't exist" (abbreviate-file-name dir)))))
|
(error "%S doesn't exist" (abbreviate-file-name dir)))))
|
||||||
|
|
||||||
(defun +snippet--get-exact-template-by-uuid (mode uuid)
|
|
||||||
"Similar behavior to yas--get-template-by-uuid, but deal with empty tables better.
|
|
||||||
Yas' behavior introduces a bug for this case (no table for mode)"
|
|
||||||
(when-let* ((table (gethash mode yas--tables))
|
|
||||||
(uuid-hash (yas--table-uuidhash table)))
|
|
||||||
(gethash uuid uuid-hash)))
|
|
||||||
|
|
||||||
(defun +snippet--get-template-by-uuid (uuid &optional mode)
|
(defun +snippet--get-template-by-uuid (uuid &optional mode)
|
||||||
"Look up the template by uuid in child-most to parent-most mode order.
|
"Look up the template by uuid in child-most to parent-most mode order.
|
||||||
Finds correctly active snippets from parent modes (based on Yas' logic)."
|
Finds correctly active snippets from parent modes (based on Yas' logic)."
|
||||||
(let* ((mode (or mode major-mode))
|
(cl-loop with mode = (or mode major-mode)
|
||||||
(active-modes (yas--modes-to-activate mode)))
|
for active-mode in (yas--modes-to-activate mode)
|
||||||
(cl-loop
|
if (gethash active-mode yas--tables)
|
||||||
for active-mode in active-modes
|
if (gethash uuid (yas--table-uuidhash it))
|
||||||
for template = (+snippet--get-exact-template-by-uuid active-mode uuid)
|
return it))
|
||||||
if (not (null template))
|
|
||||||
return template)))
|
|
||||||
|
|
||||||
(defun +snippet--completing-read-uuid (prompt all-snippets &rest args)
|
(defun +snippet--completing-read-uuid (prompt all-snippets &rest args)
|
||||||
(plist-get
|
(plist-get
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue