diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/simple.el | 11 | ||||
-rw-r--r-- | lisp/subr.el | 7 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index cd7a82b7aca..bed72457c3a 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -5928,6 +5928,15 @@ See also `yank-handled-properties'." :group 'killing :version "24.3") +(defcustom yank-transform-functions nil + "List of functions to 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." + :type '(repeat function) + :version "29.1" + :group 'killing) + (defvar yank-window-start nil) (defvar yank-undo-function nil "If non-nil, function used by `yank-pop' to delete last stretch of yanked text. @@ -5999,6 +6008,8 @@ property, as described below. Properties listed in `yank-handled-properties' are processed, then those listed in `yank-excluded-properties' are discarded. +STRING will be run through `yank-transform-functions'. + If STRING has a non-nil `yank-handler' property anywhere, the normal insert behavior is altered, and instead, for each contiguous segment of STRING that has a given value of the `yank-handler' diff --git a/lisp/subr.el b/lisp/subr.el index d7f06bdcde8..945587db53c 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4070,7 +4070,12 @@ remove properties specified by `yank-excluded-properties'." This function is like `insert', except it honors the variables `yank-handled-properties' and `yank-excluded-properties', and the -`yank-handler' text property, in the way that `yank' does." +`yank-handler' text property, in the way that `yank' does. + +It also runs the string through `yank-transform-functions'." + ;; Allow altering the yank string. + (dolist (func yank-transform-functions) + (setq string (funcall func string))) (let (to) (while (setq to (next-single-property-change 0 'yank-handler string)) (insert-for-yank-1 (substring string 0 to)) |