diff --git a/oni-yasnippet.el b/oni-yasnippet.el index 46a9e95..1e4d7f2 100644 --- a/oni-yasnippet.el +++ b/oni-yasnippet.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2021.0919.235328 +;; Version: 2023.0712.232619 ;; Package-Requires: (yasnippet yasnippet-snippets diminish) ;; This program is free software; you can redistribute it and/or modify @@ -34,6 +34,20 @@ (require 'yasnippet) (require 'diminish) +(defun oni-yasnippet-remove-snippet-by-name (name mode) + "Remove the snippet NAME from MODE's snippet tables." + (let* ((mode-table (gethash mode yas--tables)) + (uuidhash-table (yas--table-uuidhash mode-table)) + (hash-table (yas--table-hash mode-table)) + (snippet (gethash name uuidhash-table)) + (key (yas--template-key snippet))) + (remhash key hash-table) + (remhash name uuidhash-table))) + +(defun oni-yasnippet-cleanup-snippets () + "Remove some snippets that I don't like." + (oni-yasnippet-remove-snippet-by-name "defun" 'lisp-interaction-mode)) + (with-eval-after-load 'yasnippet (diminish 'yas-minor-mode)) (setq-default yas-buffer-local-condition yas-not-string-or-comment-condition) @@ -43,5 +57,7 @@ (define-key yas-minor-mode-map (kbd "SPC") yas-maybe-expand) (define-key yas-minor-mode-map (kbd "TAB") nil) +(add-hook 'yas-after-reload-hook #'oni-yasnippet-cleanup-snippets) + (provide 'oni-yasnippet) ;;; oni-yasnippet.el ends here