diff options
| author | Kim F. Storm | 2003-01-18 23:35:06 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2003-01-18 23:35:06 +0000 |
| commit | e0e80ec90dbdf3a6609d046b90143d6fe493339d (patch) | |
| tree | 448bd83465f8caaf390280bfc5a84452e25b77b5 | |
| parent | be5936a745c91f51584fd6ab60472af39bd06ef3 (diff) | |
| download | emacs-e0e80ec90dbdf3a6609d046b90143d6fe493339d.tar.gz emacs-e0e80ec90dbdf3a6609d046b90143d6fe493339d.zip | |
(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.
| -rw-r--r-- | lisp/subr.el | 51 |
1 files changed, 42 insertions, 9 deletions
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." | |||
| 1457 | (set-text-properties start end nil) | 1457 | (set-text-properties start end nil) |
| 1458 | (remove-list-of-text-properties start end yank-excluded-properties)))) | 1458 | (remove-list-of-text-properties start end yank-excluded-properties)))) |
| 1459 | 1459 | ||
| 1460 | (defun insert-for-yank (&rest strings) | 1460 | (defvar yank-undo-function) |
| 1461 | "Insert STRINGS at point, stripping some text properties. | 1461 | |
| 1462 | Strip text properties from the inserted text | 1462 | (defun insert-for-yank (string) |
| 1463 | according to `yank-excluded-properties'. | 1463 | "Insert STRING at point, stripping some text properties. |
| 1464 | Otherwise just like (insert STRINGS...)." | 1464 | Strip text properties from the inserted text according to |
| 1465 | (let ((opoint (point))) | 1465 | `yank-excluded-properties'. Otherwise just like (insert STRING). |
| 1466 | (apply 'insert strings) | 1466 | |
| 1467 | (remove-yank-excluded-properties opoint (point)))) | 1467 | If STRING has a non-nil yank-handler property on the first character, |
| 1468 | 1468 | the normal insert behaviour is modified in various ways. The value of | |
| 1469 | the yank-handler property must be a list with one to five elements | ||
| 1470 | with the following format: (FUNCTION PARAM NOEXCLUDE UNDO COMMAND). | ||
| 1471 | When FUNCTION is present and non-nil, it is called instead of `insert' | ||
| 1472 | to insert the string. FUNCTION takes one argument--the object to insert. | ||
| 1473 | If PARAM is present and non-nil, it replaces STRING as the object | ||
| 1474 | passed to FUNCTION (or `insert'); for example, if FUNCTION is | ||
| 1475 | `yank-rectangle', PARAM may be a list of strings to insert as a | ||
| 1476 | rectangle. | ||
| 1477 | If NOEXCLUDE is present and non-nil, the normal removal of the | ||
| 1478 | yank-excluded-properties is not performed; instead FUNCTION is | ||
| 1479 | responsible for removing those properties. This may be necessary | ||
| 1480 | if FUNCTION adjusts point before or after inserting the object. | ||
| 1481 | If UNDO is present and non-nil, it is a function that will be called | ||
| 1482 | by `yank-pop' to undo the insertion of the current object. It is | ||
| 1483 | called with two arguments | ||
| 1484 | FUNCTION may set `yank-undo-function' to override this. | ||
| 1485 | If COMMAND is present and non-nil, `this-command' is set to COMMAND | ||
| 1486 | after calling FUNCTION (or insert). Note that setting `this-command' | ||
| 1487 | to a value different from `yank' will prevent `yank-pop' from undoing | ||
| 1488 | this yank." | ||
| 1489 | (let* ((method (get-text-property 0 'yank-handler string)) | ||
| 1490 | (param (or (nth 1 method) string)) | ||
| 1491 | (opoint (point))) | ||
| 1492 | (setq yank-undo-function (nth 3 method)) ;; UNDO | ||
| 1493 | (if (nth 0 method) ;; FUNCTION | ||
| 1494 | (funcall (car method) param) | ||
| 1495 | (setq opoint (point)) | ||
| 1496 | (insert param)) | ||
| 1497 | (unless (nth 2 method) ;; NOEXCLUDE | ||
| 1498 | (remove-yank-excluded-properties opoint (point))) | ||
| 1499 | (if (nth 4 method) ;; COMMAND | ||
| 1500 | (setq this-command (nth 4 method))))) | ||
| 1501 | |||
| 1469 | (defun insert-buffer-substring-no-properties (buf &optional start end) | 1502 | (defun insert-buffer-substring-no-properties (buf &optional start end) |
| 1470 | "Insert before point a substring of buffer BUFFER, without text properties. | 1503 | "Insert before point a substring of buffer BUFFER, without text properties. |
| 1471 | BUFFER may be a buffer or a buffer name. | 1504 | BUFFER may be a buffer or a buffer name. |