aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/simple.el38
-rw-r--r--lisp/subr.el32
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.
4775The sequence of kills wraps around, so that after the oldest one 4775The sequence of kills wraps around, so that after the oldest one
4776comes the newest one. 4776comes the newest one.
4777 4777
4778When this command inserts killed text into the buffer, it honors 4778This 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
4780doc string for `insert-for-yank-1', which see." 4780property, 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.
4810With just \\[universal-argument] as argument, put point at beginning, and mark at end. 4810With just \\[universal-argument] as argument, put point at beginning, and mark at end.
4811With argument N, reinsert the Nth most recent kill. 4811With argument N, reinsert the Nth most recent kill.
4812 4812
4813When this command inserts text into the buffer, it honors the 4813This 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
4815variables, and the `yank-handler' text property. See 4815property, as described below.
4816`insert-for-yank-1' for details. 4816
4817Properties listed in `yank-handled-properties' are processed,
4818then those listed in `yank-excluded-properties' are discarded.
4819
4820If STRING has a non-nil `yank-handler' property anywhere, the
4821normal insert behavior is altered, and instead, for each contiguous
4822segment of STRING that has a given value of the `yank-handler'
4823property, that value is used as follows:
4824
4825The value of a `yank-handler' property must be a list of one to four
4826elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO).
4827FUNCTION, if non-nil, should be a function of one argument (the
4828 object to insert); FUNCTION is called instead of `insert'.
4829PARAM, 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.
4833If 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.
4837UNDO, 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
4818See also the command `yank-pop' (\\[yank-pop])." 4842See 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
2898See `insert-for-yank-1' for more details." 2898This 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."
2907This 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
2911Properties listed in `yank-handled-properties' are processed,
2912then those listed in `yank-excluded-properties' are discarded.
2913
2914If STRING has a non-nil `yank-handler' property on its first
2915character, the normal insert behavior is altered. The value of
2916the `yank-handler' property must be a list of one to four
2917elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO).
2918FUNCTION, if non-nil, should be a function of one argument, an
2919 object to insert; it is called instead of `insert'.
2920PARAM, 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.
2923If 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.
2927UNDO, 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))