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

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

[elpa] master 280ece2 131/177: Add yas-shortest-key-until-whitespace


From: João Távora
Subject: [elpa] master 280ece2 131/177: Add yas-shortest-key-until-whitespace
Date: Sat, 28 Mar 2015 15:41:25 +0000

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

    Add yas-shortest-key-until-whitespace
    
    Example yas-key-syntaxes function.
    
    * yasnippet.el (yas-shortest-key-until-whitespace): new function.
    * yasnippet-tests.el (complicated-yas-key-syntaxes): test it.
---
 yasnippet-tests.el |    5 ++++-
 yasnippet.el       |    9 +++++++++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index ae7a8d1..8a845dc 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -346,7 +346,10 @@ TODO: correct this bug!"
            (yas-should-expand '(("foo-barbaz" . "foo-barOKbazOK")))))
        (let ((yas-key-syntaxes '(yas-try-key-from-whitespace)))
          (yas-should-expand '(("xxx\n'quote" . "xxx\nOKquoteOK")
-                              ("xxx 'quote" . "xxx OKquoteOK"))))))))
+                              ("xxx 'quote" . "xxx OKquoteOK"))))
+       (let ((yas-key-syntaxes '(yas-shortest-key-until-whitespace))
+             (yas--foobarbaz t) (yas--barbaz t))
+         (yas-should-expand '(("foo-barbaz" . "foo-barOKbazOK"))))))))
 
 
 ;;; Loading
diff --git a/yasnippet.el b/yasnippet.el
index 741ab61..e006d52 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -2737,6 +2737,15 @@ marks it as something else (typically comment ender). 
Use as
 element of `yas-key-syntaxes'."
   (skip-chars-backward "^[:space:]\n"))
 
+(defun yas-shortest-key-until-whitespace ()
+  "Return `again' until at whitespace.
+
+A newline will be considered whitespace even if the mode syntax
+marks it as something else (typically comment ender). Use as
+element of `yas-key-syntaxes'."
+  (when (/= (skip-chars-backward "^[:space:]\n" (1- (point))) 0)
+    'again))
+
 
 ;;; User convenience functions, for using in snippet definitions
 



reply via email to

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