aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-07-13 23:46:16 +0200
committerLars Ingebrigtsen2021-07-13 23:46:16 +0200
commit210b10f3fe7d2b847f7af31276c05001c8fc0ed7 (patch)
treed072dc775003cc7ce767900931c273f2389aaf92
parent3ce37f5afa7d7852b0c69b355f531682efebc832 (diff)
downloademacs-210b10f3fe7d2b847f7af31276c05001c8fc0ed7.tar.gz
emacs-210b10f3fe7d2b847f7af31276c05001c8fc0ed7.zip
Add new function 'insert-into-buffer'
* doc/lispref/text.texi (Insertion): Document it. * lisp/subr.el (insert-into-buffer): New function.
-rw-r--r--doc/lispref/text.texi9
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/subr.el8
3 files changed, 21 insertions, 0 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index feb9e58f31c..6fbb475a325 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -502,6 +502,15 @@ This is like @code{insert-buffer-substring} except that it does not
502copy any text properties. 502copy any text properties.
503@end defun 503@end defun
504 504
505@defun insert-into-buffer to-buffer &optional start end
506This is like @code{insert-buffer-substring}, but works in the opposite
507direction: The text is copied from the current buffer into
508@var{to-buffer}. The block of text is copied to the current point in
509@var{to-buffer}, and point (in that buffer) is advanced to after the
510end of the copied text. Is @code{start}/@code{end} is @code{nil}, the
511entire text in the current buffer is copied over.
512@end defun
513
505 @xref{Sticky Properties}, for other insertion functions that inherit 514 @xref{Sticky Properties}, for other insertion functions that inherit
506text properties from the nearby text in addition to inserting it. 515text properties from the nearby text in addition to inserting it.
507Whitespace inserted by indentation functions also inherits text 516Whitespace inserted by indentation functions also inherits text
diff --git a/etc/NEWS b/etc/NEWS
index a3f12837f78..a0b62250d89 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2186,6 +2186,10 @@ summaries will include the failing condition.
2186** Miscellaneous 2186** Miscellaneous
2187 2187
2188+++ 2188+++
2189*** New utility function 'insert-into-buffer'.
2190This is like 'insert-into-buffer', but works in the opposite direction.
2191
2192+++
2189*** New user option 'lock-file-name-transforms'. 2193*** New user option 'lock-file-name-transforms'.
2190This option allows controlling where lock files are written. It uses 2194This option allows controlling where lock files are written. It uses
2191the same syntax as 'auto-save-file-name-transforms'. 2195the same syntax as 'auto-save-file-name-transforms'.
diff --git a/lisp/subr.el b/lisp/subr.el
index e49c2773357..c7e18646bfb 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3850,6 +3850,14 @@ Before insertion, process text properties according to
3850 (insert-buffer-substring buffer start end) 3850 (insert-buffer-substring buffer start end)
3851 (remove-yank-excluded-properties opoint (point)))) 3851 (remove-yank-excluded-properties opoint (point))))
3852 3852
3853(defun insert-into-buffer (buffer &optional start end)
3854 "Insert the contents of the current buffer into BUFFER.
3855If START/END, only insert that region from the current buffer.
3856Point in BUFFER will be placed after the inserted text."
3857 (let ((current (current-buffer)))
3858 (with-current-buffer buffer
3859 (insert-buffer-substring current start end))))
3860
3853(defun yank-handle-font-lock-face-property (face start end) 3861(defun yank-handle-font-lock-face-property (face start end)
3854 "If `font-lock-defaults' is nil, apply FACE as a `face' property. 3862 "If `font-lock-defaults' is nil, apply FACE as a `face' property.
3855START and END denote the start and end of the text to act on. 3863START and END denote the start and end of the text to act on.