[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5d10b5d 133/177: Add yas-longest-key-from-whitespace
From: |
João Távora |
Subject: |
[elpa] master 5d10b5d 133/177: Add yas-longest-key-from-whitespace |
Date: |
Sat, 28 Mar 2015 15:41:26 +0000 |
branch: master
commit 5d10b5dfee3ee3d1c5c199e8c9acfb9c9b26172c
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Add yas-longest-key-from-whitespace
Example yas-key-syntaxes function.
* yasnippet.el (yas-longest-key-from-whitespace): new function.
* yasnippet-tests.el (complicated-yas-key-syntaxes): test it.
---
yasnippet-tests.el | 4 +++-
yasnippet.el | 13 +++++++++++++
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index 12ca615..d090c51 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -349,7 +349,9 @@ TODO: correct this bug!"
("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"))))))))
+ (yas-should-expand '(("foo-barbaz" . "foo-barOKbazOK")))
+ (setq yas-key-syntaxes '(yas-longest-key-from-whitespace))
+ (yas-should-expand '(("foo-barbaz" . "OKfoo-barbazOK"))))))))
;;; Loading
diff --git a/yasnippet.el b/yasnippet.el
index 93eceb2..dcf6bf0 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -2746,6 +2746,19 @@ element of `yas-key-syntaxes'."
(when (/= (skip-chars-backward "^[:space:]\n" (1- (point))) 0)
'again))
+(defun yas-longest-key-from-whitespace (start-point)
+ "Go back to nearest whitespace, then go forward and return `again' until at
START-POINT.
+
+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'."
+ (if (= (point) start-point)
+ (yas-try-key-from-whitespace start-point)
+ (forward-char))
+ (unless (= original (1+ (point)))
+ 'again))
+
+
;;; User convenience functions, for using in snippet definitions
- [elpa] master 2b24aea 126/177: Merge pull request #493 from npostavs/ijit, (continued)
- [elpa] master 2b24aea 126/177: Merge pull request #493 from npostavs/ijit, João Távora, 2015/03/28
- [elpa] master 280ece2 131/177: Add yas-shortest-key-until-whitespace, João Távora, 2015/03/28
- [elpa] master 0b7b34a 127/177: Closes #492, closes #494: Consider defalias when calculating parent modes, João Távora, 2015/03/28
- [elpa] master 7761dee 128/177: Closes #497: Allow functions as elements in yas-key-syntaxes, João Távora, 2015/03/28
- [elpa] master faed106 129/177: * yasnippet.el (yas-key-syntaxes): Improve documentation., João Távora, 2015/03/28
- [elpa] master de34d91 130/177: Closes #470, handle non-whitespace newlines, João Távora, 2015/03/28
- [elpa] master 6b04dad 120/177: Document type directive, João Távora, 2015/03/28
- [elpa] master 10ecde1 132/177: Pass start point to yas-key-syntaxes functions, João Távora, 2015/03/28
- [elpa] master 47a3d5f 134/177: Fix yas-key-syntaxes example functions docstrings., João Távora, 2015/03/28
- [elpa] master d982b70 135/177: Fix edge case in yas-longest-key-from-whitespace, João Távora, 2015/03/28
- [elpa] master 5d10b5d 133/177: Add yas-longest-key-from-whitespace,
João Távora <=
- [elpa] master f7ef023 137/177: Prevent disabling errors from recent `yas-current-syntaxes` logic, João Távora, 2015/03/28
- [elpa] master 1d4618b 138/177: Closes #504: Correctly discover buffers needing snippets immediately, João Távora, 2015/03/28
- [elpa] master e60e8b5 136/177: Merge pull request #503 from npostavs/key-syntaxes, João Távora, 2015/03/28
- [elpa] master 5b59b80 139/177: Closes #495: Allow symbols as aliases in `yas-snippet-dirs', João Távora, 2015/03/28
- [elpa] master be2f815 140/177: Closes #508: Ensure original point when evaluating conditions, João Távora, 2015/03/28
- [elpa] master 241465c 141/177: move eof footer to the actual eof, João Távora, 2015/03/28
- [elpa] master 70de821 143/177: enforce use of spaces for indentation, João Távora, 2015/03/28
- [elpa] master 41cb5f5 145/177: Update snippets submodule, João Távora, 2015/03/28
- [elpa] master cc64ff6 144/177: Merge pull request #514 from tarsius/master, João Távora, 2015/03/28
- [elpa] master 8e9bf3c 147/177: Merge pull request #518 from rnkn/master, João Távora, 2015/03/28