emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master e3f03ca 21/60: Test visiting compiled snippets


From: João Távora
Subject: [elpa] master e3f03ca 21/60: Test visiting compiled snippets
Date: Thu, 21 Jan 2016 22:35:55 +0000

branch: master
commit e3f03cabe01c3d218bc921b90f8946d5621efb8c
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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.
---
 yasnippet-tests.el |   16 +++++++++++++++-
 yasnippet.el       |   14 +++++++++-----
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 0b14a56..a59cdf7 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -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
diff --git a/yasnippet.el b/yasnippet.el
index 1fd08e2..ff46811 100644
--- a/yasnippet.el
+++ b/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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]