681 Commits

Author SHA1 Message Date
Noam Postavsky
3e67b1bb7b yasnippet.el (snippet-mode): Add autoload cookie. 2016-04-09 19:51:56 -04:00
Noam Postavsky
4c6064ce1a Avoid potential problems with user's hooks
* yasnippet.el (yas--font-lock-keywords): ignore-errors from
emacs-lisp-mode call, in case user's hooks cause problems (e.g. enabling
`yas-minor-mode' before we finish loading).
2016-04-09 19:50:47 -04:00
Noam Postavsky
4af9fc9815 Further cleanup
* yasnippet.el (yas-snippet-dirs): Fix :type.
(yas--modes-to-activate): Add explicit fboundp check instead of
ignore-errors.
(yas--font-lock-keywords): Remove redundant entries.
(yas--guess-snippet-directories): Simplify.
(yas-load-snippet-buffer-and-close): Use read-file-name.
2016-04-08 18:58:17 -04:00
Stefan Monnier
18f7b1b9fe Various cleanup
* yasnippet/yasnippet.el: Add Package-Requires since we use cl-lib.
(yas-installed-snippets-dir, yas--default-user-snippets-dir)
(yas--load-directory-1, yas-load-snippet-buffer-and-close):
Use expand-file-name.
(yas-buffer-local-condition): Let's not quote lambdas.
(yas--modes-to-activate): Fix compiler warning about free `dfs' var and
unused return value of `mapcar'.
(yas-minor-mode): Don't confuse emulation-mode-map-alists for a hook.
(yas--font-lock-keywords): Don't hardcode the name of emacs-lisp-mode's
font-lock keywords.
(yas--calculate-group): Use file-relative-name.
(yas--subdirs): Don't mismatch \n in file name.
(yas-expand-from-trigger-key, yas-tryout-snippet): Prefer numbers to
number names.
(yas--guess-snippet-directories): Use expand-file-name rather than
removing&adding / by hand.
(yas--on-field-overlay-modification): Mark `length' as unused.
(yas--update-mirrors): Try to better fit within 80 columns.
(yas--backported-syms, yas--exported-syms): Don't mismatch \n in
symbol name.
2016-04-08 18:57:48 -04:00
Noam Postavsky
6aeccce2f1 Release 0.9.1
- add NEWS
- update version numbers
- update snippet submodule
2016-04-03 11:30:04 -04:00
Noam Postavsky
115f5ffff0 yasnippet.el (yas--describe-pretty-table): Cleanup. 2016-04-02 10:38:05 -04:00
USAMI Kenta
ea5ed74fb2 Avoid trailing whitespace in snippet tables
* yasnippet.el (yas-describe-tables, yas--describe-pretty-table): Remove
  redundant tail spaces from output.

Copyright-paperwork-exempt: yes
2016-04-02 10:30:10 -04:00
Noam Postavsky
572c73d50b Avoid error in case this-command isn't a symbol.
Fixes #664.

* yasnippet.el (yas--skip-and-clear-field-p): Only get
  `delete-selection' property of `this-command' when it's a symbol.
2016-02-26 16:59:39 -05:00
Noam Postavsky
88b7950554 Reduce `yas-new-snippet-default'
* yasnippet.el (yas-new-snippet-default): Remove
  "require-final-newline: nil", it's redundant since `snippet-mode' already
  sets that.  Also remove the direct-keybinding, since it's hardly ever
  used, and often the literal "# binding: direct-keybinding" ends up in
  actual snippets.
2016-01-31 12:48:06 -05:00
Noam Postavsky
8632262a50 Don't use yas-x-prompt by default
It is not a very pleasant method when there are many values, and
`yas-completing-prompt' will usually do a better job, in addition to
respecting customizations to `completing-read-function'.
`yas-dropdown-prompt' remains in first place, since it only takes effect
if the `dropdown' library is loaded, which likely indicates a preference
for it.

* yasnippet.el (yas-prompt-functions): Remove yas-x-prompt from default value.
2016-01-29 13:57:18 -05:00
Noam Postavsky
acf2cdd03e Decide field clearing commands based on delsel
* yasnippet.el (yas--skip-and-clear-field-p): Check `delete-selection'
  of `this-command'.

Fix #644, close #645.
2016-01-22 11:45:01 -05:00
João Távora
4a6d923c9d Slightly improve on fix for #515: Refactor code and add tests
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.
2016-01-22 11:19:34 -05:00
Noam Postavsky
1a98c38d9c Fix silly mistake in previous commit
* yasnippet.el (yas--load-snippet-dirs): Put `make-directory' call in
  same branch of the `if' as the `dolist' loop.
2016-01-20 09:44:28 -05:00
Noam Postavsky
46256db43d Fix #648; create ~/.emacs.d/snippets automatically
* yasnippet.el (yas--load-snippet-dirs): Create
  yas--default-user-snippets-dir, if needed.
2016-01-20 09:27:24 -05:00
João Távora
a2c5292724 Bless Noam Postavsky as the new official maintainer
* yasnippet.el (yas-about): Bless Noam Postavsky as the official maintainer
2016-01-04 09:29:20 +00:00
Noam Postavsky
e6fff091f2 Don't choose ido prompting based on Emacs version
* yasnippet.el (yas-ido-prompt): Unconditionally use ido prompting,
  explicitly requireing ido.
