1226 Commits

Author SHA1 Message Date
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
Noam Postavsky
fa6a71c42d ; Wait until post-command, or bad auto-fill call to print stacktrace
If we popup a warning as soon as yas--original-auto-fill-function is
changed to nil, we'll have false positives in cases where
auto-fill-function was *also* going to be turned nil afterwards.

* yasnippet.el (yas--watch-auto-fill-backtrace): New variable, to save
backtrace into.
(yas--watch-auto-fill): Check both yas--original-auto-fill-function
and auto-fill-function, but only save the backtrace, don't popup the
debugger.
(yas--auto-fill): Also print the saved backtrace if
yas--original-auto-fill-function is nil.
(yas--post-command-handler): Print the saved backtrace if
yas--original-auto-fill-function and auto-fill-function is
yas--auto-fill, which means we're in a bad state.
2018-03-19 09:07:34 -04:00
Noam Postavsky
a0d2cff79b ; Don't enter debugger for kill-all-local-variables case
* yasnippet.el (yas--watch-auto-fill): If we're called from
kill-all-local-variables, we don't need to check this, because
auto-fill-function will shortly be set to nil as well.
2018-03-18 09:39:00 -04:00
Noam Postavsky
ae95810289 ; Try to get more info about 873/919
* yasnippet.el (yas--watch-auto-fill): New variable watcher to catch
the problem.
(yas--auto-fill): If `yas--original-auto-fill-function' is nil, print
a warning with some info instead of signaling an error.
2018-03-17 07:31:54 -04:00
Noam Postavsky
5170f051ad Don't indent first and only line of expanded snippet
Unless yas-also-auto-indent-first-line applies.
* yasnippet.el (yas--indent): Check that forward-line successfully
moved 1 line forward before trying to indent.
* yasnippet-tests.el (yas-indent-first-line)
(yas-indent-first-line-fixed): New tests.
2018-03-10 19:14:42 -05:00
Noam Postavsky
15761e85d6 Adjust previous fix
* yasnippet.el (yas--indent): Call `beginning-of-line' before doing
fixed indentation.
2018-03-06 07:24:57 -05:00
Noam Postavsky
4467e934f3 Use fancy field adjustment for fixed indent too
* yasnippet.el (yas--indent): When `yas-indent-line' is `fixed',
instead of calling `indent-to-column' on each line directly, bind
`indent-line-function' and use `yas--indent-region'.  The latter uses
some clever tricks to keep field regions from extending into the newly
created whitespace.
2018-03-04 19:07:12 -05:00
Noam Postavsky
58b88d8be6 Merge: doc style improvements 2018-03-04 19:05:57 -05:00
Noam Postavsky
d364425176 * yasnippet.el (yas-field-value): Fix docstring. 2018-03-04 19:02:36 -05:00
Noam Postavsky
3032337831 Improve rendering of docstrings in manual's reference section
* doc/yas-doc-helper.el (yas--org-raw-html): Accept an ATTRS argument.
(yas--document-symbol): Render variables with <code
class='variable>... and functions with <code
class='function'>... instead of =...=.  Render indented lisp
forms (recognized as lines beginning 4+ spaces followed by open paren)
with #+BEGIN_SRC elisp...#+END_SRC.  Render \\{keymap} with
substitute-command-keys and #+BEGIN_EXAMPOE...#+END_EXAMPLE.  Link
"Info node `(manul) Node Name'" to gnu.org manual page.
* yasnippet.el (yas-prompt-functions): Add spaces to make example lisp
form be recognized as lisp.
2018-03-04 19:02:36 -05:00
Noam Postavsky
e261832b1a Add some styling to doc, improve top menu
* doc/snippet-expansion.org:
* doc/snippet-organization.org: Fix typos.
* doc/stylesheets/manual.css: Add some simple styling.  Mainly, this
sets 'max-width' for the main text, and centers it.  Adjust the
background color.
* doc/nav-menu.html.inc: Adjust 'class' of top menu.
* doc/yas-doc-helper.el (yas--make-preamble): New function, used for
:html-preamble.  It sets the element for the current page in the top
menu as bolded text to aid navigation.
* doc/stylesheets/styles.css: Remove, it was unused since the old rst
manual was removed.
2018-03-04 19:02:24 -05:00
Noam Postavsky
0afc638e16 Fix docs for new org mode
* Rakefile: Comment to remind me how to run it.
* doc/snippet-expansion.org:
* doc/snippet-menu.org: It seems org 9.x got a bit stricter about link
formatting.  Cross-file links *must* use the 'file:' prefix.
* doc/yas-doc-helper.el (yas--document-symbol): Org 9.x also got a bit
more strict about empty lines between a node and its property list.
Make sure not to put a blank line between variable nodes and the
property list.
2018-03-04 18:56:26 -05:00
Noam Postavsky
3d7cafccf8 Make yas-snippet-mode-buffer-p robust against symlinks
* yasnippet.el (yas-snippet-mode-buffer-p): Instead of a string
comparison of file names to check whether the buffer file is in on of
the `yas-snippet-dirs', use the builtin `file-in-directory-p'
function.
2018-02-18 07:59:33 -05:00
Noam Postavsky
cf23537279 Fix expansion of commands snippet
The previous changed failed to account for command snippets which have
lists for bodies, not strings.
* yasnippet.el (yas-expand-snippet): Don't error if SNIPPET is a list
representing a command snippet body.
* yasnippet-tests.el (yas-expand-command-snippet): New test.
2018-02-13 09:02:23 -05:00
Noam Postavsky
c9277d326e Change yas-lookup-snippet to return a yas--template struct
This allows proper handling of a snippet's expand-env field when doing

    (yas-expand-snippet (yas-lookup-snippet NAME))

