1263 Commits

Author SHA1 Message Date
Noam Postavsky
291873ee13 ; .travis.yml: Clean up validator warnings/infos 2020-04-04 20:52:38 -04:00
Noam Postavsky
170d13d069 Scan nested fields properly
* yasnippet.el (yas--scan-for-field-end): New function.
(yas--field-parse-create): Use it instead of yas--scan-sexps, which
isn't able to distinguish between ${...} (a nested field) and
{...} (plain old braces in the snippet text).
* yasnippet-tests.el (yas-escaping-close-brace): New test.
2020-04-04 20:47:21 -04:00
Noam Postavsky
7c02bc142c Fix failure on depth 2+ nested snippets
* yasnippet.el (yas--advance-end-maybe-previous-fields): New function.
(yas--commit-snippet, yas--on-field-overlay-modification)
(yas-expand-snippet): Use it, so that all active fields will be
extended properly, even in case of deeply nested snippet expansion.
* yasnippet-tests.el (nested-snippet-expansion-depth-2): New test.
2020-03-29 10:34:42 -04:00
Noam Postavsky
ac03c2f192 ; Test on Emacs 27
* .travis.yml: Add 27-prerelease.  Change 26-prerelease to 26.3.
2020-03-25 22:38:30 -04:00
Noam Postavsky
3bf9a3b1af Release 0.14.0
* NEWS: Update for 0.14.
* yasnippet.el (yas-installed-snippets-dir, yas--version): Bump
version.
0.14.0
2019-12-22 17:06:42 -05:00
Noam Postavsky
4046f61588 * yasnippet.el (yas-field-highlight-face): Remove redundant quote. 2019-12-13 16:01:51 -05:00
João Távora
1bee3a33c7 Fix #979: grok curly braces with LSP-style escaping
* yasnippet-tests.el (escaping-for-lsp-style-snippet-syntax): New
test.

* yasnippet.el (yas--field-parse-create): rework real-match-end-0
calculation.
2019-10-30 13:31:17 +00:00
Bao Haojun
a66f15e6c9 Fix yas-insert-snippet for keyless snippets
* yasnippet.el (yas--table-templates): Get snippets from uuidhash
table too.

Copyright-paperwork-exempt: yes
2019-10-08 22:16:25 -04:00
Stefan Monnier
d91dd66f2a * yasnippet.el (yas--extra-modes): Move alias before def 2019-07-24 08:04:46 -04:00
Noam Postavsky
bd3572a9b3 Handle multiple uses of yas-auto-next
* yasnippet.el (yas--auto-next): Loop again after moving to the next
field.
* yasnippet-tests.el (auto-next-field): Test for multiple
yas-auto-next uses.
2019-07-23 18:05:40 -04:00
Noam Postavsky
476bc77c34 Fix snippet undo
* yasnippet.el (yas--snippet-revive): Add revived snippet to
yas--active-snippets.
* yasnippet-debug.el (yas-debug-snippets): Print yas--active-snippets
length.
* yasnippet-tests.el (undo-revive-and-do-again): New test.
2019-06-30 13:20:19 -04:00
Bill Sacks
e45e3de357 * doc/faq.org: yas-prev should be yas-prev-field
Copyright-paperwork-exempt: yes
2019-05-08 18:42:08 -04:00
Noam Postavsky
f056a4def8 Minor code shuffling and commenting
* yasnippet.el (yas--do-todo-snippet-indent): Renamed from
yas--do-todo-snippet-indent.
2019-05-02 18:14:52 -04:00
Noam Postavsky
55c448b991 Remove redundant arg to yas-expand-snippet
* yasnippet.el (yas--expand-or-visit-from-menu)
(yas--expand-or-prompt-for-template)
(yas-visit-snippet-file, yas-tryout-snippet): Don't pass expand-env
when to yas-expand-snippet when first arg is a yas--template record.
2019-05-02 18:13:15 -04:00
Noam Postavsky
c432e78ffd Fix field adjustment on deletion
For deletion, we need to check the bounds before the deletion happens,
otherwise the overlay may already be moved to wrong place.
* yasnippet.el (yas--before-change-modified-snippets): New variable.
(yas--merge-and-drop-dups): New function.
(yas--gather-active-snippets): New function.
(yas--on-field-overlay-modification): Use it.

