[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master de34d91 130/177: Closes #470, handle non-whitespace newlin
From: |
Jo�o T�vora |
Subject: |
[elpa] master de34d91 130/177: Closes #470, handle non-whitespace newlines |
Date: |
Sat, 28 Mar 2015 15:41:25 +0000 |
branch: master
commit de34d91a3c149993526370f98cf36eb6da565976
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Closes #470, handle non-whitespace newlines
Many modes put newlines in comment ender class because they have line
comments.
* yasnippet.el (yas-try-key-from-whitespace): new function.
(yas-key-syntaxes): use it in place of "^ ".
* yasnippet-tests.el (complicated-yas-key-syntaxes): test it.
---
yasnippet-tests.el | 12 ++++++++----
yasnippet.el | 14 +++++++++++++-
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index f40ed25..ae7a8d1 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -322,12 +322,13 @@ TODO: correct this bug!"
(yas-saving-variables
(yas-with-snippet-dirs
'((".emacs.d/snippets"
- ("text-mode"
+ ("emacs-lisp-mode"
("foo-barbaz" . "# condition: yas--foobarbaz\n# --\nOKfoo-barbazOK")
("barbaz" . "# condition: yas--barbaz\n# --\nOKbarbazOK")
- ("baz" . "OKbazOK"))))
+ ("baz" . "OKbazOK")
+ ("'quote" . "OKquoteOK"))))
(yas-reload-all)
- (text-mode)
+ (emacs-lisp-mode)
(yas-minor-mode-on)
(let ((yas-key-syntaxes '("w" "w_")))
(let ((yas--barbaz t))
@@ -342,7 +343,10 @@ TODO: correct this bug!"
'again))
yas-key-syntaxes))
(yas--foobarbaz t))
- (yas-should-expand '(("foo-barbaz" . "foo-barOKbazOK")))))))))
+ (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"))))))))
;;; Loading
diff --git a/yasnippet.el b/yasnippet.el
index fc5d36b..741ab61 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -388,7 +388,8 @@ the trigger key itself."
map)
"The active keymap while a snippet expansion is in progress.")
-(defvar yas-key-syntaxes (list "w" "w_" "w_." "w_.()" "^ ")
+(defvar yas-key-syntaxes (list "w" "w_" "w_." "w_.()"
+ #'yas-try-key-from-whitespace)
"Syntaxes and functions to help look for trigger keys before point.
Each element in this list specifies how to skip buffer positions
@@ -2726,6 +2727,17 @@ and `kill-buffer' instead."
+;;; User convenience functions, for using in `yas-key-syntaxes'
+
+(defun yas-try-key-from-whitespace ()
+ "Go back to nearest 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'."
+ (skip-chars-backward "^[:space:]\n"))
+
+
;;; User convenience functions, for using in snippet definitions
(defvar yas-modified-p nil
- [elpa] master fe288a1 121/177: Fix publishing with org 7.9, (continued)
- [elpa] master fe288a1 121/177: Fix publishing with org 7.9, Jo�o T�vora, 2015/03/28
- [elpa] master e1ed662 125/177: Allow jit loading interactively, Jo�o T�vora, 2015/03/28
- [elpa] master e53ec1e 124/177: Make snippets submodule track master, update it, Jo�o T�vora, 2015/03/28
- [elpa] master f98c527 123/177: Replace text -> yas-text in documentation, Jo�o T�vora, 2015/03/28
- [elpa] master 763f5fa 122/177: Closes #474: fix more cc-mode font-lock conflicts, Jo�o T�vora, 2015/03/28
- [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 <=
- [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, 2015/03/28
- [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