* yasnippet.el (yas-expand-snippet): Return the yas--template struct
instead of snippet body.
(yas-expand-snippet): Let first argument be a yas--template struct.
* yasnippet-tests.el (snippet-lookup, snippet-load-uuid): Update tests
accordingly.
(yas-lookup-snippet-with-env): New test.
2018-02-11 17:42:24 -05:00
Noam Postavsky
05ac1da894 ; yasnippet-tests.el (yas-no-memory-of-bad-snippet): Fix docstring. 2018-02-07 18:37:00 -05:00
Noam Postavsky
caf3dba320 Don't use global variable for backquote expression locations
* yasnippet.el (yas--backquote-markers-and-strings): Remove.
(yas--save-backquotes): Return list of backquote expressions.
(yas--restore-backquotes): Receive it as a parameter.
(yas--snippet-parse-create): Keep it in a local variable.
* yasnippet-tests.el (yas-no-memory-of-bad-snippet): New test.
2018-02-04 19:13:48 -05:00
Noam Postavsky
7c9edb5b34 ; doc/snippet-development.org: Further copy edit. 2018-02-02 09:57:16 -05:00
Joerg Bornemann
60666310af Fix typos in "Writing Templates" documentation
* doc/snippet-development.org: Fix typos.

Copyright-paperwork-exempt: yes
2018-02-02 09:53:32 -05:00
Noam Postavsky
ba73f20bc3 Bind field skip and clear command conditionally
Rather than embedding the conditionality inside the function body, and
hardcoding fallback to `delete-char'.  This allows users who want, for
example, to use backspace for field skipping to simply do

    (define-key yas-minor-mode-map (kbd "DEL")
      yas-maybe-skip-and-clear-field)

* yasnippet.el (yas-skip-and-clear-field, yas-current-field)
(yas--maybe-clear-field-filter): New command and function, extracted
from yas-skip-and-clear-or-delete-char.
(yas-skip-and-clear-or-delete-char): Mark obsolete.
(yas-maybe-skip-and-clear-field): New constant, for conditional
binding.
(yas-keymap): Bind it to `C-d' instead of
`yas-skip-and-clear-or-delete-char'.
* yasnippet-tests.el (delete-numberless-inner-snippet-issue-562): Use
`yas-skip-and-clear-field' instead of
`yas-skip-and-clear-or-delete-char'.
2018-02-02 09:52:10 -05:00
Noam Postavsky
074d670be4 Add yasnippet-unload-function
* yasnippet.el (yasnippet-unload-function): New function.
* yasnippet-debug.el (yas-exterminate-package): Remove, it was only
doing a partial job of undoing modes, and uninterning is entirely not
needed.
* yasnippet-tests.el (yas-unload): New test.
2018-01-31 08:11:04 -05:00
Noam Postavsky
e35c031410 * yasnippet.el (yas--guess-snippet-directories): Guess major mode first. 2018-01-31 07:44:35 -05:00
Noam Postavsky
2e69471df2 ; yasnippet-debug.el: macroexp-progn is not avaiable in Emacs 23. 2018-01-31 07:39:37 -05:00
Noam Postavsky
ff8e833375 ; yasnippet-debug.el: Fix deprecation warning. 2018-01-31 07:37:48 -05:00
Noam Postavsky
6ffd1c7950 ; .travis.yml: Test with 25.3 and 26 prelease. 2018-01-31 06:36:35 -05:00
Noam Postavsky
fe9f8b6c98 ; yasnippet-debug.el: Update yas-debug-snippets arg for previous change. 2018-01-31 06:34:43 -05:00
João Távora
8b421bc78d Reinstate the old debug behaviour for yas-tryout-snippet
During a redesign of the debug facilities, the old shortcut C-u C-t
available and useful in snippet-mode, was lost.

* yasnippet-debug.el (yas-debug-snippets): Add docstring.
Add post-command-hook locally if HOOK is snippet-navigation.
Concisely describe parent field (not just mention it).

* yasnippet.el (yas-tryout-snippet): Call yas-debug-snippets and display
buffer.  Tweak docstring.
(yas-debug-snippets): Forward declare function defined in
yasnippet-debug.el
2018-01-24 22:45:14 +00:00
João Távora
ff26e3ba7f Close #824: Simple fields can be parented like other fields or mirrors
The fact that they didn't prevented a deletion of the parent field to
also delete the child, confusing snippet navigation.

* yasnippet-tests.el (delete-nested-simple-field-issue-824): Add a
test for this issue.

* yasnippet.el (yas--calculate-simple-fom-parentage): Renamed from
yas--calculate-mirrors-in-fields.  Generalize to FOMs.
(yas--transform-mirror-parse-create): Call yas--simple-fom-create
and yas--calculate-simple-fom-parentage.
(yas--simple-fom-create): Rename from
yas--simple-mirror-parse-create.  Call
yas--calculate-simple-fom-parentage also for fields.
2018-01-24 22:45:02 +00:00
Noam Postavsky
16c2b38bce Update `yas--take-care-of-redo' call in buffer undo list
On 2018-01-01 "Fix undo when first line indentation moves snippet
forward", `yas--take-care-of-redo' removed the BEG and END arguments,
but the call added to `buffer-undo-list' from `yas--snippet-revive',
was not updated accordingly.