* yasnippet.el
2019-05-02 07:34:23 -04:00
Noam Postavsky
ffce236268 Do auto indentation only in post command hook
* yasnippet.el (yas--todo-snippet-indent): New variable.
(yas--on-field-overlay-modification): Save snippet to it, and don't
indent after mirror update.
(yas--do-todo-field-updates): New function.
(yas--post-command-handler): Call it.
(yas--snippet-field-mirrors, yas--indent-mirrors-of-snippet): New
functions, split out from...
(yas--snippet-field-mirrors): ...here.
* yasnippet-tests.el (yas-test-delete-and-insert-command)
(indent-mirrors-on-complex-update): New test and helper function.
2019-05-01 17:52:26 -04:00
Noam Postavsky
6a738b581f ; doc/faq.org: Fix example keybinding code. 2019-04-30 20:44:40 -04:00
Noam Postavsky
fc33b2fbae Make overlay-modification protection optional
* yasnippet.el (yas-inhibit-overlay-modification-protection): New
variable.
(yas--on-protection-overlay-modification): Consult it.
2019-04-22 22:06:40 -04:00
Noam Postavsky
bae20af3de ; * doc/faq.org: Linkify bug reference. 2019-04-22 11:23:49 -04:00
Noam Postavsky
189f7375b6 * doc/faq.org: Note that Flyspell problem is (now fixed) Emacs bug. 2019-04-21 16:18:01 -04:00
Noam Postavsky
9cedd596ec Allow disabling snippet keybindings from hook
* yasnippet.el (yas-keymap-disable-hook): New hook.
(yas-filtered-definition): New function.
(yas-keymap): Use it.
* doc/faq.org: Update key redefinition example.
2019-04-21 16:11:44 -04:00
Noam Postavsky
7612bc1b70 Don't check this-command in yas-not-string-or-comment-condition
Since we now check conditions in conditional keybindings, it can be
evaluated before 'this-command' has been assigned.
* yasnippet.el (yas-not-string-or-comment-condition): Remove check of
'this-command'.
2019-04-21 15:25:02 -04:00
Noam Postavsky
6a3619b4f2 Fix additional corner case with org source block integration
* yasnippet.el (yas--on-buffer-kill): Check if the org-marker still points
to a buffer.
2019-04-21 14:18:14 -04:00
Noam Postavsky
048d030b68 Fix line-relative snapshotting for org src blocks
There was some half-backed code getting confused between "plain"
snapshort info and line+snapshot info leading to some type errors when
expanding snippets in org-mode src blocks.  I had wrongly assumed the
failures were only due to org version 9 changes (in fact, the org
changes only affect snippet expansion for text-mode (and probably
other non-fontifying modes too)).  Reorganize the snapshotting
functions so that line+snaphot has the line info after the marker,
next to the rest of the snapshot info.  This removes the need for list
manipulation and simplifies the code.  Furthermore, let the
restoration functions take the info as a list, rather than separate
arguments, this removes the need for several uses of `apply'.
* yasnippet.el (yas--snapshot-location): Renamed from
yas--snapshot-marker-location, don't return marker.
(yas--snapshot-line-location): New function.
(yas--goto-saved-location): Take single list arg.  Return point.
(yas--restore-marker-location): Remove, open code callers.
(yas--goto-saved-line-location)
(yas--restore-overlay-line-location): New functions.
(yas--prepare-snippets-for-move, yas--finish-moving-snippets)
(yas--auto-fill, yas--indent-region): Adjust callers of previously
mentioned functions accordingly.
* yasnippet-tests.el (yas-org-native-tab-in-source-block-text):
Renamed from yas-org-native-tab-in-source-block.
(yas-org-native-tab-in-source-block-emacs-lisp): New test.
(do-yas-org-native-tab-in-source-block): Take MODE parameter.
2019-04-14 12:06:44 -04:00
Noam Postavsky
dabc719921 Don't turn on yas-minor-mode in temp buffers
Generally, the user won't be interacting with, or creating snippets in
temporary buffers.
* yasnippet.el (yas-temp-buffer-p): New function.
(yas-dont-activate-functions): Add it to default value.
* yasnippet-tests.el (complicated-yas-key-syntaxes)
(test-yas-activate-extra-modes): Call yas-minor-mode instead of
yas-minor-mode-on, to ensure activation.
2019-04-10 08:06:25 -04:00
Martin Harrigan
8b25d627a4 * doc/snippet-development.org: Fix typos.
Copyright-paperwork-exempt: yes
2019-03-31 21:54:38 -04:00
Benjamin Hipple
03aa5618ae * doc/snippet-organization.org: Fix typo.
Copyright-paperwork-exempt: yes
2019-03-31 21:39:07 -04:00
Noam Postavsky
1d96da2e08 Don't call before/after change-functions twice
* yasnippet.el (yas--snippet-create): Let-bind
inhibit-modification-hooks for snippet insertion, so that we don't
call change functions automatically, we already call them manually
after insertion and parsing.
2018-10-15 08:12:51 -04:00
Noam Postavsky
9f51cf29c9 Register snippet movement comments for eldoc
* yasnippet.el (top-level): Call eldoc-add-command.
2018-10-13 17:22:12 -04:00
James Nguyen
bceb65ba29 Make backspace/DEL clear field (#957)
* yasnippet.el (yas-clear-field): New command.
(yas-maybe-clear-field): New conditional binding value.
(yas-keymap): Bind it to DEL.
2018-10-13 17:12:48 -04:00
Noam Postavsky
fb253ac607 New public function yas-maybe-expand-abbrev-key-filter
* yasnippet.el (yas-maybe-expand-abbrev-key-filter): Renamed from
yas--maybe-expand-key-filter.
2018-10-13 17:08:32 -04:00
Noam Postavsky
0f05a7555a Add yas-completing-read
* yasnippet.el (yas-completing-read): New function.
(yas-verify-value): Simplify with `member' instead of `cl-notany'.
* doc/snippet-development.org (Template Syntax): Show
`yas-completing-read' instead of `yas-choose-value' in the example.
2018-10-13 17:04:50 -04:00
Noam Postavsky
845222774b Consider fundamental-mode as ultimate ancestor
* yasnippet.el (yas--modes-to-activate): If a mode doesn't have a
`derived-mode-parent' property, use `fundamental-mode'.
* yasnippet-tests.el (loading-with-cyclic-parenthood)
(issue-492-and-494): Expect fundamental-mode to be active.
* doc/snippet-expansion.org (Eligible snippets): Mention that
fundamental-mode is a fallback parent mode.
2018-10-13 17:02:10 -04:00
Kofi Laing
760f77afb9 Test for mirroring more than one field
* yasnippet-tests.el (yas-mirror-many-fields): New test.
2018-10-08 22:51:28 -04:00
Noam Postavsky
3c0be40e21 Update FAQ
* doc/faq.org: Add two questions about yas-key-syntaxes.  Remove
reference to obsolete Google Groups.  Remove question about turning
off minor mode in some buffers, it was out of date, and not frequently
asked.
* yasnippet.el (yas-key-syntaxes): Fix docstring.
2018-10-07 18:30:44 -04:00
Noam Postavsky
eeb05f0910 Handle field adjust of pending active fields
* yasnippet.el (yas--on-field-overlay-modification): Call
yas--advance-end-maybe on all pending active snippets in case of
stacked expansion.
(yas-next-field): Get current snippet according to
active field bounds.
* yasnippet-tests.el (nested-snippet-expansion-4): New test.
2018-10-07 15:06:51 -04:00
Noam Postavsky
ffc733d4cf ; Debug code fixes
* yasnippet-debug.el (yas-debug-live-range): Consider an overlay as
live, not dead even though it has integer bounds.
(yas-debug-with-tracebuf): Add debug declaration.
2018-10-07 15:06:51 -04:00
Noam Postavsky
8328c38d77 Fix another failure of cc-mode indentation
Suggested by OGAWA Hirofumi in
https://github.com/joaotavora/yasnippet/issues/953.
* yasnippet.el (yas--snippet-create): Call before and after change
functions around yas--snippet-parse-create.
* yasnippet-tests.el (indent-cc-mode-2): New test.
2018-10-07 05:55:20 -04:00
Noam Postavsky
7a178a2ca0 Remove spurious change of before-change-functions
Found by OGAWA Hirofumi in
<https://github.com/joaotavora/yasnippet/issues/953>.
* yasnippet.el (yas--save-backquotes): Don't remove first entry of
before-change-functions.
2018-09-16 17:15:26 -04:00
João Távora
1e71360868
Per #947: fix typo in README.md
* README.md (Where are the snippets?): package-install, 
not install-package.
2018-07-22 18:31:33 +01:00
Noam Postavsky
d3bb879356 Remove last-buffer-undo-list compat definition
* yasnippet.el (last-buffer-undo-list): Remove, apparently it works
around some bug in "Carbon Emacs", but yasnippet is probably not the
right place for such a workaround anyway (yasnippet does not use
last-buffer-undo-list).
2018-06-20 20:50:52 -04:00
Noam Postavsky
79b90c9489 Remove compatibility code for Emacs 22 and earlier
* yasnippet.el (region-active-p, locate-dominating-stop-dir-regexp)
(locate-dominating-file): Remove.
2018-06-20 20:50:52 -04:00
Noam Postavsky
e67592ce1b Don't use overlays to find active snippets
* yasnippet.el (yas--active-snippets): New buffer-local variable.
(yas-active-snippets): Use it, when asked for all active snippets.
(yas--commit-snippet): Remove finished snippet from list of active
snippets.
(yas--snippet-create): Add new snippet to list of active snippets.
(yas--check-commit-snippet): Consult list of active snippetes.
2018-06-06 20:22:57 -04:00
Noam Postavsky
4af33546d8 Make less garbage in overlay heavy buffers
* yasnippet.el (yas-active-snippets): Use dolist+when-push instead of
mapcar+delq.
2018-06-06 08:22:58 -04:00
João Távora
4f78d03f85 Close #937: Officially support automatically moving to next field
* yasnippet-tests.el (auto-next-field): New test.
(yas-saving-variables): Move up in the file.

