Misc fixes found via compilation warnings

* yasnippet-debug.el (yas-debug-snippets): Improve commit 009322196cfa.
* yasnippet-tests.el (test-rebindings): Avoid `copy-keymap`.
This commit is contained in:
Stefan Monnier 2025-01-12 17:51:54 -05:00
parent 03b1b11547
commit 5b315f1753
2 changed files with 9 additions and 13 deletions

View File

@ -1,6 +1,6 @@
;;; yasnippet-debug.el --- debug functions for yasnippet -*- lexical-binding: t -*- ;;; 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 ;; Author: João Távora
;; Keywords: emulations, convenience ;; Keywords: emulations, convenience
@ -221,11 +221,9 @@
(setq yas-debug-undo value) (setq yas-debug-undo value)
(yas--message 3 "debug undo %sabled" (if yas-debug-undo "en" "dis"))) (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) (defun yas-debug--target-snippet (snippet)
(add-to-list 'yas-debug-target-snippets 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) (defun yas-debug--untarget-snippet (snippet)
(setq yas-debug-target-snippets (setq yas-debug-target-snippets
(remq snippet 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)))) do (printf "%S\n" undo-elem))))
(when hook (when hook
(setq yas-debug-target-buffer (current-buffer)) (setq yas-debug-target-buffer (current-buffer))
(ad-enable-advice 'yas--snippet-parse-create 'before 'yas-debug-target-snippet) (advice-add 'yas--snippet-parse-create :before #'yas-debug--target-snippet)
(ad-activate 'yas--snippet-parse-create) (advice-add 'yas--commit-snippet :after #'yas-debug--untarget-snippet)
(ad-enable-advice 'yas--commit-snippet 'after 'yas-debug-untarget-snippet)
(ad-activate 'yas--commit-snippet)
(add-hook 'post-command-hook #'yas-debug-snippets (add-hook 'post-command-hook #'yas-debug-snippets
nil (eq hook 'snippet-navigation)) nil (eq hook 'snippet-navigation))
;; Window management is slapped together, it does what I ;; Window management is slapped together, it does what I

View File

@ -1,6 +1,6 @@
;;; yasnippet-tests.el --- some yasnippet tests -*- lexical-binding: t -*- ;;; 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 <joaot@siscog.pt> ;; Author: João Távora <joaot@siscog.pt>
;; Keywords: emulations, convenience ;; Keywords: emulations, convenience
@ -1665,14 +1665,14 @@ TODO: be meaner"
(should (eq (key-binding [backtab]) #'yas-prev-field)))))) (should (eq (key-binding [backtab]) #'yas-prev-field))))))
(ert-deftest test-rebindings () (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 (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 (cl-remove 'yas-minor-mode minor-mode-map-alist
:test #'eq :key #'car)))) :test #'eq :key #'car))))
(define-key yas-minor-mode-map [tab] nil) (define-key test-map [tab] nil)
(define-key yas-minor-mode-map (kbd "TAB") nil) (define-key test-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "SPC") #'yas-expand) (define-key test-map (kbd "SPC") #'yas-expand)
(with-temp-buffer (with-temp-buffer
(yas-minor-mode 1) (yas-minor-mode 1)
(should-not (eq (key-binding (kbd "TAB")) #'yas-expand)) (should-not (eq (key-binding (kbd "TAB")) #'yas-expand))