Prioritize private snippets over built-in ones
In the case of snippet conflicts, you'd normally be prompted to select which snippet you want. Built-in snippets are now disregarded if conflicting private ones exist. This makes it easier for users to add overriding snippets to DOOMDIR/snippets.
This commit is contained in:
parent
735e14270e
commit
1490b9ec8d
2 changed files with 22 additions and 4 deletions
|
@ -1,8 +1,20 @@
|
|||
;;; feature/snippets/autoload/snippets.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;
|
||||
;; Commands
|
||||
;;
|
||||
;;;###autoload
|
||||
(defun +snippets-prompt-private (prompt choices &optional fn)
|
||||
"Prioritize private snippets (in `+snippets-dir') over built-in ones if there
|
||||
are multiple choices."
|
||||
(when-let*
|
||||
((choices
|
||||
(or (cl-loop for tpl in choices
|
||||
if (file-in-directory-p (yas--template-get-file tpl)
|
||||
+snippets-dir)
|
||||
collect tpl)
|
||||
choices)))
|
||||
(if (cdr choices)
|
||||
(let ((prompt-functions (remq '+snippets-prompt-private yas-prompt-functions)))
|
||||
(run-hook-with-args-until-success 'prompt-functions prompt choices fn))
|
||||
(car choices))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +snippets/goto-start-of-field ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue