64 Commits

Author SHA1 Message Date
Noam Postavsky
041821a210 * yasnippet-tests.el (string-suffix-p): Define for older Emacsen. 2015-09-05 16:20:04 -04:00
Noam Postavsky
e3f03cabe0 Test visiting compiled snippets
* 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.
2015-09-05 15:42:32 -04:00
Noam Postavsky
7bce1a6473 Add new function yas-lookup-snippet
* yasnippet.el (yas-lookup-snippet): New function.
(yas--get-snippet-tables, yas--modes-to-activate): Add optional mode
parameter.
* yasnippet-tests.el (snippet-lookup): New test for yas-lookup-snippet.
* doc/snippet-expansion.org (Expanding from emacs-lisp code): Mention
  yas-lookup-snippet.
2015-08-03 10:36:46 -04:00
João Távora
a46701966a `yas-minor-mode' assertion broke a test. Good. Fix it.
* yasnippet-tests.el
(be-careful-when-escaping-in-yas-selected-text-2): Add
`yas-minor-mode'.
2015-03-23 10:21:26 +00:00
João Távora
316435e03e Closes #562: Deleting inner numberless snippet causes error
* yasnippet.el (yas--field-probably-deleted-p): Protect against
nil `yas--field-number'.

* yasnippet-tests.el (delete-numberless-inner-snippet-issue-562): New test
2015-03-23 10:11:06 +00:00
Jonas Bernoulli
70de82164c enforce use of spaces for indentation 2014-09-07 14:20:07 +02:00
Jonas Bernoulli
241465cea2 move eof footer to the actual eof 2014-09-07 14:20:07 +02:00
João Távora
1d4618b022 Closes #504: Correctly discover buffers needing snippets immediately
* 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'.
2014-08-20 21:29:32 +01:00
Noam Postavsky
d982b701fc Fix edge case in yas-longest-key-from-whitespace
* 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.
2014-08-10 14:05:26 -04:00
Noam Postavsky
5d10b5dfee Add yas-longest-key-from-whitespace
Example yas-key-syntaxes function.

* yasnippet.el (yas-longest-key-from-whitespace): new function.
* yasnippet-tests.el (complicated-yas-key-syntaxes): test it.
2014-08-10 14:05:25 -04:00
Noam Postavsky
10ecde158e 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.
2014-08-10 14:05:25 -04:00
Noam Postavsky
280ece2af4 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.
2014-08-10 14:05:25 -04:00
Noam Postavsky
de34d91a3c 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.
2014-08-10 14:05:01 -04:00
João Távora
7761deeeb5 Closes #497: Allow functions as elements in yas-key-syntaxes
* yasnippet.el (yas--templates-for-key-at-point): Renamed from
`yas--current-key'.
(yas-key-syntaxes): Overhaul documentation.
(yas-expand-from-trigger-key): Use
`yas--templates-for-key-at-point'.

* yasnippet-tests.el (complicated-yas-key-syntaxes): New test.
(yas-should-expand, yas-should-not-expand): Friendlier failure
message.
2014-07-29 01:19:58 +01:00
João Távora
0b7b34a333 Closes #492, closes #494: Consider defalias when calculating parent modes
* 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.
2014-07-28 23:23:04 +01:00
Noam Postavsky
763f5faa14 Closes #474: fix more cc-mode font-lock conflicts
* 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.
2014-05-14 19:49:11 -04:00
Noam Postavsky
4473b4ede5 New test for cc-mode's fontification functions
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
2014-04-27 14:49:02 -04:00
João Távora
b36a4f7449 Properly closes #469: Don't use `yas--init-minor-keymap'
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.
2014-03-13 20:29:06 +00:00
Joao Tavora
12b7f82dd8 Add Travis CI and update tests. Start a Changelog.
* .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.
2013-12-31 15:58:21 +00:00
Joao Tavora
7d4e4aa34c Closes #440: don't use make-variable-buffer-local' for yas--extra-modes' 2013-12-03 15:20:53 +00:00
João Távora
0f67c07ddd Merge pull request #424 from ljos/de/activate-extra-mode
Feature: de/activate-extra-mode
2013-10-31 06:28:26 -07:00
Joao Tavora
43a484e943 add: external test for issue #404 2013-10-31 13:03:32 +01:00
Bjarte Johansen
d5d6e456bf Feature: de/activate-extra-mode
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.
2013-10-27 20:38:12 +01:00
Noam Postavsky
5c76a0fda2 test middle-of-buffer snippet insertion 2013-10-14 11:48:04 -04:00
Joao Tavora
6268cc26b3 add: test for issue #404 2013-10-14 10:25:38 +01:00
João Távora
a7d40ed14a Closes #318: correctly implement YAS--MODES-TO-ACTIVATE
- simpler and got rid of YAS--ALL-PARENTS
- also got rid of YAS/MODE-SYMBOL backward compatibility hack
2013-08-31 23:48:19 +01:00
João Távora
ddaf9a9f5c Fix: cleanup yasnippet-tests.el
- add edebug-form-specs
- replace "yas/" with "yas-"
- yas/ert => yas-batch-run-tests
2013-08-31 23:48:00 +01:00
Joao Tavora
13d87aa3c0 fix: more idiomatic elisp, better docstrings, less byte-compiler warnings
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)."
2013-08-29 10:20:31 +01:00
Joao Tavora
9df05fc413 Minor: indenting in for yasnippet-tests.el macro 2013-05-05 20:42:33 -04:00
Joao Tavora
0da56720a8 Closes #318: now checks for circular parenthood in snippet dirs 2013-05-05 20:42:33 -04:00
João Távora
35493b8f06 Fix: enclose this test in WITH-TEMP-BUFFER 2012-12-25 04:30:26 +00:00
João Távora
74e8f43f06 Closes #351: sort mirrors by nesting depth when updating 2012-12-25 04:30:19 +00:00
João Távora
810de9a4b0 Add: unit test for YAS-MINOR-MODE-MAP rebindings 2012-12-24 01:45:59 +00:00
João Távora
e5c41c78d2 Fix: tests also use YAS--WITH-TEMPORARY-REDEFINITIONS to make stubs 2012-12-24 01:35:05 +00:00
João Távora
cfefaca284 Fix: cleanup after #333 fix, use 'cl-flet' 2012-11-17 16:38:11 +00:00
Joao Tavora
0778a1b61b Fix: Closes #330 2012-11-16 15:15:24 +00:00
João Távora
185c771ded Closes #253. 2012-11-06 16:28:16 +00:00
João Távora
cd70010b83 Closes #296: No longer use customizable yas-trigger-key and friends.
Use keymaps that the user can customise with `define-key` like all the
other modes
2012-11-06 14:12:18 +00:00
João Távora
f836621480 Fix: correct expectation for this test in batch-mode 2012-11-06 14:09:51 +00:00
João Távora
1774d7cbd0 Add: easier to run tests 2012-11-06 13:27:37 +00:00
João Távora
9503c332f5 Closes #290: problem when advancing the start of a mirror-in-field
* Rewrote 'yas--update-mirrors'
* Added unit test
* Advancing is done exceptionally in 'yas--update-mirrors'
  not 'yas--mirror-update-display' and just before we need to
  re-update the mirror-in-field.
