Ayah extends auto-yasnippet with snippet history features.
- Expand a snippet from history
- Persist a snippet from history
To manage history there are also commands (next/previous) in history, delete a snippet from history and clear history.
Ayah is pending addition to MELPA.
Install manually. Clone to your machine:
git clone https://github.com/emacsfodder/ayah
Add this to your Emacs init:
(add-to-list 'load-path "/path/to/ayah")
(require 'ayah)
Install using straight.el
(straight-use-package
'(ayah :type git :host github :repo "emacsfodder/ayah"))
Install with Doom Emacs.
(package! ayah :recipe (:host github :repo "emacsfodder/ayah"))
The first time you try to access any history features Ayah will hook up to Auto-yasnippet.
To manually initialize call (ayah-setup)
, for example:
(use-package auto-snippet
:config
(require 'ayah)
(ayah-setup))
Select and expand from snippets in ayah-history
. The selected
snippet will become aya-current
.
Set aya-current
to the next or previous in ayah-history
.
Functionally equivalent to aya-persist-snippet
in but using a snippet selected
from ayah-history
Select and delete a snippet from ayah-history
. The next available
snippet will become aya-current
. When there are no other snippets
available aya-current
will be set to ""
.
Completely clear snippet history (ayah-history
and aya-current
will be cleared).
In your Emacs init file bind keys to the ayah
commands.
For example:
(global-set-key (kbd "C-c C-a SPC") 'ayah-expand-from-history)
(global-set-key (kbd "C-c C-a n") 'ayah-next-in-history)
(global-set-key (kbd "C-c C-a p") 'ayah-previous-in-history)
(global-set-key (kbd "C-c C-a C") 'ayah-clear-history)
(global-set-key (kbd "C-c C-a D") 'ayah-delete-from-history)
(global-set-key (kbd "C-c C-a W") 'ayah-persist-snippet-from-history))
You can set the key bindings to those above using:
M-x ayah-default-bindings