* yasnippet-tests.el (complicated-yas-key-syntaxes): Avoid looking-back.
* yasnippet.el (yas--font-lock-keywords): Escape $, even if first in the
regexp.
(yas--indent): Remove unused var `end'.
(yas--indent-parse-create): Remove unused arg `snippet'. Update caller.
* doc/snippet-development.org: New "Indentation markers" section.
* yasnippet-tests.el (indentation-markers): New test.
* yasnippet.el (yas--indent-markers): New variable.
(yas--indent): Use it instead of searching for $> directly.
(yas--indent-parse-create): New function, records occurences of $> into
`yas--indent-markers'.
(yas--snippet-parse-create): Call it.
* yasnippet.el (yas--indent-region): Indent only non-empty lines.
* yasnippet-tests.el (basic-indentation): Add empy and non-empty (but
blank) lines in test snippet.
cc-mode fill paragraph narrows to the paragraph being filled. This
causes problems if there is a mirror needing to be updated outside of
the current paragraph.
* yasnippet-tests.el: New test.
* yasnippet.el (yas--update-mirrors): Widen while updating the mirrors.
While I agree with the solution for #515 in commit 17fe790 for now,
other approaches might be interesting in the future, like clearing on
other types of insertion, not just self-insertion.
So add some tests and refactor a new function that could be used for
that purpose later on. For now, change no behaviour.
* yasnippet-tests.el (dont-clear-on-partial-deletion-issue-515,
dont-clear-on-yank-issue-515): New tests. (yas-mock-yank): New
function.
* yasnippet.el (yas--skip-and-clear-field-p): New function.
(yas--on-field-overlay-modification): Use it.
* yasnippet-tests.el (yas-mock-insert): Use `ert-simulate-command' to
simulate n self-insert-commands.
(simple-mirror, mirror-with-transformation):
(primary-field-transformation, nested-placeholders-kill-superfield):
(nested-placeholders-use-subfield):
(mirrors-adjacent-to-fields-with-nested-mirrors):
(deep-nested-mirroring-issue-351, example-for-issue-271):
(string-match-with-subregexp-in-mirror-transformations): Call
`yas-mock-insert' directly instead of with `ert-simulate-command'.
Probably nobody wants a snippet `key` with a trailing space. It can
be hard to differentiate from a `key` without trailing space. The
default `<TAB>` behavior of yasnippet will never expand these.
* yasnippet.el (yas--parse-template): Ignore trailing spaces in snippet
definitions.
* yasnippet-tests.el (deftest ignore-trailing-whitespace): New test for
new behavior.
Copyright-paperwork-exempt: yes
This prevents snippets from a parent mode from overriding those of the
major-mode's (or yas--extra-modes). Snippets of ancestor modes may
still override snippets of some other ancestor modes, but hopefully this
won't cause much trouble in practice.
See [1] and subsequent comments.
[1]: https://github.com/capitaomorte/yasnippet/issues/619#issuecomment-149127150
* yasnippet.el (yas--modes-to-activate): Reverse result, so that parents
of yas--extra-modes and major are later in the list.
* yasnippet-tests.el (loading-with-cyclic-parenthood)
(extra-modes-parenthood): Test it.
Close#626.
* yasnippet-tests.el (extra-modes-parenthood): New (failing) test.
(loading-with-cyclic-parenthood): Use equal + sort instead of set
operation + length.
* yasnippet-tests.el (visiting-compiled-snippets): New Test.
* yasnippet.el (yas--lookup-snippet-1, yas-lookup-snippet): Split new
function yas--lookup-snippet-1 from yas-lookup-snippet.
* yasnippet.el (yas--field-probably-deleted-p): Protect against
nil `yas--field-number'.
* yasnippet-tests.el (delete-numberless-inner-snippet-issue-562): New test
* yasnippet-tests.el (issue-504-tricky-jit): New test.
* yasnippet.el (yas-load-directory): Use a new `impatient-buffers'
local and call `yas--load-pending-juts' in all those at the end.
* yasnippet.el (cl-lib): Don't need `eval-and-compile'.
* yasnippet.el (yas-longest-key-from-whitespace): don't try again if
start-point is on whitespace.
* yasnippet-tests.el (complicated-yas-key-syntaxes): check edge case.
Example yas-key-syntaxes function.
* yasnippet.el (yas-longest-key-from-whitespace): new function.
* yasnippet-tests.el (complicated-yas-key-syntaxes): test it.
Example yas-key-syntaxes function.
* yasnippet.el (yas-shortest-key-until-whitespace): new function.
* yasnippet-tests.el (complicated-yas-key-syntaxes): test it.
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 (issue-492-and-494): New test.
* yasnippet.el (yas--modes-to-activate): Consider each mode's
symbol-function as a neighbour in case it's a symbol as well.
* yasnippet-tests.el (example-for-issue-474): Don't call insert from
within backquotes, it's redundant and prevents proper testing of
backquote expansion.
* yasnippet.el (yas--restore-backquotes, yas--save-backquotes): Ensure
the buffer isn't narrowed while modifying it to avoid conflicting with
cc-mode fontification.
This issue requires font locking to trigger. This can be be done by
let-binding noninteractive to nil and using a buffer name that doesn't
start with a space, instead of the external emacs hack which is now
redundant.
* yasnippet-tests.el (yas--with-font-locked-temp-buffer): new macro
similar to with-temp-buffer but enables font-lock-mode even in -batch
mode.
(example-for-issue-474): new test
(example-for-issue-404, example-for-issue-404-c-mode): use new macro
(example-for-issue-404-external-emacs): removed
Previous reverted commit 498cbe4 forgot to take into account that one
of the tests used the `yas--init-minor-keymap' function that was
removed.
* yasnippet.el (yas-use-menu): Don't allow `nil' value, it's
useless.
(yas--minor-mode-menu): Use top-level `easy-menu-define' form.
(yas--init-minor-keymap): Remove definition.
* yasnippet-tests.el (test-rebindings): Don't use
`yas--init-minor-keymap'. Restore bindings explicitly. Not ideal,
but should work.
* .travis.yml: new file
* README.mdown: Add Travis CI badge.
* Rakefile: use ert-run-tests-batch-and-exit.
* yasnippet-tests.el (example-for-issue-404-external-emacs): Use
`yas-with-snippet-dirs' to not depend on bundled snippets.
(yas--call-with-temporary-redefinitions): Use `cl-labels' since no
cl-flet in emacs-24.3's cl-lib.el.
(loading-with-cyclic-parenthood): prog-mode doesn't exist in emacs
24.3.
(yas-batch-run-tests): remove it.
* yasnippet.el (require): require cl-lib during byte-compilation
and load.
Adds functionality to deactivate/activate extra modes. Two new functions
are added: `activate-extra-mode', `deactivate-extra-mode'. These two
functions activate and deactivate snippets for the given mode in the
current buffer. The use-case for the functions is to have a simple
interface for adding new snippets when activating a new minor mode.
The previous way of doing this, using `yas-extra-modes', is made
obsolete and the new deactivate/activate should be the preferred
instead. The reason for making `yas-extra-modes' obsolete is to keep a
simple interface.
See issue #420 for more information.
By Stefan Monnier, with original commentary.
"Here's an untested patch of cleanups, found partly via compilation using
lexical-binding and partly via checkdoc-current-buffer (and
occasionally by stumble-upon happenstance)."