From e38bb344e4196aa2a1488e9611d1ccecdeb5acd6 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 12 Jul 2023 23:28:12 -0700 Subject: [PATCH] =?UTF-8?q?Remove=20the=20=E2=80=98defun=E2=80=99=20snippe?= =?UTF-8?q?t=20from=20=E2=80=98lisp-interaction-mode=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It always confuses me that it's defined in ‘lisp-interaction-mode’, but not in ‘emacs-lisp-mode’. ‘emacs-lisp-mode’ has the same basic snippet under the key ‘def’. --- oni-yasnippet.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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