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.
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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
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.
* 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).
* 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.
* 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.
* 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.
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.
* 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.
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.
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.
* 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.
* 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.
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.
* 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.
* 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.
* 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.
* 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.
* 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.
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.
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.
* 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.
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'.
* 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.