mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-14 05:23:04 +00:00
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.
This commit is contained in:
parent
de34d91a3c
commit
280ece2af4
@ -346,7 +346,10 @@ TODO: correct this bug!"
|
|||||||
(yas-should-expand '(("foo-barbaz" . "foo-barOKbazOK")))))
|
(yas-should-expand '(("foo-barbaz" . "foo-barOKbazOK")))))
|
||||||
(let ((yas-key-syntaxes '(yas-try-key-from-whitespace)))
|
(let ((yas-key-syntaxes '(yas-try-key-from-whitespace)))
|
||||||
(yas-should-expand '(("xxx\n'quote" . "xxx\nOKquoteOK")
|
(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
|
;;; Loading
|
||||||
|
@ -2737,6 +2737,15 @@ marks it as something else (typically comment ender). Use as
|
|||||||
element of `yas-key-syntaxes'."
|
element of `yas-key-syntaxes'."
|
||||||
(skip-chars-backward "^[:space:]\n"))
|
(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
|
;;; User convenience functions, for using in snippet definitions
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user