* yasnippet.el (yas--snippet-revive): Remove `beg' and `end' from
`yas--take-care-of-redo' entry.
* yasnippet-tests.el (undo-redo): New test.
2018-01-21 15:13:25 -05:00
Noam Postavsky
203059a95e * yasnippet.el (yas-key-syntaxes): Prefer the longest key. 2018-01-11 18:33:53 -05:00
Noam Postavsky
ad3a4d192d Don't use prog-mode in older Emacs
* yasnippet.el (snippet-mode): Derive from prog-mode only if it's
fbound.
* yasnippet-tests.el (extra-modes-parenthood)
(loading-with-cyclic-parenthood): Fix comment typo.
2018-01-11 18:28:41 -05:00
Noam Postavsky
d806b04fc0 * yasnippet.el (snippet-mode): Derive from prog-mode. 2018-01-11 18:28:41 -05:00
Noam Postavsky
04062d8b4f Don't set yas-selected-text to non-selected text
* yasnippet.el (yas-expand-snippet): Only use the `to-delete' text if
`region-active-p' return true.
* yasnippet-tests.el (expand-with-unused-yas-selected-text): New test.
2018-01-02 21:24:48 -05:00
Noam Postavsky
ce11fd6690 * yasnippet.el (yas-reload-all): Mention if no snippets were found. 2018-01-01 15:11:56 -05:00
Noam Postavsky
b1ca219706 Remove submodules (snippet and yasmate)
* snippets:
* yasmate: Remove.
* README.mdown: Suggest yasnippet-snippets and yasmate as possible
things to download rather than submodules.
* yasnippet.el (yas-installed-snippets-dirn): Mark obsolete.
(yas-snippet-dirs): Remove `yas-installed-snippets-dir' from
default value.
2018-01-01 15:11:55 -05:00
Noam Postavsky
ee81da91d9 Allow "# --" end-of-header marker to have trailing space
* yasnippet.el (yas--parse-template): Allow trailing space after "#
--" marker.
2018-01-01 15:09:32 -05:00
Noam Postavsky
1292cd263a Refactor undo tests
* yasnippet-tests.el (yas-test-expand-and-undo): New helper function.
(undo-indentation-1, undo-indentation-2, undo-indentation-multiline-1)
(undo-indentation-multiline-2): Use it.
2018-01-01 15:07:01 -05:00
Noam Postavsky
7ea1305e67 Fix undo when first line indentation moves snippet forward
* yasnippet.el (yas--first-indent-undo, yas--get-indent-undo-pos):
Remove.
(yas-expand-snippet): Move undo-related code from here...
(yas--snippet-create): ... to here.  Collect undo information from
yas--indent in the normal, unsuppressed way.
(yas--indent-region): Don't collect undo information specially.
(yas--take-care-of-redo): Remove unused parameters.
* yasnippet-tests.el (undo-indentation-1): Rename from
undo-indentation.
(undo-indentation-2): New test.
(undo-indentation-multiline-1): Rename from
undo-indentation-multiline.
(undo-indentation-multiline-2): New test.
2018-01-01 15:07:01 -05:00