mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
Closes #495: Allow symbols as aliases in `yas-snippet-dirs'
* yasnippet.el (yas-installed-snippets-dir): New parameter. Set at load time from `load-file-name'. (yas--load-file-name): Removed. (yas-snippet-dirs): Update docstring. Default value has symbol `yas-installed-snippets-dir' as an alias to any bundled snippets. (yas-snippet-dirs): Redesign for new `yas-snippet-dirs' semantics.
This commit is contained in:
parent
1d4618b022
commit
5b59b802ac
40
yasnippet.el
40
yasnippet.el
@ -150,21 +150,25 @@
|
|||||||
"Yet Another Snippet extension"
|
"Yet Another Snippet extension"
|
||||||
:group 'editing)
|
:group 'editing)
|
||||||
|
|
||||||
(defvar yas--load-file-name load-file-name
|
(defvar yas-installed-snippets-dir nil)
|
||||||
"Store the filename that yasnippet.el was originally loaded from.")
|
(setq yas-installed-snippets-dir
|
||||||
|
(when load-file-name
|
||||||
|
(concat (file-name-directory load-file-name) "snippets")))
|
||||||
|
|
||||||
(defcustom yas-snippet-dirs (remove nil
|
(defcustom yas-snippet-dirs (remove nil
|
||||||
(list "~/.emacs.d/snippets"
|
(list "~/.emacs.d/snippets"
|
||||||
(when yas--load-file-name
|
'yas-installed-snippets-dir))
|
||||||
(concat (file-name-directory yas--load-file-name) "snippets"))))
|
"List of top-level snippet directories.
|
||||||
"Directory or list of snippet dirs for each major mode.
|
|
||||||
|
|
||||||
The directory where user-created snippets are to be stored. Can
|
Each element, a string or a symbol whose value is a string,
|
||||||
also be a list of directories. In that case, when used for
|
designates a top-level directory where per-mode snippet
|
||||||
bulk (re)loading of snippets (at startup or via
|
directories can be found.
|
||||||
`yas-reload-all'), directories appearing earlier in the list
|
|
||||||
shadow other dir's snippets. Also, the first directory is taken
|
Elements appearing earlier in the list shadow later elements'
|
||||||
as the default for storing the user's new snippets."
|
snippets.
|
||||||
|
|
||||||
|
The first directory is taken as the default for storing snippet's
|
||||||
|
created with `yas-new-snippet'. "
|
||||||
:type '(choice (string :tag "Single directory (string)")
|
:type '(choice (string :tag "Single directory (string)")
|
||||||
(repeat :args (string) :tag "List of directories (strings)"))
|
(repeat :args (string) :tag "List of directories (strings)"))
|
||||||
:group 'yasnippet
|
:group 'yasnippet
|
||||||
@ -178,8 +182,18 @@ as the default for storing the user's new snippets."
|
|||||||
(yas-reload-all)))))
|
(yas-reload-all)))))
|
||||||
|
|
||||||
(defun yas-snippet-dirs ()
|
(defun yas-snippet-dirs ()
|
||||||
"Return `yas-snippet-dirs' (which see) as a list."
|
"Return variable `yas-snippet-dirs' as list of strings."
|
||||||
(if (listp yas-snippet-dirs) yas-snippet-dirs (list yas-snippet-dirs)))
|
(cl-loop for e in (if (listp yas-snippet-dirs)
|
||||||
|
yas-snippet-dirs
|
||||||
|
(list yas-snippet-dirs))
|
||||||
|
collect
|
||||||
|
(cond ((stringp e) e)
|
||||||
|
((and (symbolp e)
|
||||||
|
(boundp e)
|
||||||
|
(stringp (symbol-value e)))
|
||||||
|
(symbol-value e))
|
||||||
|
(t
|
||||||
|
(error "[yas] invalid element %s in `yas-snippet-dirs'" e)))))
|
||||||
|
|
||||||
(defvaralias 'yas/root-directory 'yas-snippet-dirs)
|
(defvaralias 'yas/root-directory 'yas-snippet-dirs)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user