mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
Test visiting compiled snippets
* yasnippet-tests.el (visiting-compiled-snippets): New Test. * yasnippet.el (yas--lookup-snippet-1, yas-lookup-snippet): Split new function yas--lookup-snippet-1 from yas-lookup-snippet.
This commit is contained in:
parent
68b0ab66ca
commit
e3f03cabe0
@ -449,7 +449,7 @@ TODO: correct this bug!"
|
||||
(yas--basic-jit-loading-1)))
|
||||
|
||||
(ert-deftest basic-jit-loading-with-compiled-snippets ()
|
||||
"Test basic loading and expansion of snippets"
|
||||
"Test basic loading and expansion of compiled snippets"
|
||||
(yas-with-some-interesting-snippet-dirs
|
||||
(yas-reload-all)
|
||||
(yas-recompile-all)
|
||||
@ -459,6 +459,20 @@ TODO: correct this bug!"
|
||||
(yas-reload-all)
|
||||
(yas--basic-jit-loading-1))))
|
||||
|
||||
(ert-deftest visiting-compiled-snippets ()
|
||||
"Test snippet visiting for compiled snippets."
|
||||
(yas-with-some-interesting-snippet-dirs
|
||||
(yas-recompile-all)
|
||||
(yas-reload-all 'no-jit) ; must be loaded for `yas-lookup-snippet' to work.
|
||||
(yas--with-temporary-redefinitions ((find-file-noselect
|
||||
(filename &rest _)
|
||||
(throw 'yas-snippet-file filename)))
|
||||
(should (string-suffix-p
|
||||
"cc-mode/def"
|
||||
(catch 'yas-snippet-file
|
||||
(yas--visit-snippet-file-1
|
||||
(yas--lookup-snippet-1 "def" 'cc-mode))))))))
|
||||
|
||||
(ert-deftest loading-with-cyclic-parenthood ()
|
||||
"Test loading when cyclic parenthood is setup."
|
||||
(yas-saving-variables
|
||||
|
14
yasnippet.el
14
yasnippet.el
@ -2296,6 +2296,14 @@ Honours `yas-choose-tables-first', `yas-choose-keys-first' and
|
||||
(remove-duplicates (mapcan #'yas--table-templates tables)
|
||||
:test #'equal))))
|
||||
|
||||
(defun yas--lookup-snippet-1 (name mode)
|
||||
"Get the snippet called NAME in MODE's tables."
|
||||
(let ((yas-choose-tables-first nil) ; avoid prompts
|
||||
(yas-choose-keys-first nil))
|
||||
(cl-find name (yas--all-templates
|
||||
(yas--get-snippet-tables mode))
|
||||
:key #'yas--template-name :test #'string=)))
|
||||
|
||||
(defun yas-lookup-snippet (name &optional mode noerror)
|
||||
"Get the snippet content for the snippet NAME in MODE's tables.
|
||||
|
||||
@ -2304,11 +2312,7 @@ is non-nil, then don't signal an error if there isn't any snippet
|
||||
called NAME.
|
||||
|
||||
Honours `yas-buffer-local-condition'."
|
||||
(let* ((yas-choose-tables-first nil) ; avoid prompts
|
||||
(yas-choose-keys-first nil)
|
||||
(snippet (cl-find name (yas--all-templates
|
||||
(yas--get-snippet-tables mode))
|
||||
:key #'yas--template-name :test #'string=)))
|
||||
(let ((snippet (yas--lookup-snippet-1 name mode)))
|
||||
(cond
|
||||
(snippet (yas--template-content snippet))
|
||||
(noerror nil)
|
||||
|
Loading…
x
Reference in New Issue
Block a user