aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Fogel2016-10-02 19:47:27 -0500
committerKarl Fogel2016-10-03 14:13:43 -0500
commite1b2918c7cdecdde093390adc2fa26713554da02 (patch)
treee2c1ad4b7f6ec1bcbf74ff553fcf4455a5ac6c31
parent74b4f13842f3119f98797ea76d9be42457b330e1 (diff)
downloademacs-e1b2918c7cdecdde093390adc2fa26713554da02.tar.gz
emacs-e1b2918c7cdecdde093390adc2fa26713554da02.zip
Document yank behavior in the right place
* lisp/simple.el (yank): Document the handling of the `yank-handled-properties' and `yank-excluded-properties' variables, and the `yank-handler' text property. (yank-pop): Refer to `yank' now (bug#286) * lisp/subr.el (insert-for-yank): Refer to `yank' now. (insert-for-yank-1): Refer to `insert-for-yank' now. See this thread for discussion: https://lists.gnu.org/archive/html/emacs-devel/2016-09/threads.html#00329 From: Karl Fogel To: Emacs Devel Subject: Question about intended behavior of 'insert-for-yank-1'. Date: Mon, 12 Sep 2016 00:17:14 -0500 Message-ID: <874m5lr92d.fsf@red-bean.com>
-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 c7d3b2e6b0b..c43fe548c82 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4662,9 +4662,9 @@ If N is negative, this is a more recent kill.
4662The sequence of kills wraps around, so that after the oldest one 4662The sequence of kills wraps around, so that after the oldest one
4663comes the newest one. 4663comes the newest one.
4664 4664
4665When this command inserts killed text into the buffer, it honors 4665This command honors the `yank-handled-properties' and
4666`yank-excluded-properties' and `yank-handler' as described in the 4666`yank-excluded-properties' variables, and the `yank-handler' text
4667doc string for `insert-for-yank-1', which see." 4667property, in the way that `yank' does."
4668 (interactive "*p") 4668 (interactive "*p")
4669 (if (not (eq last-command 'yank)) 4669 (if (not (eq last-command 'yank))
4670 (user-error "Previous command was not a yank")) 4670 (user-error "Previous command was not a yank"))
@@ -4697,10 +4697,34 @@ at the end, and set mark at the beginning without activating it.
4697With just \\[universal-argument] as argument, put point at beginning, and mark at end. 4697With just \\[universal-argument] as argument, put point at beginning, and mark at end.
4698With argument N, reinsert the Nth most recent kill. 4698With argument N, reinsert the Nth most recent kill.
4699 4699
4700When this command inserts text into the buffer, it honors the 4700This command honors the `yank-handled-properties' and
4701`yank-handled-properties' and `yank-excluded-properties' 4701`yank-excluded-properties' variables, and the `yank-handler' text
4702variables, and the `yank-handler' text property. See 4702property, as described below.
4703`insert-for-yank-1' for details. 4703
4704Properties listed in `yank-handled-properties' are processed,
4705then those listed in `yank-excluded-properties' are discarded.
4706
4707If STRING has a non-nil `yank-handler' property anywhere, the
4708normal insert behavior is altered, and instead, for each contiguous
4709segment of STRING that has a given value of the `yank-handler'
4710property, that value is used as follows:
4711
4712The value of a `yank-handler' property must be a list of one to four
4713elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO).
4714FUNCTION, if non-nil, should be a function of one argument (the
4715 object to insert); FUNCTION is called instead of `insert'.
4716PARAM, if present and non-nil, is passed to FUNCTION (to be handled
4717 in whatever way is appropriate; e.g. if FUNCTION is `yank-rectangle',
4718 PARAM may be a list of strings to insert as a rectangle). If PARAM
4719 is nil, then the current segment of STRING is used.
4720If NOEXCLUDE is present and non-nil, the normal removal of
4721 `yank-excluded-properties' is not performed; instead FUNCTION is
4722 responsible for the removal. This may be necessary if FUNCTION
4723 adjusts point before or after inserting the object.
4724UNDO, if present and non-nil, should be a function to be called
4725 by `yank-pop' to undo the insertion of the current PARAM. It is
4726 given two arguments, the start and end of the region. FUNCTION
4727 may set `yank-undo-function' to override UNDO.
4704 4728
4705See also the command `yank-pop' (\\[yank-pop])." 4729See also the command `yank-pop' (\\[yank-pop])."
4706 (interactive "*P") 4730 (interactive "*P")
diff --git a/lisp/subr.el b/lisp/subr.el
index e9e19d35f65..9c717e16b94 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2859,9 +2859,11 @@ remove properties specified by `yank-excluded-properties'."
2859(defvar yank-undo-function) 2859(defvar yank-undo-function)
2860 2860
2861(defun insert-for-yank (string) 2861(defun insert-for-yank (string)
2862 "Call `insert-for-yank-1' repetitively for each `yank-handler' segment. 2862 "Insert STRING at point for the `yank' command.
2863 2863
2864See `insert-for-yank-1' for more details." 2864This function is like `insert', except it honors the variables
2865`yank-handled-properties' and `yank-excluded-properties', and the
2866`yank-handler' text property, in the way that `yank' does."
2865 (let (to) 2867 (let (to)
2866 (while (setq to (next-single-property-change 0 'yank-handler string)) 2868 (while (setq to (next-single-property-change 0 'yank-handler string))
2867 (insert-for-yank-1 (substring string 0 to)) 2869 (insert-for-yank-1 (substring string 0 to))
@@ -2869,31 +2871,7 @@ See `insert-for-yank-1' for more details."
2869 (insert-for-yank-1 string)) 2871 (insert-for-yank-1 string))
2870 2872
2871(defun insert-for-yank-1 (string) 2873(defun insert-for-yank-1 (string)
2872 "Insert STRING at point for the `yank' command. 2874 "Helper for `insert-for-yank', which see."
2873This function is like `insert', except it honors the variables
2874`yank-handled-properties' and `yank-excluded-properties', and the
2875`yank-handler' text property.
2876
2877Properties listed in `yank-handled-properties' are processed,
2878then those listed in `yank-excluded-properties' are discarded.
2879
2880If STRING has a non-nil `yank-handler' property on its first
2881character, the normal insert behavior is altered. The value of
2882the `yank-handler' property must be a list of one to four
2883elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO).
2884FUNCTION, if non-nil, should be a function of one argument, an
2885 object to insert; it is called instead of `insert'.
2886PARAM, if present and non-nil, replaces STRING as the argument to
2887 FUNCTION or `insert'; e.g. if FUNCTION is `yank-rectangle', PARAM
2888 may be a list of strings to insert as a rectangle.
2889If NOEXCLUDE is present and non-nil, the normal removal of
2890 `yank-excluded-properties' is not performed; instead FUNCTION is
2891 responsible for the removal. This may be necessary if FUNCTION
2892 adjusts point before or after inserting the object.
2893UNDO, if present and non-nil, should be a function to be called
2894 by `yank-pop' to undo the insertion of the current object. It is
2895 given two arguments, the start and end of the region. FUNCTION
2896 may set `yank-undo-function' to override UNDO."
2897 (let* ((handler (and (stringp string) 2875 (let* ((handler (and (stringp string)
2898 (get-text-property 0 'yank-handler string))) 2876 (get-text-property 0 'yank-handler string)))
2899 (param (or (nth 1 handler) string)) 2877 (param (or (nth 1 handler) string))