mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 21:13:04 +00:00
Pass start point to yas-key-syntaxes functions
* yasnippet-tests.el (complicated-yas-key-syntaxes): accept argument. * yasnippet.el (yas-try-key-from-whitespace): accept argument. (yas-shortest-key-until-whitespace): accept argument. (yas--templates-for-key-at-point): pass start point the methods. (yas-key-syntaxes): update docstring.
This commit is contained in:
parent
280ece2af4
commit
10ecde158e
@ -337,7 +337,7 @@ TODO: correct this bug!"
|
|||||||
(let ((yas--foobarbaz t))
|
(let ((yas--foobarbaz t))
|
||||||
(yas-should-expand '(("foo-barbaz" . "OKfoo-barbazOK"))))
|
(yas-should-expand '(("foo-barbaz" . "OKfoo-barbazOK"))))
|
||||||
(let ((yas-key-syntaxes
|
(let ((yas-key-syntaxes
|
||||||
(cons #'(lambda ()
|
(cons #'(lambda (_start-point)
|
||||||
(unless (looking-back "-")
|
(unless (looking-back "-")
|
||||||
(backward-char)
|
(backward-char)
|
||||||
'again))
|
'again))
|
||||||
|
18
yasnippet.el
18
yasnippet.el
@ -395,15 +395,15 @@ the trigger key itself."
|
|||||||
Each element in this list specifies how to skip buffer positions
|
Each element in this list specifies how to skip buffer positions
|
||||||
backwards and look for the start of a trigger key.
|
backwards and look for the start of a trigger key.
|
||||||
|
|
||||||
Each element can be either a string or a functino of no
|
Each element can be either a string or a function receiving the
|
||||||
arguments. A string element is simply passed to
|
original point as an argument. A string element is simply passed
|
||||||
`skip-syntax-backward' whereas a function element is called with
|
to `skip-syntax-backward' whereas a function element is called
|
||||||
no arguments and should also place point before the original
|
with no arguments and should also place point before the original
|
||||||
position.
|
position.
|
||||||
|
|
||||||
The string between the resulting buffer position and the original
|
The string between the resulting buffer position and the original
|
||||||
point.in the is matched against the trigger keys in the active
|
point is matched against the trigger keys in the active snippet
|
||||||
snippet tables.
|
tables.
|
||||||
|
|
||||||
If no expandable snippets are found, the next element is the list
|
If no expandable snippets are found, the next element is the list
|
||||||
is tried, unless a function element returned the symbol `again',
|
is tried, unless a function element returned the symbol `again',
|
||||||
@ -1239,7 +1239,7 @@ Returns (TEMPLATES START END). This function respects
|
|||||||
(skip-syntax-backward method)
|
(skip-syntax-backward method)
|
||||||
(setq methods (cdr methods)))
|
(setq methods (cdr methods)))
|
||||||
((functionp method)
|
((functionp method)
|
||||||
(unless (eq (funcall method)
|
(unless (eq (funcall method original)
|
||||||
'again)
|
'again)
|
||||||
(setq methods (cdr methods))))
|
(setq methods (cdr methods))))
|
||||||
(t
|
(t
|
||||||
@ -2729,7 +2729,7 @@ and `kill-buffer' instead."
|
|||||||
|
|
||||||
;;; User convenience functions, for using in `yas-key-syntaxes'
|
;;; User convenience functions, for using in `yas-key-syntaxes'
|
||||||
|
|
||||||
(defun yas-try-key-from-whitespace ()
|
(defun yas-try-key-from-whitespace (_start-point)
|
||||||
"Go back to nearest whitespace.
|
"Go back to nearest whitespace.
|
||||||
|
|
||||||
A newline will be considered whitespace even if the mode syntax
|
A newline will be considered whitespace even if the mode syntax
|
||||||
@ -2737,7 +2737,7 @@ 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 ()
|
(defun yas-shortest-key-until-whitespace (_start-point)
|
||||||
"Return `again' until at whitespace.
|
"Return `again' until at whitespace.
|
||||||
|
|
||||||
A newline will be considered whitespace even if the mode syntax
|
A newline will be considered whitespace even if the mode syntax
|
||||||
|
Loading…
x
Reference in New Issue
Block a user