1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-21 18:23:59 +00:00

Add new function 'insert-into-buffer'

* doc/lispref/text.texi (Insertion): Document it.
* lisp/subr.el (insert-into-buffer): New function.
This commit is contained in:
Lars Ingebrigtsen 2021-07-13 23:46:16 +02:00
parent 3ce37f5afa
commit 210b10f3fe
3 changed files with 21 additions and 0 deletions

View File

@ -500,6 +500,15 @@ We hold these truth@point{}
@defun insert-buffer-substring-no-properties from-buffer-or-name &optional start end
This is like @code{insert-buffer-substring} except that it does not
copy any text properties.
@end defun
@defun insert-into-buffer to-buffer &optional start end
This is like @code{insert-buffer-substring}, but works in the opposite
direction: The text is copied from the current buffer into
@var{to-buffer}. The block of text is copied to the current point in
@var{to-buffer}, and point (in that buffer) is advanced to after the
end of the copied text. Is @code{start}/@code{end} is @code{nil}, the
entire text in the current buffer is copied over.
@end defun
@xref{Sticky Properties}, for other insertion functions that inherit

View File

@ -2185,6 +2185,10 @@ summaries will include the failing condition.
** Miscellaneous
+++
*** New utility function 'insert-into-buffer'.
This is like 'insert-into-buffer', but works in the opposite direction.
+++
*** New user option 'lock-file-name-transforms'.
This option allows controlling where lock files are written. It uses

View File

@ -3850,6 +3850,14 @@ Before insertion, process text properties according to
(insert-buffer-substring buffer start end)
(remove-yank-excluded-properties opoint (point))))
(defun insert-into-buffer (buffer &optional start end)
"Insert the contents of the current buffer into BUFFER.
If START/END, only insert that region from the current buffer.
Point in BUFFER will be placed after the inserted text."
(let ((current (current-buffer)))
(with-current-buffer buffer
(insert-buffer-substring current start end))))
(defun yank-handle-font-lock-face-property (face start end)
"If `font-lock-defaults' is nil, apply FACE as a `face' property.
START and END denote the start and end of the text to act on.