diff options
| -rw-r--r-- | lisp/simple.el | 38 | ||||
| -rw-r--r-- | lisp/subr.el | 32 |
2 files changed, 36 insertions, 34 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index dd253aec7d5..70bd759edab 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -4775,9 +4775,9 @@ If N is negative, this is a more recent kill. | |||
| 4775 | The sequence of kills wraps around, so that after the oldest one | 4775 | The sequence of kills wraps around, so that after the oldest one |
| 4776 | comes the newest one. | 4776 | comes the newest one. |
| 4777 | 4777 | ||
| 4778 | When this command inserts killed text into the buffer, it honors | 4778 | This command honors the `yank-handled-properties' and |
| 4779 | `yank-excluded-properties' and `yank-handler' as described in the | 4779 | `yank-excluded-properties' variables, and the `yank-handler' text |
| 4780 | doc string for `insert-for-yank-1', which see." | 4780 | property, in the way that `yank' does." |
| 4781 | (interactive "*p") | 4781 | (interactive "*p") |
| 4782 | (if (not (eq last-command 'yank)) | 4782 | (if (not (eq last-command 'yank)) |
| 4783 | (user-error "Previous command was not a yank")) | 4783 | (user-error "Previous command was not a yank")) |
| @@ -4810,10 +4810,34 @@ at the end, and set mark at the beginning without activating it. | |||
| 4810 | With just \\[universal-argument] as argument, put point at beginning, and mark at end. | 4810 | With just \\[universal-argument] as argument, put point at beginning, and mark at end. |
| 4811 | With argument N, reinsert the Nth most recent kill. | 4811 | With argument N, reinsert the Nth most recent kill. |
| 4812 | 4812 | ||
| 4813 | When this command inserts text into the buffer, it honors the | 4813 | This command honors the `yank-handled-properties' and |
| 4814 | `yank-handled-properties' and `yank-excluded-properties' | 4814 | `yank-excluded-properties' variables, and the `yank-handler' text |
| 4815 | variables, and the `yank-handler' text property. See | 4815 | property, as described below. |
| 4816 | `insert-for-yank-1' for details. | 4816 | |
| 4817 | Properties listed in `yank-handled-properties' are processed, | ||
| 4818 | then those listed in `yank-excluded-properties' are discarded. | ||
| 4819 | |||
| 4820 | If STRING has a non-nil `yank-handler' property anywhere, the | ||
| 4821 | normal insert behavior is altered, and instead, for each contiguous | ||
| 4822 | segment of STRING that has a given value of the `yank-handler' | ||
| 4823 | property, that value is used as follows: | ||
| 4824 | |||
| 4825 | The value of a `yank-handler' property must be a list of one to four | ||
| 4826 | elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO). | ||
| 4827 | FUNCTION, if non-nil, should be a function of one argument (the | ||
| 4828 | object to insert); FUNCTION is called instead of `insert'. | ||
| 4829 | PARAM, if present and non-nil, is passed to FUNCTION (to be handled | ||
| 4830 | in whatever way is appropriate; e.g. if FUNCTION is `yank-rectangle', | ||
| 4831 | PARAM may be a list of strings to insert as a rectangle). If PARAM | ||
| 4832 | is nil, then the current segment of STRING is used. | ||
| 4833 | If NOEXCLUDE is present and non-nil, the normal removal of | ||
| 4834 | `yank-excluded-properties' is not performed; instead FUNCTION is | ||
| 4835 | responsible for the removal. This may be necessary if FUNCTION | ||
| 4836 | adjusts point before or after inserting the object. | ||
| 4837 | UNDO, if present and non-nil, should be a function to be called | ||
| 4838 | by `yank-pop' to undo the insertion of the current PARAM. It is | ||
| 4839 | given two arguments, the start and end of the region. FUNCTION | ||
| 4840 | may set `yank-undo-function' to override UNDO. | ||
| 4817 | 4841 | ||
| 4818 | See also the command `yank-pop' (\\[yank-pop])." | 4842 | See also the command `yank-pop' (\\[yank-pop])." |
| 4819 | (interactive "*P") | 4843 | (interactive "*P") |
diff --git a/lisp/subr.el b/lisp/subr.el index e913e378500..b14381207fb 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -2893,9 +2893,11 @@ remove properties specified by `yank-excluded-properties'." | |||
| 2893 | (defvar yank-undo-function) | 2893 | (defvar yank-undo-function) |
| 2894 | 2894 | ||
| 2895 | (defun insert-for-yank (string) | 2895 | (defun insert-for-yank (string) |
| 2896 | "Call `insert-for-yank-1' repetitively for each `yank-handler' segment. | 2896 | "Insert STRING at point for the `yank' command. |
| 2897 | 2897 | ||
| 2898 | See `insert-for-yank-1' for more details." | 2898 | This function is like `insert', except it honors the variables |
| 2899 | `yank-handled-properties' and `yank-excluded-properties', and the | ||
| 2900 | `yank-handler' text property, in the way that `yank' does." | ||
| 2899 | (let (to) | 2901 | (let (to) |
| 2900 | (while (setq to (next-single-property-change 0 'yank-handler string)) | 2902 | (while (setq to (next-single-property-change 0 'yank-handler string)) |
| 2901 | (insert-for-yank-1 (substring string 0 to)) | 2903 | (insert-for-yank-1 (substring string 0 to)) |
| @@ -2903,31 +2905,7 @@ See `insert-for-yank-1' for more details." | |||
| 2903 | (insert-for-yank-1 string)) | 2905 | (insert-for-yank-1 string)) |
| 2904 | 2906 | ||
| 2905 | (defun insert-for-yank-1 (string) | 2907 | (defun insert-for-yank-1 (string) |
| 2906 | "Insert STRING at point for the `yank' command. | 2908 | "Helper for `insert-for-yank', which see." |
| 2907 | This function is like `insert', except it honors the variables | ||
| 2908 | `yank-handled-properties' and `yank-excluded-properties', and the | ||
| 2909 | `yank-handler' text property. | ||
| 2910 | |||
| 2911 | Properties listed in `yank-handled-properties' are processed, | ||
| 2912 | then those listed in `yank-excluded-properties' are discarded. | ||
| 2913 | |||
| 2914 | If STRING has a non-nil `yank-handler' property on its first | ||
| 2915 | character, the normal insert behavior is altered. The value of | ||
| 2916 | the `yank-handler' property must be a list of one to four | ||
| 2917 | elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO). | ||
| 2918 | FUNCTION, if non-nil, should be a function of one argument, an | ||
| 2919 | object to insert; it is called instead of `insert'. | ||
| 2920 | PARAM, if present and non-nil, replaces STRING as the argument to | ||
| 2921 | FUNCTION or `insert'; e.g. if FUNCTION is `yank-rectangle', PARAM | ||
| 2922 | may be a list of strings to insert as a rectangle. | ||
| 2923 | If NOEXCLUDE is present and non-nil, the normal removal of | ||
| 2924 | `yank-excluded-properties' is not performed; instead FUNCTION is | ||
| 2925 | responsible for the removal. This may be necessary if FUNCTION | ||
| 2926 | adjusts point before or after inserting the object. | ||
| 2927 | UNDO, if present and non-nil, should be a function to be called | ||
| 2928 | by `yank-pop' to undo the insertion of the current object. It is | ||
| 2929 | given two arguments, the start and end of the region. FUNCTION | ||
| 2930 | may set `yank-undo-function' to override UNDO." | ||
| 2931 | (let* ((handler (and (stringp string) | 2909 | (let* ((handler (and (stringp string) |
| 2932 | (get-text-property 0 'yank-handler string))) | 2910 | (get-text-property 0 'yank-handler string))) |
| 2933 | (param (or (nth 1 handler) string)) | 2911 | (param (or (nth 1 handler) string)) |