From: Stefan Monnier Date: Tue, 24 May 2022 16:29:54 +0000 (-0400) Subject: Make `yank-transform-functions` a proper hook X-Git-Tag: emacs-29.0.90~1910^2~454 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5c1c614940c35432d048d3879abdcab39c4d4229;p=emacs.git 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. --- 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))