1226 Commits

Author SHA1 Message Date
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
0.9.1
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
Stefan Monnier
42601d2ff8 Apply changes from GNU ELPA
* doc/yas-doc-helper.el:
* yasnippet-debug.el:
* yasnippet-tests.el: Fix up copyright headers.

* yasnippet-tests.el: Fix lexical-binding cookie.
* yasnippet-debug.el: Require cl.

* yasnippet-tests.el: Silence byte-compiler.
(yas-saving-variables, yas-with-snippet-dirs): Move macros before their use.
(yas--barbaz, yas--foobarbaz): Declare.
(yas--phony-c-mode, yas--test-mode, yas--another-test-mode): Move out of
deftest, so the byte-compiler understands they're defined.
2016-01-28 14:36:19 -05:00
Noam Postavsky
80941c077f Update snippets submodule 0.9.1-snapshot 2016-01-22 13:56:26 -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
Noam Postavsky
100d8d1904 Fix bug reporting examples.
- There was a missing "." in the emacs invocation (thanks to Barrie
  Treloar for reporting).

- The example reports had too little plain observation, and too much
  interpretation.

* README.mdown: Add missing "." to bug reporting instructions, improve
  wording of example reports.

Close #646.
2016-01-15 17:00:48 -05:00
João Távora
af905283bd Fix debugging code for newer Emacsen
* yasnippet-debug.el (yas-debug-snippet-vars): Check for length of
`buffer-undo-list'. Don't assume all fields have integer
`yas--field-number'.
2016-01-06 10:40:58 +00: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
71f0142eda Improve test simulatulation of self-insert
* yasnippet-tests.el (yas-mock-insert): Use `ert-simulate-command' to
  simulate n self-insert-commands.
(simple-mirror, mirror-with-transformation):
(primary-field-transformation, nested-placeholders-kill-superfield):
(nested-placeholders-use-subfield):
(mirrors-adjacent-to-fields-with-nested-mirrors):
(deep-nested-mirroring-issue-351, example-for-issue-271):
(string-match-with-subregexp-in-mirror-transformations): Call
`yas-mock-insert' directly instead of with `ert-simulate-command'.
2015-12-13 00:37:36 -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
67a45a61de * README.mdown: Add link to textmate-to-yas.el. 2015-12-12 10:59:21 -05:00
JJ Asghar
444c882b64 * README.mdown: update melpa URL.
Copyright-paperwork-exempt: yes

Close #555.
2015-12-12 10:30:18 -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
beb02e5e9e * CONTRIBUTING.md: Add note about changelog only messages. 2015-11-07 08:54: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
fb28ec8384 * README.mdown (Use yas-minor-mode): Reword.
Close #623.
2015-11-01 18:36:08 -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
ac3fe83247 Merge pull request #621 from npostavs/dfs-extra-modes2
find parents for extra-modes too (v2)
2015-10-11 14:51:56 -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
00b84ceaf4 Add (failing) yas--modes-to-activate test
* yasnippet-tests.el (extra-modes-parenthood): New (failing) test.
(loading-with-cyclic-parenthood): Use equal + sort instead of set
operation + length.
2015-10-11 13:08:53 -04:00
George Balatsouras
710ea4d106 Update snippets module 2015-10-05 02:57:27 +03: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
7703a55ac4 * doc/snippet-organization.org (.yas-skip): Add info. 2015-09-24 21:12:30 -04:00
Noam Postavsky
01139a2deb * yasnippet.el (yas--define-snippets-2): Use file-name-NONdirectory. 2015-09-12 16:30:01 -04:00