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:
Henrik Lissner 2018-08-11 16:48:31 +02:00
parent 735e14270e
commit 1490b9ec8d
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 22 additions and 4 deletions

View file

@ -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 ()