1323 Commits

Author SHA1 Message Date
Noam Postavsky
0b8d43490c Unset autoload-compute-prefixes for utility files
* yasnippet-debug.el:
* yasnippet-tests.el: Set autoload-compute-prefixes to nil
file-locally.
2018-01-01 12:59:52 -05:00
Noam Postavsky
4ab9cb5bac Set test to fail with newer org version
* yasnippet-tests.el (yas-org-native-tab-in-source-block): Expect to
fail for org 9.x.
2017-11-25 18:01:28 -05:00
Noam Postavsky
35a4df769c Let whitespace-global-mode work in new snippet buffers
* yasnippet.el (yas-new-snippet-buffer-name): New constant, holds the
name of new snippet buffers.  Change it to "+new-snippet+" to avoid
the leading "*" from fooling whitespace-global-mode into thinking it
shouldn't activate.
(yas-new-snippet):
* yasnippet-tests.el (snippet-save): Use the constant instead of
hardcoding the literal string.
2017-09-23 19:46:07 -04:00
Noam Postavsky
1fc34266a4 Add test relying on overlay hook inhibition in `yas-expand-snippet'
* yasnippet-tests.el
(insert-snippet-with-backslashes-in-active-field): New test.
2017-09-23 19:38:57 -04:00
Noam Postavsky
ba4e5c1736 * yasnippet-debug.el (yas-debug-snippet): Handle non-numbered fields. 2017-09-23 18:32:57 -04:00
Noam Postavsky
89eb7ab64d Release 0.12.2
* NEWS: Add changes for 0.12.2.
* yasnippet.el: Bump version.
* snippets: Update submodule.
0.12.2
2017-08-28 22:08:58 -04:00
Noam Postavsky
c79c8df599 Add yas-also-indent-empty-lines to allow old indent behavior
* yasnippet.el (yas-also-auto-indent-first-line): New option.
(yas--indent-region): Also indent empty lines if it's set.
* yasnippet-tests.el (yas-also-indent-empty-lines): New test.
2017-08-18 22:16:45 -04:00
Noam Postavsky
e371c119ec Don't keep region active when expanding from keymap
* yasnippet.el (yas-expand-snippet): Only keep region active if we are
going to field $0 and it has some text.
2017-08-08 12:40:33 -04:00
Noam Postavsky
0463c75b63 Release 0.12.1
* NEWS: Changes for 0.12.1.
* yasnippet.el (yas--version): Bump version number.
0.12.1
2017-07-23 18:30:56 -04:00
Noam Postavsky
dd65fe6186 Add compile_all target, fix all compilation warnings
* Rakefile (.elc): Set byte-compile-force-lexical-warnings when
compiling.
(:compile_all): New target that compiles yasnippet-debug.el and
yasnippet-tests.el too.
* .travis.yml (script): Use it instead of `compile'.  Update cl-lib to
0.6.1.  Don't error on warnings for Emacs 24.3 on yasnippet-tests.el.
* yasnippet-debug.el: Don't use `yas--loaddir' if it's not
bound (e.g., when compiling).  Require `color' and `edebug' at
toplevel.  Check if `subr-x' defines `when-let'.
(yas-debug-snippet-vars): Remove, it was unused and broken.
* yasnippet-tests.el (yas-with-snippet-dirs, (yas-should-expand)
(yas--collect-menu-items, yas-should-not-expand, yas-mock-insert)
(yas-mock-yank, yas--key-binding, yas-make-file-or-dirs)
(yas-variables, yas-call-with-saving-variables)
(yas-call-with-snippet-dirs, special-mode, string-suffix-p): Move to
top section.
(yas-tests--ran-exit-hook): Rename from yas--ran-exit-hook, and move
to top-level.
* yasnippet.el (yas--letenv): Evaluate the FORMs of ENV.
2017-07-23 08:11:36 -04:00
Stefan Monnier
304c01a44a Fix some compilation warnings
* yasnippet-debug.el (yas--condition-cache-timestamp): Move it before first use.
(yas-debug-live-marker, yas-debug-live-range, yas-debug-snippet-vars)
(yas-debug-process-command-line): Remove or mark unused
variable/parameters.
(yas--letenv): Use `cl-progv'.
(yas--mirror-update-display): Remove unused SNIPPET parameter, update
caller.
2017-07-23 08:11:35 -04:00
Pierre Téchoueyres
7365f9ed40 Avoid to indent snippets having setup `(yas-indent-line 'fixed)'
Avoid `yas--auto-fill' call to `yas--update-mirrors' without setting
the snippet environment.

* yasnippet.el (yas--auto-fill): Reinstate snippet environment before
calling `yas--update-mirrors'.
2017-07-23 07:18:20 -04:00
Noam Postavsky
75cbf7251b Update NEWS, version number to 0.12, and snippets submodule
* NEWS: Update for 0.12 changes.
* snippets/: Update to latest.
* yasnippet-debug.el:
* yasnippet-tests.el:
* yasnippet.el: Update copright years.  Update version number to
0.12.0.
0.12.0
2017-07-17 22:46:04 -04:00
Noam Postavsky
2a3a0cd2b1 Update CONTRIBUTING.md information
* README.mdown: Note that bugs can be submitted to main Emacs list.
* CONTRIBUTING.md: Fix double spacing, remove carriage returns.
Tighten up commit message example.
2017-07-16 19:38:41 -04:00
Noam Postavsky
1436d211d2 ; Merge yasnippet-debug.el updates 2017-07-16 15:23:04 -04:00
Noam Postavsky
164acd6869 * yasnippet-debug.el (yas-debug-snippet): Show modified flag. 2017-07-16 15:19:35 -04:00
Noam Postavsky
b0e729b1de Optionally add undo list to debug info
* yasnippet-debug.el (yas-debug-undo): New variable.
(yas-toggle-debug-undo): New command.
(yas-debug-snippets): Print undo list if `yas-debug-undo' is non-nil.
2017-07-16 15:19:35 -04:00
Noam Postavsky
7b03ac2030 Handle dead snippets better
* yasnippet-debug.el (yas-debug-live-marker)
(yas-debug-ov-fom-start, yas-debug-ov-fom-end)
(yas-debug-live-range, yas--debug-format-fom-concise): Don't assume
snippet has markers, it could have been converted to integer position.
2017-07-16 15:19:34 -04:00
Noam Postavsky
2f5cb2e2ef Make yas-debug-process-command-line easier to debug
* yasnippet-debug.el (yas-debug-process-command-line): Allow giving
options programatically
2017-07-16 15:19:34 -04:00
Noam Postavsky
274406ee44 Provide command line interface from yasnippet-debug.el
yasnippet-debug.el can now be used to quickly test and debug a snippet
in a file.

* Rakefile (itests): New target, runs tests interactively.
* yasnippet-debug.el: Set lexical binding.
(when-let): Backwards compabtility definition.
(yas-debug-live-indicators, yas-debug-live-colors)
(yas-debug-recently-live-indicators, yas-debug-get-live-indicator)
(yas-debug-live-marker, yas-debug-ov-fom-start, yas-debug-ov-fom-end)
(yas-debug-live-range, yas-debug-with-tracebuf, yas-debug-snippet)
(yas-debug-target-buffer, yas-debug-target-snippets)
(yas-debug-snippets, yas-debug-process-command-line): New functions
and variables.
(yas-debug-test): Remove.
* yasnippet.el (yas--snippet-revive): List snippet identifier in debug
message.
(yas--post-command-handler): Allow the debugger to run.
2017-07-16 15:19:34 -04:00
Noam Postavsky
c98672eb54 Fixup yasnippet-debug.el
* yasnippet-debug.el: Replace cl with cl-lib, replace
yas--snippets-at-point with yas-active-snippets.
2017-07-01 17:40:51 -04:00
Noam Postavsky
65952e3054 Allow customizing overlay priority
* yasnippet.el (yas-overlay-priority): New custom option.
(yas--make-control-overlay, yas--make-move-active-field-overlay): Use
it.
2017-06-24 11:03:07 -04:00
Noam Postavsky
e8ed276e2c Make sure tests don't rely on running order
* yasnippet-tests.el (undo-indentation)
(undo-indentation-multiline): Call `yas-reload-all'.
2017-06-06 23:07:26 -04:00
Noam Postavsky
1a860bd50b Fix undo information recording for multiline snippets
* yasnippet.el (yas--get-indent-undo-pos): Renamed from
yas--return-first-indent-undo.
(yas-expand-snippet): Bind it to line beginning of snippet expansion
position.
* yasnippet-tests.el (undo-indentation, undo-indentation-multiline):
New tests for this and previous fix.
2017-06-05 22:40:02 -04:00
Noam Postavsky
6102ff5049 Handle undo of snippet 1st line indent properly
* yasnippet.el (yas--first-indent-undo)
(yas--return-first-indent-undo): New variables.
(yas-expand-snippet): Use them to collect the exact undo info from
indenting the first snippet line, rather than trying to reconstruct
it.
(yas--indent-region): Put undo info from indenting snippet's first
line into `yas--first-indent-undo' if `yas--return-first-indent-undo'
is non-nil.
2017-06-01 22:07:49 -04:00
Noam Postavsky
1043b6c557 Restore syntax-propertize-function before indenting mirrors
* yasnippet.el (yas--snippet-parse-create): End binding of
syntax-propertize-function once snippet field parsing is finished.
2017-05-18 20:53:40 -04:00
Noam Postavsky
82818e5460 Don't delete snippets more than once.
* yasnippet.el (yas--on-field-overlay-modification): Don't commit
snippet again if the the triggering overlay has already been deleted.
2017-05-16 21:46:49 -04:00
Noam Postavsky
1bf7a4cbae Fix field parsing in modes that use the `syntax-table' property
* yasnippet.el (yas--indent-parse-create): Let-bind
`parse-sexp-lookup-properties' to nil.
2017-05-11 21:24:53 -04:00
Noam Postavsky
0f6d82feae * .travis.yml: Use Emacs 25.2 2017-05-11 08:03:34 -04:00
Noam Postavsky
8797a31337 * doc/snippet-expansion.org: Complete sentence fragment. 2017-04-20 21:00:22 -04:00
Noam Postavsky
462f5667fc Don't leave unreadable objects in the undo list
* yasnippet.el (yas--commit-snippet): Remove overlay object after
deleting it.
(yas--markers-to-points): Drop marker object.
(yas--points-to-markers): Create a new marker object.
2017-04-18 06:51:30 -04:00
Noam Postavsky
c3a94478b4 Fix condition timestamps in key filter functions
* yasnippet.el (yas--maybe-expand-key-filter):
(yas--maybe-expand-from-keymap-filter): Let-bind
`yas--condition-cache-timestamp' to the current time.
2017-04-17 16:03:15 -04:00
Noam Postavsky
47f37f70f4 Fix ${0:soon-to-be-deleted} with no other fields
* yasnippet.el (yas-expand-snippet): Unset `deactivate-mark'.
2017-04-09 23:44:34 -04:00
Noam Postavsky
394942130d Fix problems with auto-fill-mode interaction
* yasnippet-tests.el (auto-fill-with-multiparagraph): New test.
* yasnippet.el (yas--auto-fill): Don't snapshot markers outside of
current paragraph.
(yas--goto-saved-location, yas--snapshot-marker-location): Count
newlines as whitespace (even if mode marks them as non-whitespace
syntax, e.g., comment end).
(yas--snapshot-overlay-location, yas--restore-overlay-location): Don't
snapshot overlay position which is outside of BEG .. END.
2017-04-08 19:07:26 -04:00
Noam Postavsky
1babe81f7e * yasnippet.el (yas-about): Fix compile warnings in previous commit. 2017-04-07 22:28:00 -04:00
Noam Postavsky
ca04f69c10 Make `yas-about' more informative
* yasnippet.el (yas--loaddir): New constant.
(yas-installed-snippets-dir): Use it to compute value.
(yas-about): Get version from git or `package' if available.
2017-04-07 22:09:04 -04:00
Noam Postavsky
5043a96121 Correctly wrap auto-fill-function when it's toggled on later
* yasnippet.el (yas--auto-fill-wrapper): New function, extracted from
`yas-minor-mode'.
(yas-minor-mode): Call it, and it to `auto-fill-mode-hook'.
2017-03-26 13:30:28 -04:00
Noam Postavsky
b4d2f9cb4e Update snippets submodule 2017-03-26 11:00:48 -04:00
Noam Postavsky
22eeb1ef0e Fix interaction with c auto-fill
Save and restore all snippet marker and overlays in the current
paragraph around auto-fill calls.  Extend the marker/overlay snapshot
and restore mechanisms to work in multiline regions.

* yasnippet.el (yas-minor-mode): Install our auto-fill function around
the default one.
(yas--original-auto-fill-function): New variable.
(yas--auto-fill): New function, saves snippet markers & overlays,
calls original auto-fill-function, then restores markers and overlays.
(yas--snapshot-marker-location): Take new optional parameters BEG END,
allow for newlines in whitespace sequences (even if newline doesn't
have whitespace syntax).
(yas--snapshot-overlay-location): New function, takes BEG END,
produced non-line based location snapshots.
(yas--snapshot-overlay-line-location): Renamed from old
`yas--snapshot-overlay-location' function.
(yas--restore-overlay-line-location): Renamed from old
`yas--restore-overlay-location' function, narrow to line before calling
`yas--goto-saved-location'.
(yas--goto-saved-location): Use whole narrowed buffer instead of
assuming current line.
(yas--restore-overlay-location): New function, assume whole narrowed
buffer may be used.
(yas--prepare-snippets-for-move, yas--finish-moving-snippets):
(yas--indent-region): Adjust callers.
2017-03-26 10:15:31 -04:00
Noam Postavsky
30913fdfb7 Only update live snippets
* yasnippet.el (yas--snippet-live-p): New function.
(yas--on-field-overlay-modification): Use it to avoid updating a dead
snippet, give a warning instead.
2017-03-23 00:06:18 -04:00
Noam Postavsky
c5fddf8cec Restore syntax-propertize-function before indenting snippet
* yasnippet.el (yas--snippet-parse-create): Some modes require correct
syntax-propertizing to indent properly.
2017-03-22 21:29:01 -04:00
Noam Postavsky
63f44b4e48 Ensure inhibit-modification-hooks is nil while modifying buffer
* yasnippet.el (yas--on-field-overlay-modification): Bind
inhibit-modification-hooks to nil so that other packages' hooks can
run, yas--inhibit-overlay-hooks so that we won't run recursively.
2017-03-11 22:25:50 -05:00
Noam Postavsky
7f337f4488 Fix nested snippet expansion
* yasnippet.el (yas--place-overlays): Don't move active field overlays
unless we're working on the innermost snippet.
(yas--move-to-field): Keep `yas--active-field-overlay's `yas--snippet'
property in sync with its `yas--field' property.
* yasnippet-tests.el (nested-snippet-expansion-1): Rename from
nested-snippet-expansion-1.
(nested-snippet-expansion-2, nested-snippet-expansion-3): New tests.
2017-03-10 20:24:38 -05:00
Etienne
0d9afb2c69 Fix mirror transformation error with expand-env
* yasnippet.el (yas-expand-snippet): Use the snippet's bindings when
moving to the first field.  This prevents getting an error when using
a variable defined in expand-env.
* yasnippet-tests.el (snippet-mirror-bindings): New test, check if
mirror transformations have access to variables defined in the snippet
environment.
2017-03-09 13:50:06 -05:00
Etienne
6e9b7f9432 Fix running hook variable set as buffer-local
* yasnippet.el (yas--eval-for-effect): Use `yas--safely-call-fun'
instead of `yas--safely-run-hook'.
(yas--safely-call-fun): Display the called argument (even a lambda) on
errors.
(yas--safely-run-hook): Take a hook variable instead of the hook value
itself.  Use `run-hooks' to take buffer-local values into account.
This means it’s no longer possible to warn which hook function had an
error.
(yas--check-commit-snippet): Refactor to conform to
`yas--safely-run-hooks'.
* yasnippet-tests.el (snippet-exit-hooks-bindings): New test that
checks for buffer-local, global and env hooks support.
2017-02-26 19:38:32 -05:00
Noam Postavsky
cddb8260a0 Merge: let snippets expand in strings/comments by default
Also make yas-buffer-local-condition into a defcustom.
2017-02-16 22:28:31 -05:00
Noam Postavsky
14819c931f Make yas-buffer-local-condition into a defcustom
* yasnippet.el (yas-not-string-or-comment-condition): New constant,
holding the previous default value of `yas-buffer-local-condition'.
(yas-buffer-local-condition): Make into defcustom.
2017-02-16 22:27:15 -05:00
Noam Postavsky
4f37afd493 Let snippets expand in strings/comments by default
* yasnippet.el (yas-buffer-local-condition): Change default to t.
* doc/snippet-expansion.org: Update documentation.
2017-02-16 22:27:15 -05:00
Noam Postavsky
c87afe0901 Merge: snippet-local exit hook; error handling improvements 2017-02-12 11:32:27 -05:00
Noam Postavsky
f3d0e03a05 * yasnippet-tests.el (snippet-exit-hooks): New test. 2017-02-05 15:23:18 -05:00