From 5b315f1753480ebe669b157b8242448b5eafcfea Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 12 Jan 2025 17:51:54 -0500 Subject: [PATCH] Misc fixes found via compilation warnings * yasnippet-debug.el (yas-debug-snippets): Improve commit 009322196cfa. * yasnippet-tests.el (test-rebindings): Avoid `copy-keymap`. --- yasnippet-debug.el | 10 +++------- yasnippet-tests.el | 12 ++++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/yasnippet-debug.el b/yasnippet-debug.el index 798c7ce..6fd3e3f 100644 --- a/yasnippet-debug.el +++ b/yasnippet-debug.el @@ -1,6 +1,6 @@ ;;; yasnippet-debug.el --- debug functions for yasnippet -*- lexical-binding: t -*- -;; Copyright (C) 2010-2023 Free Software Foundation, Inc. +;; Copyright (C) 2010-2025 Free Software Foundation, Inc. ;; Author: João Távora ;; Keywords: emulations, convenience @@ -221,11 +221,9 @@ (setq yas-debug-undo value) (yas--message 3 "debug undo %sabled" (if yas-debug-undo "en" "dis"))) -(advice-add 'yas--snippet-parse-create :before #'yas-debug--target-snippet) (defun yas-debug--target-snippet (snippet) (add-to-list 'yas-debug-target-snippets snippet)) -(advice-add 'yas--commit-snippet :after #'yas-debug--untarget-snippet) (defun yas-debug--untarget-snippet (snippet) (setq yas-debug-target-snippets (remq snippet yas-debug-target-snippets)) @@ -270,10 +268,8 @@ buffer-locally, otherwise install it globally. If HOOK is do (printf "%S\n" undo-elem)))) (when hook (setq yas-debug-target-buffer (current-buffer)) - (ad-enable-advice 'yas--snippet-parse-create 'before 'yas-debug-target-snippet) - (ad-activate 'yas--snippet-parse-create) - (ad-enable-advice 'yas--commit-snippet 'after 'yas-debug-untarget-snippet) - (ad-activate 'yas--commit-snippet) + (advice-add 'yas--snippet-parse-create :before #'yas-debug--target-snippet) + (advice-add 'yas--commit-snippet :after #'yas-debug--untarget-snippet) (add-hook 'post-command-hook #'yas-debug-snippets nil (eq hook 'snippet-navigation)) ;; Window management is slapped together, it does what I diff --git a/yasnippet-tests.el b/yasnippet-tests.el index e8d2847..cef2548 100644 --- a/yasnippet-tests.el +++ b/yasnippet-tests.el @@ -1,6 +1,6 @@ ;;; yasnippet-tests.el --- some yasnippet tests -*- lexical-binding: t -*- -;; Copyright (C) 2012-2024 Free Software Foundation, Inc. +;; Copyright (C) 2012-2025 Free Software Foundation, Inc. ;; Author: João Távora ;; Keywords: emulations, convenience @@ -1665,14 +1665,14 @@ TODO: be meaner" (should (eq (key-binding [backtab]) #'yas-prev-field)))))) (ert-deftest test-rebindings () - (let* ((yas-minor-mode-map (copy-keymap yas-minor-mode-map)) + (let* ((test-map (make-composed-keymap nil yas-minor-mode-map)) (minor-mode-map-alist - (cons `(yas-minor-mode . ,yas-minor-mode-map) + (cons `(yas-minor-mode . ,test-map) (cl-remove 'yas-minor-mode minor-mode-map-alist :test #'eq :key #'car)))) - (define-key yas-minor-mode-map [tab] nil) - (define-key yas-minor-mode-map (kbd "TAB") nil) - (define-key yas-minor-mode-map (kbd "SPC") #'yas-expand) + (define-key test-map [tab] nil) + (define-key test-map (kbd "TAB") nil) + (define-key test-map (kbd "SPC") #'yas-expand) (with-temp-buffer (yas-minor-mode 1) (should-not (eq (key-binding (kbd "TAB")) #'yas-expand))