1323 Commits

Author SHA1 Message Date
Stefan Monnier
dd570a6b22 yasnippet.el: Bump version to trigger release
* yasnippet-tests.el (string-suffix-p): Remove fallback definition.
2025-06-02 09:42:36 -04:00
Stefan Monnier
272b6067f1 Try and fix issue #1214
* yasnippet.el (yas--load-directory-1): Add a `lexical-binding` cookie
to the compiled-snippet files, and silence warnings if it's absent from them.
(yas--letenv-f): New function extracted from `yas--letenv`.
(yas--letenv): Use it.
2025-06-01 18:43:13 -04:00
Stefan Monnier
2384fe1655 yasnippet.el (yas--version): Delete variable.
(yas-about): Fall back to the Git description only if the package
version is not available.
(yas--make-menu-binding): Don't quote lambdas.
2025-04-03 15:26:13 -04:00
Stefan Monnier
81a59d1a85 yasnippet.el: Bug fix release 0.14.2 2025-04-03 12:43:37 -04:00
Stefan Monnier
2c20b10fc3 Misc minor pending tweaks
* yasnippet.el (yas-minor-mode): Fix docstring (issue#1210).
(yas--save-restriction-and-widen): Use workaround only for the old
Emacsen where it was needed.
(yas--snippet-create): Adjust Emacs version where CC-mode needed
a workaround.
(help-snippet-def): Remove useless use of `purecopy`.
2025-04-03 12:40:54 -04:00
Stefan Monnier
5b315f1753 Misc fixes found via compilation warnings
* yasnippet-debug.el (yas-debug-snippets): Improve commit 009322196cfa.
* yasnippet-tests.el (test-rebindings): Avoid `copy-keymap`.
2025-01-12 17:51:54 -05:00
Stefan Monnier
03b1b11547 yasnippet.el (yas--font-lock-keywords): Avoid font-lock-*-face vars 2025-01-12 10:04:11 -05:00
Stefan Monnier
37d0b2790f yasnippet.el (yas-maybe-load-snippet-buffer): Don't move point (#1146) 2025-01-12 09:59:50 -05:00
monnier
fe1f4e0e96
Merge pull request #1149 from pestctrl/quit-undo-tree
Push modifications to buffer-undo-list, even if unwinding
2024-10-13 11:57:55 -04:00
Benson Chu
ce54f1958f Push modifications to buffer-undo-list, even if unwinding 2024-10-13 10:48:59 -05:00
monnier
eb5ba2664c
Merge pull request #1196 from VitoVan/master
(yas--all-parents): delete-dups for fundamental-mode
2024-04-06 09:14:51 -04:00
Vito Van
e23a80177a
(yas--all-parents): delete-dups for fundamental-mode
Before this commit,

(yas--all-parents 'lisp-mode) would return:

`(lisp-mode lisp-data-mode prog-mode fundamental-mode fundamental-mode)`

which would cause duplicated entries when prompting,
if the snippet were for fundamental-mode.
2024-04-06 17:34:18 +08:00
Stefan Monnier
33587a8551 (yas-reload-all): Flush the all-parents caches (issue #1194)
* yasnippet.el (yas--flush-all-parents): New function.
(yas-reload-all): Use it.

* yasnippet.el (issue-492-and-494): Don't flush the all=parents cache any
more since `yas-reload-all` does it for us.
2024-03-08 03:15:33 -05:00
monnier
15065c36b4
Merge pull request #1194 from gutron/master
Undo all-parents memoization in test
2024-03-01 18:27:46 -05:00
Ron Gut
ab03a754e7 Undo all-parents memoization in test
yas-reload-all does not undo the memoization done in yas--all-parents, which
causes the issue-492-and-494 test to fail when run after any tests that
expands yas-with-some-interesting-snippet-dirs.

With the memoization enabled, c++-mode is considered a parent of c-mode,
causing the issue-492-and-494 test to fail.  With the memoization reset,
this does not occur.
2024-02-28 19:26:45 -05:00
Stefan Monnier
5b565c54b0 NEWS: Give a few more details 2024-02-15 15:34:45 -05:00
Stefan Monnier
1ec7e3b6f7 (yas--all-parents): Obey derived-mode-extra-parents (Issue #1193) 2024-02-15 14:09:24 -05:00
Stefan Monnier
8e9ce76f7a yasnippet.el: Recognize ${N} as an alternative syntax for $N
(yas-define-snippets): Warn about identity conflicts.
(yas--one-simple-fom): New fun, extracted from `yas--simple-fom-create`.
(yas--simple-fom-create): Use it.
(yas--field-parse-create): Use it for ${N}.
2024-02-12 11:45:51 -05:00
Stefan Monnier
297546f085 yasnippet.el: Bug fix release 0.14.1 2024-01-23 21:58:24 -05:00
Stefan Monnier
b8f3f11ee5 yasnippet.el (yas--indent-region): Workaround for issue #1183 2024-01-22 13:46:51 -05:00
Stefan Monnier
47b38b2133 yasnippet.el (yas-define-snippets): Remove costly no-op 2024-01-22 13:46:05 -05:00
monnier
5af84cdb94
Merge pull request #1184 from martenlienen/local-condition-closure
Allow closures in yas-buffer-local-condition
2024-01-22 08:23:30 -05:00
Marten Lienen
9228fd983b * yasnippel.el (yas-buffer-local-condition): Check functionp before consp to allow closures 2024-01-22 11:08:44 +01:00
Stefan Monnier
1d0966ae34 * yasnippet.el (yas-buffer-local-condition): Accept functions
(yas-not-string-or-comment-condition): Make it a function.
(yas--funcall-condition): Rename from `yas--funcall-condition`, change
its calling convention.
(yas--template-can-expand-p, yas--describe-pretty-table):
Adjust accordingly.
(yas--require-template-specific-condition-p): Add support for functions
in `yas-buffer-local-condition`.

* doc/snippet-expansion.org (The condition system <<condition-system>>):
Adjust example to avoid quoted code.
2024-01-19 12:38:21 -05:00
Stefan Monnier
25f5d8808a Avoid shadowing the tab => TAB remapping
* yasnippet.el (yas-keymap): Don't bind `tab`.
(yas--read-keybinding): Prefer the more precise \` and \' regexps.
(yas--parse-template): Use `pcase`.
2024-01-19 08:57:17 -05:00
Stefan Monnier
d7a79d4a96 Fix remaining failing tests
* yasnippet-tests.el (issue-492-and-494): Make the test a bit less picky.
(test-yas-tab-binding, test-yas-in-org): Test TAB rather than `tab`
because at the level at which we do the test, `tab` is not remapped to TAB.
2024-01-19 08:55:17 -05:00
Stefan Monnier
3e14a8534f (yas--on-protection-overlay-modification): Fix thinko 2024-01-18 10:31:17 -05:00
Stefan Monnier
9f253badfb yasnippet.el: Work around Emacs bug#65929 (see also issue#1175)
(yas--on-protection-overlay-modification): Ignore clearly bogus calls.
(yas-keymap-disable-hook): Improve docstring.
2024-01-17 13:24:15 -05:00
Stefan Monnier
23c7a6fa51 yasnippet.el: Minor simplifications
(yas--check-commit-snippet): De Morgan.
(yas-expand-snippet): Use `yas-current-field`.
2024-01-17 13:07:51 -05:00
Stefan Monnier
c6488ac6fb README.mdown: Minor tweaks 2024-01-15 00:55:21 -05:00
Stefan Monnier
d12428082c yasnippet-tests.el: Fix some failures
* yasnippet-tests.el (yas-call-with-saving-variables): Don't `set` when
there's nothing to change.
(yas-with-overriden-buffer-list): Fix `buffer-list` override.
(loading-with-cyclic-parenthood, extra-modes-parenthood): Tweak tests
to be a bit less sensitive to details of ordering and number of
repetitions in `yas--modes-to-activate`.

* yasnippet.el (yas--all-parents): Make sure `mode` is always first in
the output, as is the case for `derived-mode-all-parents`.
(yas--modes-to-activate): Put extra modes first and not reversed, as
required by test `extra-modes-parenthood`.
2024-01-15 00:53:00 -05:00
Stefan Monnier
8ce506e32f * yasnippet.el (yas--all-parents): Don't add fundamental-mode to itself
Rename `yas--all-children` to `yas--cached-children` since it doesn't
contain "all" children.
2024-01-14 00:34:22 -05:00
Stefan Monnier
d7f55c7501 (yas--all-parents): Fix stale cache issue #1180
* yasnippet.el (yas--all-parents): Record children in `yas--all-children`.
(yas--define-parents): Use it to flush the caches of the affected modes.
2024-01-08 11:42:46 -05:00
Stefan Monnier
ae36504a5f yasnippet.el: Use derived-mode-all-parents when available
This allows YASnippet to obey `derived-mode-add-parents`, which should
become the standard way to indicate "loose" relationships (such as
the fact that `js3-mode` is related to `js-mode` or for TS modes).

* yasnippet.el (yas--merge-ordered-lists, yas--all-parents): New functions.
(yas--modes-to-activate): Use them.
2024-01-04 15:13:51 -05:00
Stefan Monnier
bd2fdc8f7d * yasnippet.el (yas--snippet-create): Remove CC-mode workaround for #953 2024-01-01 19:47:31 -05:00
Stefan Monnier
362e9b551d yasnippet.el (yas-about): Use package-get-version 2024-01-01 19:45:05 -05:00
Stefan Monnier
66db827a86 yasnippet.el: Use setq-local and defvar-local 2024-01-01 19:40:47 -05:00
Stefan Monnier
bcefd0a1c1 * yasnippet.el: Remove compatibility for Emacs<24.4
Since we already require Emacs≥24.4, there's not point keeping that
compatibility code.

(yas--modes-to-activate): Remove redundant `fboundp` test.
(yas-activate-extra-mode): Don't bother converting hashtable to alist
to pass to `completing-read`.
(yas-dont-activate-functions): Get rid of Emacs≤23 code.
(snippet-mode): `prog-mode` is always available.
(yas-x-prompt): `posn-at-point` is always available.
(yas--merge-and-drop-dups): `delete-consecutive-dups` is always available.
2024-01-01 19:36:59 -05:00
Stefan Monnier
2b328e563e * yasnippet.el (yas-wrap-around-region): Fix warning
Fix placement of `:tag` arg to `const` custom type.
2024-01-01 19:18:11 -05:00
Stefan Monnier
9596631bde * README.mdown: Tweak install instructions
(Installation): Rename the Git install section to make it sound less
like the "normal&recommanded" way to install YAsnippet.
(Install with `package-install`): Mention GNU ELPA and GNU-devel ELPA.
2024-01-01 19:12:03 -05:00
Stefan Monnier
b86b44cce6 (yas--modes-to-activate): Pay attention to major-mode-remap-alist
Should hopefully fix issue #1169.
2024-01-01 16:17:58 -05:00
Stefan Monnier
52a1c50319 * yasnippet.el (debug-ignored-errors): Don't modify it
(debug-ignored-errors): Remove left over code that became obsolete with
commit 175e0a3a102c22.
(yas--read-lisp): Fix code generation.
(yas-exception): Use `define-error`.
2023-09-14 10:00:37 -04:00
Stefan Monnier
58c92ba393 * yasnippet.el: Cosmetic changes
Prefer #' to quote function names.
(yas-after-exit-snippet-hook, yas-before-expand-snippet-hook)
(yas-after-reload-hook): A hook is not a function, but a symbol
containing functions.  Fix doc accordingly.
(yas-define-snippets, yas-longest-key-from-whitespace)
(yas--field-parse-create): Make the doc fit within 80 columns.
(yas-skip-and-clear-or-delete-char): Fix ordering between `declare` and
`interactive`.
2023-09-14 10:00:37 -04:00
Stefan Monnier
043c52a5a9 * yasnippet.el (yas-minor-mode-map): Don't bind to tab 2023-09-14 10:00:37 -04:00
Stefan Monnier
009322196c * yasnippet-debug.el: Use advice-add i.s.o defadvice.
Now that we use `add-function`, we may as well avoid using the deprecated
`defadvice`

(cl-flet): Remove confusing `cl-flet` fallback, always provided by `cl-lib`.
(yas--snippet-parse-create, yas--commit-snippet):
Use `advice-add` i.s.o `defadvice`.
2023-09-14 10:00:37 -04:00
Stefan Monnier
e991530108 * yasnippet.el: Use add-function and remove left-over debug code
Instead of using `setq` and storing the old value in
`yas--original-auto-fill-function`, use `add-function`.
This makes it virtually impossible for a bug like #873/#919 to appear.
Remove the left-over debug code we had added to try and track down
#873/#919.

This requires bumping the dependency on Emacs≥24.4.

(yas--original-auto-fill-function, yas--watch-auto-fill-backtrace):
Delete variables.
(yas--watch-auto-fill): Delete function.  Don't add it to variable watchers.
(yas--auto-fill-wrapper): Use `add-function`.
(yas-minor-mode): Use `remove-function`.
(yas--auto-fill): Adjust its calling convention for use with `:around`
in `add-function`.  Remove left-over debug code.
(yas--post-command-handler): Remove left-over debug code.
2023-09-14 10:00:37 -04:00
Stefan Monnier
97002af846 * yasnippet.el: Use lexical-binding 2023-09-14 10:00:37 -04:00
Stefan Monnier
b09ab98419 * yasnippet-tests.el: Minor cosmetic changes
Use utf-8 rather than latin-1.
Prefer #' to quote function names.
(special-mode): Remove backward compatibility code which never worked
since it uses `fundamental` which doesn't exist).
2023-09-14 10:00:29 -04:00
Stefan Monnier
6e4de312cf * doc/yas-doc-helper.el: Use cl-lib and lexical-binding
Also silence compiler warnings.
2023-09-14 09:59:23 -04:00
Stefan Monnier
946b27ddca * .gitignore: Add patterns for ELPA-generated files 2023-09-14 09:59:23 -04:00