GNU ELPA - yasnippet


Yet another snippet extension for Emacs
yasnippet-0.14.0.tar, 2019-Dec-23, 930 KiB
Noam Postavsky <>
Home page
Browse ELPA's repository
CGit or Gitweb

To install this package, run in Emacs:

M-x package-install RET yasnippet RET

Full description

  Basic steps to setup:

   (add-to-list 'load-path
   (require 'yasnippet)
   (yas-global-mode 1)

  Interesting variables are:


          The directory where user-created snippets are to be
          stored.  Can also be a list of directories.  In that case,
          when used for bulk (re)loading of snippets (at startup or
          via `yas-reload-all'), directories appearing earlier in
          the list override other dir's snippets.  Also, the first
          directory is taken as the default for storing the user's
          new snippets.

          The deprecated `yas/root-directory' aliases this variable
          for backward-compatibility.

  Major commands are:

      M-x yas-expand

          Try to expand snippets before point.  In `yas-minor-mode',
          this is normally bound to TAB, but you can customize it in

      M-x yas-load-directory

          Prompts you for a directory hierarchy of snippets to load.

      M-x yas-activate-extra-mode

          Prompts you for an extra mode to add snippets for in the
          current buffer.

      M-x yas-insert-snippet

          Prompts you for possible snippet expansion if that is
          possible according to buffer-local and snippet-local
          expansion conditions.  With prefix argument, ignore these

      M-x yas-visit-snippet-file

          Prompts you for possible snippet expansions like
          `yas-insert-snippet', but instead of expanding it, takes
          you directly to the snippet definition's file, if it

      M-x yas-new-snippet

          Lets you create a new snippet file in the correct
          subdirectory of `yas-snippet-dirs', according to the
          active major mode.

      M-x yas-load-snippet-buffer

          When editing a snippet, this loads the snippet.  This is
          bound to "C-c C-c" while in the `snippet-mode' editing

      M-x yas-tryout-snippet

          When editing a snippet, this opens a new empty buffer,
          sets it to the appropriate major mode and inserts the
          snippet there, so you can see what it looks like.  This is
          bound to "C-c C-t" while in `snippet-mode'.

      M-x yas-describe-tables

          Lists known snippets in a separate buffer.  User is
          prompted as to whether only the currently active tables
          are to be displayed, or all the tables for all major

  If you have `dropdown-list' installed, you can optionally use it
  as the preferred "prompting method", putting in your .emacs file,
  for example:

      (require 'dropdown-list)
      (setq yas-prompt-functions '(yas-dropdown-prompt

  Also check out the customization group

       M-x customize-group RET yasnippet RET

  If you use the customization group to set variables
  `yas-snippet-dirs' or `yas-global-mode', make sure the path to
  "yasnippet.el" is present in the `load-path' *before* the
  `custom-set-variables' is executed in your .emacs file.

  For more information and detailed usage, refer to the project page:

Old versions

yasnippet-0.13.0.tar2018-May-13 910 KiB
yasnippet-0.12.2.tar2017-Aug-291.47 MiB
yasnippet-0.12.1.tar2017-Jul-241.47 MiB
yasnippet-0.12.0.tar2017-Jul-181.47 MiB
yasnippet-0.11.0.tar2016-Oct-281.44 MiB
yasnippet-0.10.0.tar2016-Jun-111.44 MiB
yasnippet-0.9.1.tar2016-Apr-041.42 MiB
yasnippet-0.8.0.tar.lz2012-Nov-2962.2 KiB


Yasnippet NEWS -- history of user-visible changes.

Copyright (C) 2017-2019 Free Software Foundation, Inc.
See the end of the file for license conditions.

* 0.14.0 (Dec 22, 2019)

** Changes

*** New 'yas-auto-next' macro, automatically moves to next field.
See Github #937.

*** Yasnippet now officially requires Emacs 23 or greater.
See Github #940.

*** Snippets for 'fundamental-mode' are available in all modes.
See Github #949, and #936.

*** New function for snippets, 'yas-completing-read'.
See Github #934.

*** New function 'yas-maybe-expand-abbrev-key-filter'.
This can be used for making conditional keybindings for snippets.
Promoted from 'yas--maybe-expand-key-filter'.  See Github #943.

*** DEL can now be used to clear fields, similar <delete>.
It is bound to the new conditional command 'yas-maybe-clear-field', which may
be bound to other keys as well.  See Github #960 and #957.

*** Snippet field movement commands may now trigger eldoc.
See Github #952.

*** New variable 'yas-keymap-disable-hook'.
Can be used (e.g., for company-mode) to temporarily disable
'yas-keymap' bindings, or any binding made by the new function
'yas-filtered-definition'.  See Github #987.

*** New variable 'yas-inhibit-overlay-modification-protection'.
This allows a snippet to remain active, even if some commands make
modifications outside the expected area (i.e., the active snippet

*** 'yas-minor-mode' is no longer enabled in temp buffers.
That is, buffers whose name starts with a space.  This setting may be
undone by removing 'yas-temp-buffer-p' from
'yas-dont-activate-functions'.  See Github #985.

*** Accept unescaped '{', for LSP compatibility.
See Github #979.

** Fixed bugs

*** 'yas-not-string-or-comment-condition' no longer relies on 'this-command'.
This lets it work correctly with conditional key-bindings.  See Github
#973, #991.

*** Fix snippet expansion in org src buffers.
Note that this still doesn't work in text-mode blocks.
See Github #976, #989.

*** Fix snippet insertion for keyless snippets.
See Github #1014.

*** Fix errors with company-mode completion within snippet fields.
See Github #995.

*** Fix errors with cc-mode.
See Github #962.

*** Fix problems with lsp-mode.
**** Improve performance in overlay heavy buffers (Github #926).
**** Fix double call of 'before/after-change-functions' (Github #966).

*** Fix errors with nested snippet expansion.
See Github #961, #1002.

*** Stop yas-field-highlight-face inheriting from bogus 'quote' face.

* 0.13.0 (May 13, 2018)

** Changes

*** Snippets for Yasnippet must now be installed separately.  The
submodule linking to yasnippet-snippets was removed, as were the
"classic" snippets that came with the GNU ELPA package.  The latter
can now be installed via the 'yasnippet-classic-snippets' package from
See Github #848, #858, #834, #775.

*** 'snippet-mode' no longer derives from 'text-mode'.
It will derive from 'prog-mode' where available (Emacs 24.1 and newer)
or 'fundamental-mode' otherwise.  See Github #826.

*** The default value of 'yas-key-syntaxes' is changed
Longer snippet abbrev keys are now preferred over shorter ones.
See Github #805.

*** New snippets are now created for the current major mode by default
Previously, extra activated modes could be guessed first.
See Github #875.

*** Yasnippet supports 'unload-feature' via 'yasnippet-unload-function'
See Github #753, #891.

*** New command 'yas-skip-and-clear-field' conditionally bound to 'C-d'
replaces obsoleted 'yas-skip-and-clear-or-delete-char'.  The new
function may be bound to any key via the conditional binding value
'yas-maybe-skip-and-clear-field', instead of hardcoding the
'delete-char' fallback action.  See Github #408, #892.

*** 'yas-lookup-snippet' now returns a struct
This allows 'yas-expand-snippet' to take looked up snippet's
environment into account.  'yas-expand-snippet' handles both
structured snippets, and plain text snippet bodies.
See Github #897.

** Fixed bugs

*** Avoid crashing due to Emacs Bug#30931
This prevents yasnippet's routines from triggering the bug, although
it is still possible to trigger it independently.

*** Don't enable undo when it's disabled

*** yas-also-auto-indent-first-line is once again respected
Yasnippet was behaving as if it was always t for single line snippets.
See Github #912.

*** Fixed handling of fixed indent with fields at beginning of line
See Github #906, #908.

*** Fixed incorrect snippets leaving "bad memory"
and possibly corrupting future expansions.
See Github #800.

*** 'global-whitespace-mode' now functions in new snippet buffers.
To fix this, the buffer name for new snippet buffers is now '+new
snippet+' instead of '*new snippet*'.  See Github #842.

*** Nest snippet expansion may clear default field text
See Github #844.

*** Fixed undo list corruption snippet expand+indent.
See Github #869.

*** The '# --' marker in snippets now allows trailing whitespace.
See Github #862.

*** Fixed handling of nested simple $n fields
See Github #824, #894.

* 0.12.2 (Aug 28, 2017)

** The new option 'yas-also-auto-indent-empty-lines' allows restoring
the old indent behavior.  See Github #850, #710, #685, #679.

** Keybinding triggered snippets once again deactivate the mark.
See Github #840.

* 0.12.1 (Jul 23, 2017)

This is a quick bugfix release.

** Compilation errors in yasnippet-tests.el and yasnippet-debug.el are fixed.

** A snippet-local setting of 'yas-indent-line' is now respected
during indentation triggered by auto-fill as well.  See Github #838.

* 0.12.0 (Jul 17, 2017)

** Changes and New Features

*** Snippets can now expand in strings & comments by default again.
'yas-buffer-local-condition' is now a defcustom See Github #774.

*** 'yas-after-exit-snippet-hook' can now be bound in 'expand-env' of
snippets.  See Github #28, #702, #779, #786.

*** Snippets under directories in 'yas-snippet-dirs' are now in
snippet-mode automatically.

*** Snippets can now be expanded in org source blocks, if
'org-src-tab-acts-natively' and 'org-src-fontify-natively' are set.
See Github #761.

*** 'yas-fallback-behavior' is now obsolete, 'yas-expand' is now bound
conditionally with an extended menu item, 'yas-maybe-expand'.
Therefore users wanting to bind 'yas-expand' to a different key, SPC
for example, should do

    (define-key yas-minor-mode-map (kbd "SPC") yas-maybe-expand)

See Github #760, #808.

*** The documentation build output is now reproducible.  The timestamp
now depends on the commit date, or the environment variable
SOURCE_DATE_EPOCH is that is set.

*** 'yas-indent-line' and 'expand-env' are now respected during mirror
updates.  See Github #743.

*** New function 'yas-active-snippets'.  Renamed from
'yas--snippets-at-point', which remains as an obsolete alias.  See
Github #727.

*** New custom option 'yas-overlay-priority'.  This is can be used to
give the snippet navigation keymaps higher priority than keymaps from
overlays created by other packages, like 'auto-complete'.  See Github

** Fixed bugs

*** Snippets having ${0:soon-to-be-deleted} with no other fields now
correctly put the field 0 text in the active region after exiting.
See Github #653.

*** Fix undo of snippet insertion which also triggers indentation.
See Github #821.

*** Fixed a bug causing whitespace loss between mirrors.

*** Fixed several bugs causing problems when combining Yasnippet with
other modes and packages, like 'auto-fill-mode', 'c++-mode',
'rust-mode', and 'lentic'.

**** Fix another bug with auto-fill-mode.
See Github #784, #794.

**** Fix a bug in parsing of snippet fields for modes that use the
'syntax-table' text property, 'c++-mode' is one example of this.  See
Github #815.

**** 'syntax-propertize-function' is now restored before indenting the
snippet.  This improves compatibility with modes which rely on it for
indentation, like 'rust-mode'.  See Github #782, #818.

**** Avoid trying to delete a snippet which is already deleted.  This
prevents an error when using 'rust-mode's 'rust-format-buffer'

**** Ensure inhibit-modification-hooks is nil while modifying buffer.
This fixes problems for packages relying on modification hooks, like
'lentic'.  See Github #756, #712.

* 0.11.0 (Oct 26, 2016)
** Changes and New Features

*** Modifying buffer in backquoted expressions is deprecated!
Backquoted expressions should only return a string that will be
inserted.  Snippets which modify the buffer as a side-effect will now
trigger a warning.

*** The verbosity levels for messages have been adjusted.
While the default verbosity level was increased by 1 (it was only
lower before due to a bug), several messages now only print at the
level 4, so the overall effect should be less messages by default.

*** Saving and loading snippets has been streamlined.  Saving the
snippet to a file will now automatically load it.  Additionally, the
buffer will be renamed from "*new snippet*" to whatever the snippet is
named.  See also Github #718, #733, and #734.

*** `yas-escape-text' no longer signals an error when given nil.

*** `yas-describe-tables' is split into simpler commands.
**** `yas-describe-tables' takes a prefix arg to show non-active tables.
**** New command `yas-describe-tables-by-namehash' shows table by namehash.

*** Use the region contents as the snippet body of new snippets.

*** The dependency on `cl' is removed.
Yasnippet now only requires `cl-lib'.

** Fixed Bugs

*** Fix field navigation (tabbing) in the backwards direction.
See Github #722

*** Add support for deprecated yas/ symbols in `yas-define-menu'.
It was left out by accident.  This support is conditional on
`yas-alias-to-yas/prefix-p', just like other obsolete yas/ bindings.

*** Fix overriding of snippet by a new snippet with same uuid.
See Github #714.

*** Fix handling of snippets with 2 mirros on the same line.
See Github #712.

* 0.10.0 (June 11th, 2016)

** Changes and New Features

*** Yasnippet now prints far fewer message by default.
See Github #682, #683.

*** `yas-wrap-around-region' can be set to a register.
The register's content will be used.  This is like the old `cua'
option, but can be used with any register and doesn't require enabling

*** Clearing of snippet fields is now decided by the command's effect.
The `delete-selection' property is no longer consulted.  See Github #662.

*** Empty lines in snippet expansion are no longer indented.
See Github #679.

*** All lines from mirror output are now indented.
See Github #665.

*** New variable yas-alias-to-yas/prefix-p
See Github #696, #699.

*** New function yas-next-field-will-exit-p
See Github #561.

*** `snippet-mode' is now autoloaded.

** Fixed Bugs

*** Fix incompatibility with Emacs 25 and haskell-mode.
This should also help other modes with a non-nil syntax-propertize
function.  See Github #687.

*** Text property changes no longer disable snippets.
This prevents cc-mode based modes from causing premature exit of
snippets.  See Github #677.

*** Fields are now transformed correctly after `yas-next-field'.
See Github #381.

*** The $> construct is now escaped correctly, and documented.
See Github #640.

*** Avoid corruption of snippet content when loading from files.
See Github #707 and Emacs bug #23659.

*** `yas-wrap-around-region' now works for snippets with fields
farther down the buffer than $0.  See Github #636.

*** The active region is deleted when using `yas-expand'.
This makes it consistent with `yas-insert-snippet'.  See Github #523.

*** Fix mirror+autofill interaction.
See Github #643 and

*** Snippet insertion no longer adds irrelevant strings to kill ring.
See Github #675.

* 0.9.1 (April 3rd, 2016)

** Changes and New Features

*** Noam Postavsky is now the official yasnippet maintainer.

*** `yas-visit-snippet-file' now works for compiled snippets (see Github #597).

*** New function `yas-lookup-snippet' (see Github #595, #596).

*** .emacs.d/snippets directory is now created automatically.
If that value is present in `yas-snippet-dirs' (see Github #648).

*** Default value for `yas-snippet-dirs' now uses `user-emacs-directory'
instead of hardcoding "~/emacs.d" (see Github #632).

*** `yas-visit-snippet-file' no longer overrides `yas-prompt-functions',
see Github #576.

*** The defaults for prompting have changed.
`yas-x-prompt' is no longer present in the default value of

The new function `yas-maybe-ido-prompt' (which performs ido prompting
if `ido-mode' is enabled) replaces `yas-ido-prompt' (which always
performs ido prompting).  Previously the behaviour was dependent on
the Emacs version being used.

*** The default value of `yas-buffer-local-condition' now works for `yas-insert-snippet' too.
See Github #305.

*** The default value of `yas-new-snippet-default' no longer inserts `require-final-newline: nil'.
It was redundant, since `mode: snippet' already accomplishes the same.
`binding: ${4:direct-keybinding}}' is also removed, as it is hardly
ever wanted.

*** Snippet fields are only cleared by commands with `delete-selection' property,
See Github #515, #644.

*** `yas-initialize' (and backward compat alias `yas/initialize') are restored,
but marked obsolete, use (yas-global-mode +1) instead.  See Github
#546, #569.

*** `yas-key-syntaxes' is much more powerful and accepts functions.
Enables use cases when discovering keys based on buffer syntax is not
good enough.  See issue #497.

*** Documentation rewritten in org-mode and updated.
A tremendous effort by Noam Postavsky.  Hopefully easier to maintain
and navigate.  Available at <>.

*** Snippets are now maintained in their own repo.
Snippets live in Andrea Crotti's
<>.  See
for more details.

*** Textmate snippet importer moved to separate `yasmate' repo.
URL is <>.  See for
more details.

*** `yas-snippet-dirs' now allows symbols as aliases to directories.
The added level of indirection should allow more esoteric
configurations (see Github #495).

*** `yas-reload-all' can now jit-load when called interactively.

*** New `yas-after-reload-hook' run after `yas-reload-all'.
See <> for the discussion
leading up to this change.

*** New functions `yas-activate-extra-mode' and `yas-deactivate-extra-mode'.
These are preferable to setting `yas-extra-modes' directly in the mode
hook (see issue #420 for more information).

*** New variable `yas-new-snippet-default'.
The default snippet suggested on `yas-new-snippet' can now be

** Fixed bugs

*** `yas-expand' now sets `this-command' when falling back to another command.
Previously it was setting `this-original-command', which does not
match the documented semantics.  See Github #587.

*** Github #537: Be lenient to extensions operating on snippet fields.

*** Github #619: Parents of extra modes are now activated too.

*** Github #549: `yas-verbosity' is now applied to `load' calls too.

*** Github #607; avoid obscure Emacs bug triggered by overlays in *Messages* buffer.
It was triggered by yasnippet+flycheck+highlight-parentheses.  See
also <>

*** Github #617; fix x prompt when snippet inserts many lines.

*** Github #618; avoid breakage if `scan-sexp' modifies match data.
Which it does in Emacs 25.

*** Github #562: Deleting inner numberless snippet caused an error.

*** Github #418, #536: Fix navigation to zero-length fields at snippet end.

*** Github #527, #525 and #526: Attempt to prevent "fallback loops"
when interactiing with other extensions that use similar fallback

* 0.8.0 (August 2012)

** Changes and New Features

*** All YASnippet symbols now prefixed with `yas-'.  Keep old `yas/' versions as aliases.

*** Yasnippet is now Free Software Foundation's copyright.

*** `yas-dont-activate' can be a list of functions.

*** Snippets are loaded just-in-time .
Thanks to Matthew Fidler for a lot of input with the implementation.

*** yasnippet-bundle.el is no longer available.
Use `yas-compile-directory' instead if you need the speed advantage.

*** New functions `yas-compile-directory' and `yas-recompile-all'.
This feature is still undocumented.  Generate a
.yas-compiled-snippets.el file in the directory passed where snippets
are compiled into emacs-lisp code.

*** New `yas-verbosity' variable.

*** Interactively calling `yas-exit-snippet' exits most recently inserted snippet.

*** Using filenames as snippet triggers is deprecated.

*** Default value of `yas-show-menu-p' is `abbreviate'.

*** `yas-visit-snippet' ignores `yas-prompt-functions'.

*** `yas-buffer-local-condition' restricted to trigger-key expansions by default.

*** `yas-load-snippet-buffer' (`C-c C-c') in `snippet-mode' has been much improved.

*** New variable `yas-expand-only-for-last-commands', thanks Erik Postma.

*** New variable `yas-extra-modes' aliases old `yas/mode-symbol'.

*** New `yas-describe-tables' command.

*** New `yas-define-condition-cache' macro.
This defines an optimised function for placing in a `# condition:'
directive that will run at most once per snippet-expansion attempt.

*** Mirrors can occur inside fields.

*** New `# type: command' directive.
This feature is still largely undocumented.

*** A hidden .yas-setup.el is loaded if found in a snippet directory.

*** `yas-wrap-around-region' can now also be `cua' (undocumented feature).

*** Make menu groups automatically using new .yas-make-groups file.

*** Per-snippet keybindings using `# keybinding:' directive.

*** More friendly `yas-expand-snippet' calling convention.
This breaks backward compatibility.

*** The `# env:' directive is now `# expand-env:'.

*** Setup multiple parent modes using new .yas-parents file.

** Fixed bugs

*** Github #281: jit-load snippets in the correct order.

*** Github #245: primary field transformations work inside nested fields.

*** Github #242: stop using the deprecated `assoc' library.

*** Github #233: show direct snippet keybindings in the menu.

*** Github #194, Googlecode 192: Compatibility with `fci-mode'.

*** Github #147, Googlecode 145: Snippets comments were getting inserted.

*** Github #141, Googlecode 139: searching buffer in embedded elisp works slightly better.
Issue is still open for analysis, though

*** Github #95, Googlecode 193: no more stack overflow in org-mode.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
General Public License for more details.

Local variables:
coding: utf-8
mode: outline
paragraph-separate: "[ 	]*$"