João Távora [Mon, 23 Mar 2015 10:10:56 +0000 (10:10 +0000)]
Add useful development assertion
When debugging snippets after M-x toggle-debug-on-error, errors in the
`post-command-hook' might cause `yas--post-command-handler' to be
removed. That's OK, always check that it's there before attempting any
`yas-expand-snippet' calls, since it is essential to check snippet
movement.
* yasnippet.el (yas-expand-snippet): Assert `yas-minor-mode' and
`yas--post-command-handler' active.
Stefan Monnier [Fri, 20 Mar 2015 10:34:33 +0000 (10:34 +0000)]
Getting rid of low-level assumptions in yasnippet
The main thrust is to get rid of the use of the `cl-struct-slots'
property which doesn't exist in Emacs-25 any more.
* yasnippet.el: Update copyright
(yas--template): Change constructor name from
`yas--make-blank-template' to `yas--make-template'
(yas--populate-template): Remove.
(yas--define-snippets-1): Use `yas--make-template'
(yas--define-snippets-1): Use `setf's
(yas-define-menu, yas--define-menu-1, yas-tryout-snippet): Use
`yas--make-template'
Noam Postavsky [Sun, 5 Oct 2014 00:52:58 +0000 (20:52 -0400)]
Signal an error on recursive yas--fallback calls
* yasnippet.el (yas--fallback): let-bind yas-fallback-behavior to
'yas--fallback before actually doing the fallback. Signal an error if
it's 'yas--fallback (indicating we're in an infinte loop).
João Távora [Wed, 20 Aug 2014 20:48:41 +0000 (21:48 +0100)]
Closes #495: Allow symbols as aliases in `yas-snippet-dirs'
* yasnippet.el (yas-installed-snippets-dir): New parameter. Set at
load time from `load-file-name'.
(yas--load-file-name): Removed.
(yas-snippet-dirs): Update docstring. Default value has symbol
`yas-installed-snippets-dir' as an alias to any bundled snippets.
(yas-snippet-dirs): Redesign for new `yas-snippet-dirs' semantics.
João Távora [Wed, 20 Aug 2014 19:23:00 +0000 (20:23 +0100)]
Prevent disabling errors from recent `yas-current-syntaxes` logic
* yasnippet.el (yas--templates-for-key-at-point): Don't error
since this function is called very frequently on TAB. Use new
`yas--warning'.
(yas--warning): New function.
Noam Postavsky [Sun, 10 Aug 2014 17:29:25 +0000 (13:29 -0400)]
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.
Noam Postavsky [Sun, 10 Aug 2014 16:21:47 +0000 (12:21 -0400)]
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.
Noam Postavsky [Wed, 14 May 2014 23:49:11 +0000 (19:49 -0400)]
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.
Noam Postavsky [Sat, 10 May 2014 23:01:32 +0000 (19:01 -0400)]
Don't lose error message when yas-good-grace is t
* yasnippet.el
(yas--eval-lisp-no-saves): Pass error message to message function.
(yas--handle-error): Pass "%s" to error to avoid accidentally
interpreting % in the error message as format codes.
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
Joao Tavora [Fri, 14 Mar 2014 09:55:22 +0000 (09:55 +0000)]
Closes #403: more uniform behaviour for `yas-use-menu'
Suggested by Noam Postavsky, this uses the :visible arg to
`easy-menu-define' to hide the whole "YASnippet" menu according to the
run-time value of `yas-use-menu'. Previously, only the load-time value
was considered and some functions we're noops when `yas-use-menu' was
nil.
The per-mode snippet submenus are now always updated even if
`yas-use-menu' is nil, although they won't be shown until it becomes
non-nil.
* yasnippet.el (yas--minor-mode-menu): Use :visible arg and eval `yas-use-menu'
(yas--update-template): Always update the menu.
(yas--show-menu-p): Always return t if `yas-use-menu' is non-nil and not `abbreviate'
(yas-define-menu): Always define a menu.
(yas-use-menu): Update docstring.
Joao Tavora [Mon, 3 Mar 2014 08:53:04 +0000 (08:53 +0000)]
Remove experimental Changelog file
The Changelog format is good but having a file for it is not. The same
format can be had in messages by having using vc-dir and C-x 4 a. A
temporary dummy changelog appears and that content goes to the git log
message, which is just as good in content and much better in form.
Noam Postavsky [Sun, 2 Mar 2014 16:18:54 +0000 (11:18 -0500)]
avoid double choices reversing
Both yas-choose-value the yas-prompt-functions were reversing
values (cancelling each other out), instead just keep the choices in
order the whole time.
Joao Tavora [Tue, 31 Dec 2013 15:33:20 +0000 (15:33 +0000)]
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.