* Alternative to prior point would be to have fields carry a reference
  to their child mirrors.
2012-08-22 00:52:17 +01:00
João Távora
7981f8d63b Closes #281: jit-load in reverse order to maintain coherence with yas-snippet-dirs 2012-08-15 15:38:10 +01:00
Joao Tavora
951fb3cbe7 Fix: recursive delete-directory does not exist in Emacs 23 2012-08-07 12:07:32 +01:00
Joao Tavora
38093c1a9e Fix: default value for yas-trigger-key is not "<tab>" not "TAB"
After some exploration, this seems to be the more correct default.
Corrected test that checks for correct binding in org-mode, pass in emacs23 and emacs24
2012-08-07 12:06:53 +01:00
João Távora
32c65dff47 Enhancement: add some keybinding tests 2012-08-06 09:10:54 +01:00
João Távora
fd282faaa7 Cleanup: remove unneeded test and reorganize 2012-08-05 22:32:31 +01:00
Joao Tavora
c967f74847 Closes #271: 4th try, with backquote, need protection before collection
* Add one more test, probably will need even more.
2012-08-03 18:36:29 +01:00
Joao Tavora
197104b450 Closes #271: 3rd try, protect escapes after collecting backquote elisp
* Add more tests
* Now only need to escape backslashes in mirror/field
  transformations
2012-08-03 11:03:11 +01:00
Joao Tavora
6aff6a0894 Closes #271: 2nd try, remove unescaping of backquote replacements
* Fixes previous fix (big blunder, expansion unusable)
* Added more tests
* Fixed previously broken tests.
2012-08-02 16:48:13 +01:00
João Távora
f35d2dba11 Closes #271: save backquoted elisp and re-insert at end of expansion 2012-08-01 23:38:19 +01:00