From 5c1c614940c35432d048d3879abdcab39c4d4229 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 24 May 2022 12:29:54 -0400 Subject: [PATCH] Make `yank-transform-functions` a proper hook * lisp/subr.el (insert-for-yank): Use `run-hook-wrapped` to run `yank-transform-functions`. * lisp/simple.el (yank-transform-functions): Adjust accordingly. --- lisp/emacs-lisp/package.el | 2 +- lisp/simple.el | 4 ++-- lisp/subr.el | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 3a05005fb57..8ddaa9f41d3 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -4284,7 +4284,7 @@ activations need to be changed, such as when `package-load-list' is modified." (locate-library (package--autoloads-file-name pkg)))) (pfile (prin1-to-string file))) (insert "(let ((load-true-file-name " pfile ")\ -(load-file-name " pfile "))\n") +\(load-file-name " pfile "))\n") (insert-file-contents file) ;; Fixup the special #$ reader form and throw away comments. (while (re-search-forward "#\\$\\|^;\\(.*\n\\)" nil 'move) diff --git a/lisp/simple.el b/lisp/simple.el index 1efd900030e..3318ac4731c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5947,14 +5947,14 @@ See also `yank-handled-properties'." :version "24.3") (defcustom yank-transform-functions nil - "List of functions to run on strings to be yanked. + "Hook run on strings to be yanked. Each function in this list will be called (in order) with the string to be yanked as the sole argument, and should return the (possibly) transformed string. The functions will be called with the destination buffer as the current buffer, and with point at the place where the string is to be inserted." - :type '(repeat function) + :type 'hook :version "29.1" :group 'killing) diff --git a/lisp/subr.el b/lisp/subr.el index adcbd94744e..0b415d8b2c5 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4083,8 +4083,8 @@ This function is like `insert', except it honors the variables It also runs the string through `yank-transform-functions'." ;; Allow altering the yank string. - (dolist (func yank-transform-functions) - (setq string (funcall func string))) + (run-hook-wrapped 'yank-transform-functions + (lambda (f) (setq string (funcall f string)))) (let (to) (while (setq to (next-single-property-change 0 'yank-handler string)) (insert-for-yank-1 (substring string 0 to)) -- 2.39.2