fix(file-templates): +file-templates/debug
Command was previously inoperable (threw an error).
This commit is contained in:
parent
b36d798f74
commit
3106443707
1 changed files with 15 additions and 8 deletions
|
@ -59,7 +59,10 @@ evil is loaded and enabled)."
|
||||||
(when (and pred (not ignore))
|
(when (and pred (not ignore))
|
||||||
(when (if project (doom-project-p) t)
|
(when (if project (doom-project-p) t)
|
||||||
(unless mode
|
(unless mode
|
||||||
(setq mode (if (symbolp pred) pred major-mode)))
|
(setq mode
|
||||||
|
(if (and (symbolp pred) (not (booleanp pred)))
|
||||||
|
pred
|
||||||
|
major-mode)))
|
||||||
(unless mode
|
(unless mode
|
||||||
(user-error "Couldn't determine mode for %s file template" pred))
|
(user-error "Couldn't determine mode for %s file template" pred))
|
||||||
(unless trigger
|
(unless trigger
|
||||||
|
@ -119,10 +122,14 @@ evil is loaded and enabled)."
|
||||||
"Tests the current buffer and outputs the file template rule most appropriate
|
"Tests the current buffer and outputs the file template rule most appropriate
|
||||||
for it. This is used for testing."
|
for it. This is used for testing."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((template (cl-find-if #'+file-template-p +file-templates-alist)))
|
(cl-destructuring-bind (pred &rest plist &key trigger mode &allow-other-keys)
|
||||||
(if (cl-find trigger (yas--all-templates
|
(or (cl-find-if #'+file-template-p +file-templates-alist)
|
||||||
|
(user-error "Found no file template for this file"))
|
||||||
|
(if (or (functionp trigger)
|
||||||
|
(cl-find trigger
|
||||||
|
(yas--all-templates
|
||||||
(yas--get-snippet-tables
|
(yas--get-snippet-tables
|
||||||
(plist-get template :mode)))
|
mode))
|
||||||
:key #'yas--template-key :test #'equal)
|
:key #'yas--template-key :test #'equal))
|
||||||
(message "Found %s" template)
|
(message "Found %s" (cons pred plist))
|
||||||
(message "Found rule, but can't find associated snippet: %s" template))))
|
(message "Found rule, but can't find associated snippet: %s" (cons pred plist)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue