(require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (package-refresh-contents) (package-initialize) (unless (package-installed-p 'ivy) (package-install 'ivy)) (unless (package-installed-p 'yasnippet-snippets) (package-install 'yasnippet-snippets)) (require 'yasnippet) (require 'ivy) (yas-reload-all) (switch-to-buffer "*scratch*") (lisp-interaction-mode) (yas-minor-mode-on) (let ((templates (mapcar #'yas--template-key (yas--all-templates (yas--get-snippet-tables))))) (defun update-fn () (with-current-buffer "*scratch*" (save-restriction (narrow-to-region 3 3) (insert " " (ivy-state-current ivy-last)) (yas-expand) (mapc #'yas-abort-snippet (yas-active-snippets))) (redisplay))) (let ((buffer-undo-list t)) (while t (erase-buffer) (insert "aaaaaa") (redisplay) (sit-for 0.1) (run-with-timer 0.01 nil (lambda () (dotimes (_ (% (random) 15)) (execute-kbd-macro "\C-n") (sit-for 0.05) (redisplay) (when (zerop (% (random) 4)) (execute-kbd-macro "\C-p") (sit-for 0.05) (redisplay))) (sit-for 0.1) (redisplay) (abort-recursive-edit))) (catch 'exit (condition-case err (ivy-read "foo: " templates :update-fn #'update-fn) (quit))))))