Function: yank
yank is an interactive and byte-compiled function defined in
simple.el.gz.
Signature
(yank &optional ARG)
Documentation
Reinsert ("paste") the last stretch of killed text.
More precisely, reinsert the most recent kill, which is the stretch of
text most recently killed OR yanked, as returned by current-kill (which
see). Put point at the end, and set mark at the beginning without
activating it. With just C-u (universal-argument) as argument, put point
at beginning, and mark at end.
With argument N, reinsert the Nth most recent kill.
This command honors the yank-handled-properties and
yank-excluded-properties variables, and the yank-handler text
property, as described below.
Properties listed in yank-handled-properties are processed,
then those listed in yank-excluded-properties are discarded.
STRING will be run through yank-transform-functions.
yank-in-context is a command that uses this mechanism to
provide a yank alternative that conveniently preserves
string/comment syntax.
If STRING has a non-nil yank-handler property anywhere, the
normal insert behavior is altered, and instead, for each contiguous
segment of STRING that has a given value of the yank-handler
property, that value is used as follows:
The value of a yank-handler property must be a list of one to four
elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO).
FUNCTION, if non-nil, should be a function of one argument (the
object to insert); FUNCTION is called instead of insert.
PARAM, if present and non-nil, is passed to FUNCTION (to be handled
in whatever way is appropriate; e.g. if FUNCTION is yank-rectangle,
PARAM may be a list of strings to insert as a rectangle). If PARAM
is nil, then the current segment of STRING is used.
If NOEXCLUDE is present and non-nil, the normal removal of
yank-excluded-properties is not performed; instead FUNCTION is
responsible for the removal. This may be necessary if FUNCTION
adjusts point before or after inserting the object.
UNDO, if present and non-nil, should be a function to be called
by yank-pop to undo the insertion of the current PARAM. It is
given two arguments, the start and end of the region. FUNCTION
may set yank-undo-function to override UNDO.
See also the command yank-pop (M-y (yank-pop)).
This function has :around advice: ses--advice-yank.
Probably introduced at or before Emacs version 22.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun yank (&optional arg)
"Reinsert (\"paste\") the last stretch of killed text.
More precisely, reinsert the most recent kill, which is the stretch of
text most recently killed OR yanked, as returned by `current-kill' (which
see). Put point at the end, and set mark at the beginning without
activating it. With just \\[universal-argument] as argument, put point
at beginning, and mark at end.
With argument N, reinsert the Nth most recent kill.
This command honors the `yank-handled-properties' and
`yank-excluded-properties' variables, and the `yank-handler' text
property, as described below.
Properties listed in `yank-handled-properties' are processed,
then those listed in `yank-excluded-properties' are discarded.
STRING will be run through `yank-transform-functions'.
`yank-in-context' is a command that uses this mechanism to
provide a `yank' alternative that conveniently preserves
string/comment syntax.
If STRING has a non-nil `yank-handler' property anywhere, the
normal insert behavior is altered, and instead, for each contiguous
segment of STRING that has a given value of the `yank-handler'
property, that value is used as follows:
The value of a `yank-handler' property must be a list of one to four
elements, of the form (FUNCTION PARAM NOEXCLUDE UNDO).
FUNCTION, if non-nil, should be a function of one argument (the
object to insert); FUNCTION is called instead of `insert'.
PARAM, if present and non-nil, is passed to FUNCTION (to be handled
in whatever way is appropriate; e.g. if FUNCTION is `yank-rectangle',
PARAM may be a list of strings to insert as a rectangle). If PARAM
is nil, then the current segment of STRING is used.
If NOEXCLUDE is present and non-nil, the normal removal of
`yank-excluded-properties' is not performed; instead FUNCTION is
responsible for the removal. This may be necessary if FUNCTION
adjusts point before or after inserting the object.
UNDO, if present and non-nil, should be a function to be called
by `yank-pop' to undo the insertion of the current PARAM. It is
given two arguments, the start and end of the region. FUNCTION
may set `yank-undo-function' to override UNDO.
See also the command `yank-pop' (\\[yank-pop])."
(interactive "*P")
(setq yank-window-start (window-start))
;; If we don't get all the way thru, make last-command indicate that
;; for the following command.
(setq this-command t)
(push-mark)
(insert-for-yank (current-kill (cond
((listp arg) 0)
((eq arg '-) -2)
(t (1- arg)))))
(if (consp arg)
;; This is like exchange-point-and-mark, but doesn't activate the mark.
;; It is cleaner to avoid activation, even though the command
;; loop would deactivate the mark because we inserted text.
(goto-char (prog1 (mark t)
(set-marker (mark-marker) (point) (current-buffer)))))
;; If we do get all the way thru, make this-command indicate that.
(if (eq this-command t)
(setq this-command 'yank))
nil)