(yas-maybe-ido-prompt): New function, call `yas-ido-prompt' if
`ido-mode' is enabled.
(yas-prompt-functions): Replace `yas-ido-prompt' with
`yas-maybe-ido-prompt' in the default value.
2015-12-27 18:50:21 -05:00
Noam Postavsky
61261c9bb4 Fix #576; don't override yas-prompt-functions
* yasnippet.el (yas-visit-snippet-file): Don't override
  `yas-prompt-functions'.
2015-12-27 18:26:07 -05:00
Noam Postavsky
140c415505 Respect y-b-l-cond from binding triggered snippets
The default value for `yas-buffer-local-condition' was only effective
for `yas-expand-from-trigger-key' command, so it didn't have any effect
when triggering snippets from a key binding (or if using the
`yas-expand' alias).

* yasnippet.el (yas-buffer-local-condition): Check if `this-command' is
  `yas-expand' or `yas-expand-from-keymap' too.

Fixes #305, close #638
2015-12-27 18:24:37 -05:00
Noam Postavsky
17fe7904ae Fix #515; only clear field on self-insert
* yasnippet.el (yas--on-field-overlay-modification): Only clear field if
  `this-command' is `self-insert-command'.  Clean up docstring.

Close #639.
2015-12-27 18:24:01 -05:00
Noam Postavsky
c80fbf2c0b Cleanup yas--on-field-overlay-modification
* yasnippet.el (yas--on-field-overlay-modification): Remove redundant
  `after?' check; use `=' to save marker vs number type checking.
2015-12-13 00:33:25 -05:00
Noam Postavsky
d78181a7f1 Remove yas--inhibit-overlay-hooks macro.
* yasnippet.el (yas--inhibit-overlay-hooks): Remove.
(yas--commit-snippet, yas--make-move-field-protection-overlays):
(yas-expand-snippet, yas--mirror-update-display):
(yas--field-update-display): Replace `yas--inhibit-overlay-hooks' with
its expansion.
2015-12-09 21:04:24 -05:00
Noam Postavsky
3cd64b74b3 yasnippet.el (yas--called-interactively-p): Remove.
It's unused since "fix: more idiomatic elisp..." 29 Aug 2013
(13d87aa3c0b0289ed918bab545d2b423974688a5).
2015-12-09 20:11:31 -05:00
Noam Postavsky
23ee54e10f Use destructive list functions in yas--s-a-p
`mapcar' already create a fresh list so there is no need to preserve it.

* yasnippet.el (yas--snippets-at-point): Use `delq' and `delete-dups'
  instead of `remove' and `remove-duplicates`, respectively.
2015-12-08 19:03:42 -05:00
Noam Postavsky
6c46878882 Fix #587; set `this-command' on fallback.
`this-original-command' is supposed to be for the command that
we're *not* executing because of key remapping, therefore it doesn't
make sense to set it to the command we're about to execute.

* yasnippet.el (yas--fallback): Set `this-command'.
2015-12-08 18:19:02 -05:00
João Távora
2100b89eb8 Closes #632: Use `user-emacs-directory' instead of hardcoded "~/emacs.d"
* yasnippet.el (yas--default-user-snippets-dir): New defconst.
(yas-snippet-dirs, yas--guess-snippet-directories): Use it.
2015-11-26 13:18:16 +00:00
Sharif Nassar
1cf723a408 Ignore trailing spaces in snippet definitions
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
2015-11-08 18:05:09 -05:00
Sharif Nassar
3aa7cb29d4 M-x delete-trailing-whitespace
* yasnippet.el: delete-trailing-whitespace
* yasnippet-tests.el: delete-trailing-whitespace

Copyright-paperwork-exempt: yes (trivial)
2015-11-08 18:04:08 -05:00
Noam Postavsky
f12164551f Fix #607; avoid Emacs bug #21824
See also
- https://github.com/capitaomorte/yasnippet/issues/607
- http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21824

* yasnippet.el (yas--on-field-overlay-modification): Do nothing if
  yas--active-field-overlay is not an overlay.
2015-11-03 22:16:17 -05:00
Noam Postavsky
cd05da61f9 Activate extra and major modes first
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.
2015-11-01 18:35:52 -05:00
Noam Postavsky
b8687bb0fe Avoid double snippet loading messages
* yasnippet.el (yas--load-directory-1): Message about loading compiled
  snippets only after successfully doing so.

Close #627.
2015-11-01 18:35:28 -05:00
Noam Postavsky
b055f132be Fix #617; ensure point is visible before x prompt
* yasnippet.el (yas-x-prompt): Call redisplay.
2015-10-21 18:39:40 -04:00
Noam Postavsky
35642ac007 Simplify string matching.
* yasnippet.el (yas--field-parse-create): Use string-match-p to instead
  of save-match-data, anchor regexp with \` (start of string) to instead
  of (eq ... 0)
2015-10-11 21:23:36 -04:00
Noam Postavsky
72c6c4cd7b Fix #618; save match data in yas--scan-sexps
* yasnippet.el (yas--scan-sexps): Save match data.
2015-10-11 21:18:52 -04:00
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