branch: master commit 10ecde158e5efae11186aa4c261aaec6261e8e51 Author: Noam Postavsky <npost...@users.sourceforge.net> Commit: Noam Postavsky <npost...@users.sourceforge.net>
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. --- yasnippet-tests.el | 2 +- yasnippet.el | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/yasnippet-tests.el b/yasnippet-tests.el index 8a845dc..12ca615 100644 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -337,7 +337,7 @@ TODO: correct this bug!" (let ((yas--foobarbaz t)) (yas-should-expand '(("foo-barbaz" . "OKfoo-barbazOK")))) (let ((yas-key-syntaxes - (cons #'(lambda () + (cons #'(lambda (_start-point) (unless (looking-back "-") (backward-char) 'again)) diff --git a/yasnippet.el b/yasnippet.el index e006d52..93eceb2 100644 --- a/yasnippet.el +++ b/yasnippet.el @@ -395,15 +395,15 @@ the trigger key itself." Each element in this list specifies how to skip buffer positions backwards and look for the start of a trigger key. -Each element can be either a string or a functino of no -arguments. A string element is simply passed to -`skip-syntax-backward' whereas a function element is called with -no arguments and should also place point before the original +Each element can be either a string or a function receiving the +original point as an argument. A string element is simply passed +to `skip-syntax-backward' whereas a function element is called +with no arguments and should also place point before the original position. The string between the resulting buffer position and the original -point.in the is matched against the trigger keys in the active -snippet tables. +point is matched against the trigger keys in the active snippet +tables. If no expandable snippets are found, the next element is the list 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) (setq methods (cdr methods))) ((functionp method) - (unless (eq (funcall method) + (unless (eq (funcall method original) 'again) (setq methods (cdr methods)))) (t @@ -2729,7 +2729,7 @@ and `kill-buffer' instead." ;;; 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. 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'." (skip-chars-backward "^[:space:]\n")) -(defun yas-shortest-key-until-whitespace () +(defun yas-shortest-key-until-whitespace (_start-point) "Return `again' until at whitespace. A newline will be considered whitespace even if the mode syntax