From: Kim F. Storm Date: Sat, 18 Jan 2003 23:35:06 +0000 (+0000) Subject: (insert-for-yank): Arg list changed; now only accepts one X-Git-Tag: ttn-vms-21-2-B4~11596 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e0e80ec90dbdf3a6609d046b90143d6fe493339d;p=emacs.git (insert-for-yank): Arg list changed; now only accepts one string rather than any number of strings; no callers needed change. Use yank-handler text property on the arg string. Set yank-undo-function variable appropriately for yank-pop. --- diff --git a/lisp/subr.el b/lisp/subr.el index b2842b27242..66b69d58850 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1457,15 +1457,48 @@ Replaces `category' properties with their defined properties." (set-text-properties start end nil) (remove-list-of-text-properties start end yank-excluded-properties)))) -(defun insert-for-yank (&rest strings) - "Insert STRINGS at point, stripping some text properties. -Strip text properties from the inserted text -according to `yank-excluded-properties'. -Otherwise just like (insert STRINGS...)." - (let ((opoint (point))) - (apply 'insert strings) - (remove-yank-excluded-properties opoint (point)))) - +(defvar yank-undo-function) + +(defun insert-for-yank (string) + "Insert STRING at point, stripping some text properties. +Strip text properties from the inserted text according to +`yank-excluded-properties'. Otherwise just like (insert STRING). + +If STRING has a non-nil yank-handler property on the first character, +the normal insert behaviour is modified in various ways. The value of +the yank-handler property must be a list with one to five elements +with the following format: (FUNCTION PARAM NOEXCLUDE UNDO COMMAND). +When FUNCTION is present and non-nil, it is called instead of `insert' + to insert the string. FUNCTION takes one argument--the object to insert. +If PARAM is present and non-nil, it replaces STRING as the object + passed to FUNCTION (or `insert'); for example, if FUNCTION is + `yank-rectangle', PARAM may be a list of strings to insert as a + rectangle. +If NOEXCLUDE is present and non-nil, the normal removal of the + yank-excluded-properties is not performed; instead FUNCTION is + responsible for removing those properties. This may be necessary + if FUNCTION adjusts point before or after inserting the object. +If UNDO is present and non-nil, it is a function that will be called + by `yank-pop' to undo the insertion of the current object. It is + called with two arguments + FUNCTION may set `yank-undo-function' to override this. +If COMMAND is present and non-nil, `this-command' is set to COMMAND + after calling FUNCTION (or insert). Note that setting `this-command' + to a value different from `yank' will prevent `yank-pop' from undoing + this yank." + (let* ((method (get-text-property 0 'yank-handler string)) + (param (or (nth 1 method) string)) + (opoint (point))) + (setq yank-undo-function (nth 3 method)) ;; UNDO + (if (nth 0 method) ;; FUNCTION + (funcall (car method) param) + (setq opoint (point)) + (insert param)) + (unless (nth 2 method) ;; NOEXCLUDE + (remove-yank-excluded-properties opoint (point))) + (if (nth 4 method) ;; COMMAND + (setq this-command (nth 4 method))))) + (defun insert-buffer-substring-no-properties (buf &optional start end) "Insert before point a substring of buffer BUFFER, without text properties. BUFFER may be a buffer or a buffer name.