510 Commits

Author SHA1 Message Date
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
faed1062a2 * yasnippet.el (yas-key-syntaxes): Improve documentation. 2014-07-29 20:40:09 +01: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
e1ed662b7c Allow jit loading interactively
* yasnippet.el (yas-reload-all, yas-load-directory): let a prefix
  argument indicate jit loading.
2014-07-19 10:47:48 -04: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
4c16eaee0e Document uuid directive
* doc/snippet-development.org: Mention uuid in directive list.
* yasnippet.el (yas-define-snippets): Fix docstring grammar.
2014-05-11 12:47:15 -04:00
Noam Postavsky
8ced5c7f1d Remove type, expand-env from new snippet value
They are seldom used, and can cause errors if left in.

* yasnippet.el (yas-new-snippet-default): Remove type and expand-env
  directives.
2014-05-11 12:44:29 -04:00
Noam Postavsky
580e5c64f6 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.
2014-05-11 12:23:40 -04:00
Noam Postavsky
a80033d142 Refactor yas-good-grace error handling
* yasnippet.el
(yas--handle-error): New function.
(yas--eval-lisp-no-saves, yas--eval-lisp): Use it.
2014-05-10 23:04:13 -04:00
Noam Postavsky
599a2622c6 Closes #474: fix cc-mode fontification conflict
* yasnippet.el (yas--save-backquotes): don't change buffer while
narrowed.
2014-04-27 14:49:05 -04:00
Joao Tavora
8e7295b934 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.
2014-03-14 09:55:22 +00: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
d809e886e0 Revert "Closes #469: Don't use `yas--init-minor-keymap'"
This reverts commit 498cbe4138d74f39f7447acc9de456291c639724.
2014-03-13 20:23:05 +01:00
Joao Tavora
498cbe4138 Closes #469: Don't use `yas--init-minor-keymap'
* 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.
2014-03-13 19:04:05 +00:00
João Távora
e7599b9325 Merge pull request #466 from npostavs/no-reverse
Avoid double choices reversing
2014-03-06 08:05:53 +00:00
Noam Postavsky
43a501aa56 remove yas--x-pretty-prompt-templates 2014-03-05 22:38:46 -05:00
Noam Postavsky
c07db054ec yas-x-prompt: remove dead code 2014-03-04 21:46:05 -05:00
Noam Postavsky
4470110384 display-fn isn't actually used for filtering 2014-03-03 18:30:48 -05:00
Joao Tavora
4d220f726a Remove an obsolete hack notice
* yasnippet.el (yas-x-prompt): Remove hack notice.
2014-03-03 08:53:20 +00:00
Noam Postavsky
3744f92ad2 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.
2014-03-02 11:18:54 -05:00
Raimon Grau
c128580598 yasnippet templates don't add newlines 2014-02-27 12:34:55 +01:00
Joao Tavora
0f8c2ab438 Add yas-after-reload-hook' and run it at the end of yas-reload-all'
See https://github.com/pezra/rspec-mode/pull/75 for the discussion leading up to
this change.
2014-01-06 18:09:51 +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
c18672a227 Closes #447: only call command beyond yasnippet if it exists 2013-12-24 09:43:56 +00:00
João Távora
0567c931f4 Merge pull request #442 from npostavs/auto-export
populate yas--exported-syms based on sym prefix
2013-12-23 02:44:24 -08:00
dongxiong
90e7595c74 yas-text export twice
Something different between line 4521 and line 4528? I am not sure about this.
2013-12-20 13:06:37 +08:00
Noam Postavsky
6c752a1572 populate yas--exported-syms based on sym prefix
Rename what was formerly yas--exported-syms to yas--backported-syms,
and remove yas--dont-backport.
2013-12-12 23:19:21 -05: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
Noam Postavsky
a9e303525c docstring fixes
yas--prompt-function -> yas-prompt-functions
yas-fallback-behaviour -> yas-fallback-behavior
2013-11-28 23:35:32 -05:00
Noam Postavsky
eaa3141402 fix docstring extraction for "fancy" docs
The docstrings for yas-expand and yas-expand-from-keymap are generated
on the fly, depending on how they are called ("context"). Add a context
argument to the synthesizing functions and pass it nil when extracting
docstrings for the manual.
2013-11-27 21:34:29 -05: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
Noam Postavsky
d7b2b89eaa widen before deleting regions
This avoid problems with c-mode's after change hooks.
2013-10-30 18:25:51 -04: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
33dff9ad12 let C-c C-c save existing snippets too 2013-10-26 14:40:50 -04:00
Noam Postavsky
205b0e6970 move snippet saving from loading to closing
yas-load-snippet-buffer now just loads the snippet,
yas-load-snippet-buffer-and-close also saves it.
2013-10-26 13:42:32 -04:00
Noam Postavsky
ffd497d541 don't kill snippet buffer unless saved
Split the quit-window part of yas-load-snippet-buffer into
yas-load-snippet-buffer-and-close, and only quit if the snippet was
saved.

This resolves #417, where you could lose a snippet by giving the wrong
answer in a prompt.
2013-10-26 12:11:04 -04:00
Joao Tavora
32ee5cbde5 Closes #415: remove c-specific hacks, harmful on emacs 24.3 2013-10-21 09:28:44 +01:00
João Távora
6c3e0294dd Merge pull request #412 from npostavs/less-narrow
Wait till after content insertion to narrow
2013-10-14 09:28:42 -07:00
João Távora
3bb1515046 Merge pull request #409 from npostavs/font-lock
Fix yas--font-lock-keywords
2013-10-14 08:46:18 -07:00
Noam Postavsky
51e9e8e53c wait till after content insertion to narrow
Fixes #404 without inhibiting change hooks.
2013-10-14 10:00:45 -04:00
Noam Postavsky
6997922011 Revert "inhibit change hooks during (insert content)"
This reverts commit 90d4cae1b1bbfacc612e73444f1e5a723ae4036e.
2013-10-14 09:57:11 -04:00
Joao Tavora
7849ffcec5 fix: don't use universal-argument-num-events 2013-10-14 10:26:34 +01:00
Noam Postavsky
90d4cae1b1 inhibit change hooks during (insert content)
`yas-expand-snippet' narrows to a 0 size region before doing (insert
content), this confuses cc-mode's before-change-functions that
invalidate some cached information. Binding `inhibit-modification-hooks'
to `t' prevents calling these functions.

Fixes #404.
2013-10-14 01:05:29 -04:00
Noam Postavsky
f21ddd1b2e remove redundant font-lock-keywords
`lisp-font-lock-keywords' is identical to `lisp-font-lock-keywords1',
`lisp-font-lock-keywords2' is a superset of `lisp-font-lock-keywords1'.
2013-10-13 18:00:00 -04:00
Noam Postavsky
79f3656b3e fix font-lock-keywords syntax
The syntax is (MATCHER . FACENAME) (note the dot).
2013-10-13 17:55:58 -04:00
João Távora
d963c41a14 Closes #406: correct docstring for yas-extra-modes 2013-10-10 00:02:39 +01:00
João Távora
3ec62aba0d fix: please older emacsen, don't use LETREC after all
also fix some compiler warnings
2013-09-07 18:55:37 +01:00
João Távora
78c52fdf5c fix: shoosh warning with LETREC instead of LET 2013-09-02 12:01:24 +01:00