748 Commits

Author SHA1 Message Date
Noam Postavsky
b6d924c83d * yasnippet.el (yas--scan-sexps): Use ignore-errors. 2015-10-11 21:17:50 -04:00
Noam Postavsky
fb6ec67228 Fix #619; find parents for extra-modes too
* yasnippet.el (yas--modes-to-activate): Call dfs on yas--extra-modes as
  well.
2015-10-11 13:09:00 -04:00
Noam Postavsky
e56aa6f7b3 Build a single `explored' list.
* yasnippet.el (yas--modes-to-activate): Make helper dfs function
  produce the list of modes only by updating a single `explored' list,
  instead of building up the list by value and having to remove
  duplicated after.
2015-10-11 13:08:59 -04:00
Noam Postavsky
8df6a6ed8e Fix invalid yas-key-syntaxes element warning
* yasnippet.el (yas--templates-for-key-at-point): Fix infinite loop and
  remove redundant "Warning" in the bad element warning.
2015-09-27 20:16:28 -04:00
Noam Postavsky
01139a2deb * yasnippet.el (yas--define-snippets-2): Use file-name-NONdirectory. 2015-09-12 16:30:01 -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
68b0ab66ca Accept documented snippet list formats
yas-define-snippets was making assumptions that happended to be true for
its current calls, but could fail if given differently formatted snippet
lists that still meet the docstring description.

* yasnippet.el (yas-define-snippets): Handle incomplete snippet lists.
2015-09-05 15:42:32 -04:00
Noam Postavsky
215ad9bcf2 Fix #597; use SAVE-FILE to visit compiled snippets
Rename the existing FILE field to LOAD-FILE, and add a new SAVE-FILE to
yas--template struct.  Normally they will be the same, but compiled
snippets have only SAVE-FILE because they are loaded by "compiled" code.

* yasnippet.el (yas--template): Remove field file, add load-file and
  save-file.
(yas--parse-template): Update snippet-definition list in docstrings.
(yas-define-snippets): Move LOAD-FILE value to SAVE-FILE when compiling.
(yas--template-get-file): New function.
(yas--visit-snippet-file-1, yas-load-snippet-buffer,
yas-load-snippet-buffer-and-close): Use yas--template-load-file,
yas--template-save-file, or yas--template-get-file, as appropriate.
* doc/snippet-organization.org (The =.yas-compiled-snippet.el= file):
  Remove caveat that is no longer relevant.
2015-09-05 15:41:05 -04:00
Noam Postavsky
cc1c758ab7 Reorganize snippet construction from list code
* yasnippet.el (yas--template): New yas--define-snippets-2 constructor
  with arguments matching yas-define-snippets format.
(yas--define-snippets-1): Use it.
(yas--update-template): Return TEMPLATE argument.
2015-09-04 18:33:44 -04:00
Noam Postavsky
c91a58840b Simplify some code
* yasnippet.el (yas-define-snippets): Modify the list instead of
  reconstructing it.
  (yas-load-snippet-buffer-and-close): Replace listp and second with
  cdr-safe.  Use string-prefix-p rather than string-match-p.
2015-08-04 14:20:29 -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
5aebe46e5c Closes #549: Adjust load' verbosity to yas-verbosity'
* yasnippet.el (yas--load-yas-setup-file): Be verbose on `load'
according to `yas-verbosity'
2015-04-15 10:44:52 +01:00
Phil Hudson
0e7ea945ce Replaced 'shadow' with 'override' throughout documentation
It is hoped that this will add clarity.

* yasnippet.el, doc/snippet-organization.org (documentation):
  Replaced 'shadow' with 'override' globally.
2015-04-13 15:08:24 +01:00
Noam Postavsky
d61910789f yasnippet.el (yas-initialize): Mark obsolete 2015-04-05 18:05:07 -04:00
João Távora
885237a485 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.
2015-03-23 10:11:19 +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
Stefan Monnier
d19ef74634 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'
2015-03-20 10:34:33 +00:00
Vasilij Schneidermann
3e7b56ebd7 Implements #566: Remove dead major modes code
* yasnippet.el (yas--known-modes, yas--real-mode?): Removed
2015-03-18 11:48:44 +01:00
Wieland Hoffmann
3c133487dc yas-expand-snippet: Clarify EXPAND-ENV 2015-02-12 11:04:31 +01:00
João Távora
b62bdf3fcd Closes #546: backport yas-initialize' and provide yas/initialize'
* yasnippet.el (yas-initialize): Renamed from `yas--initialize'.
(yas--backported-syms): Add `yas-initialize'
2014-12-23 11:03:09 +00:00
João Távora
175e0a3a10 Clean up previous change
* yasnippet.el: Update comment.
(yas--protection-violation): Removed.
(yas--on-protection-overlay-modification): Simplified.
(yas--post-command-handler): No longer reference
`yas--protection-violation'
2014-11-17 11:27:30 +00:00
João Távora
596e6b2640 Closes #537: Be lenient to extensions operating on snippet fields
* yasnippet.el (yas--on-protection-overlay-modification): Commit the
snippets being destroyed instead of signalling a protection violation.
2014-11-04 08:27:34 +00:00
João Távora
1c97671c6e Closes #536: Fix navigation to zero-length fields at snippet end
* yasnippet.el (yas--field-probably-deleted-p): A deleted field
was probably modified before, so enforce that condition.
2014-11-02 23:54:04 +00:00
João Távora
6053db05ca Closes #527: Unbreak case where yas-fallback-behaviour is a list
* yasnippet.el (yas--fallback): Extract interesting values from
`yas-fallback-behaviour' before rebinding.
2014-10-09 07:16:36 +01:00
João Távora
70151f4f1e Closes #525, closes #526: Prevent some keybinding fallback loops
* yasnippet.el (yas--keybinding-beyond-yasnippet): Add docstring.
(yas--fallback): Also let-bind `yas-minor-mode' to nil when
falling back.
2014-10-07 14:57:23 +01:00
Noam Postavsky
e7314516e3 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).
2014-10-04 20:52:58 -04:00
Syohei YOSHIDA
783cc3394f Use cl-incf instead of cl
* yasnippet.el (yas--snippet-next-id, yas--real-line-beginning):
Use `cl-incf'.
2014-09-29 10:38:31 +01:00
Paul Rankin
6f7c91558a Compatibility with custom-unlispify-remove-prefixes 2014-09-21 00:53:29 +10: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
be2f815c43 Closes #508: Ensure original point when evaluating conditions
* yasnippet.el (yas--templates-for-key-at-point): Call
`yas--fetch', and hence condition system, with point in the
original position.
2014-08-21 08:38:46 +01:00
João Távora
5b59b802ac 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.
2014-08-20 21:48:41 +01: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
João Távora
f7ef023ebb 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.
2014-08-20 20:23:00 +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
47a3d5f1cb Fix yas-key-syntaxes example functions docstrings.
* yasnippet.el (yas-try-key-from-whitespace),
  (yas-shortest-key-until-whitespace),
  (yas-longest-key-from-whitespace): docstring describes the effect, not
  implementation.
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
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