* yasnippet.el (yas--auto-next): New helper.
(yas-auto-next): New user-visible snippet helper.

* doc/snippet-development.org (Choosing fields value from a list
and other tricks): Add mention of yas-auto-next.
2018-05-26 19:33:52 +01:00
Noam Postavsky
5a29fe67d7 Release 0.13.0
* yasnippet-debug.el:
* yasnippet-tests.el:
* yasnippet.el: Bump version to 0.13.0.  Bump copyright years.
* NEWS: Update for 0.13
0.13.0
2018-05-13 13:04:50 -04:00
Noam Postavsky
4755aa9781 Clarify behavior of mirror transforms
* doc/snippet-development.org (mirror-fields): Note that all mirros
are updated when any field is changed.
(mirror-transformations): Add an example of a mirror taking values
from multiple fields.
2018-05-13 12:11:05 -04:00
João Távora
b0aa5c2816 Tweak bug-reporting information slightly
In the README and in the FAQ, mention and link to the list of support
issues in the Github issue tracker.

Rewrite README.mdown slightly for readability and suggest the GH
tracker as primary place for YASnippet discussion.

Retire the YASnippet google group.

* README.mdown (Manual, issues, etc): Mention docs, support issues
and issue tracker separately.  Remove reference to the YASnippet
google group.
(Where are the snippets?): Properly write YASnippet for
consistency.

* doc/faq.org: Add note and link to support issues.
2018-04-29 01:38:27 +01:00
Noam Postavsky
f9231b0e3d Work around Emacs Bug#30931 (Misc_Free in undo list)
* yasnippet.el (yas--remove-misc-free-from-undo): New function.
(yas--save-restriction-and-widen): New macro.
(yas--eval-for-string, yas--snippet-parse-create)
(yas--indent-region, yas--save-backquotes)
(yas--restore-backquotes, yas--update-mirrors): Use it.
2018-04-12 18:48:12 -04:00
Noam Postavsky
16686075bb Don't add to disabled undo list
Previously, we were unconditionally pushing entries onto the undo
list, which effectively enables undo, even in buffers where it's
disabled.
* yasnippet.el (yas--commit-snippet, yas--snippet-revive)
(yas--snippet-create): Check that `buffer-undo-list' is a list before
pushing to it.
2018-04-12 18:48:12 -04:00