diff options
| author | Lars Ingebrigtsen | 2021-07-13 23:46:16 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-07-13 23:46:16 +0200 |
| commit | 210b10f3fe7d2b847f7af31276c05001c8fc0ed7 (patch) | |
| tree | d072dc775003cc7ce767900931c273f2389aaf92 | |
| parent | 3ce37f5afa7d7852b0c69b355f531682efebc832 (diff) | |
| download | emacs-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.texi | 9 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/subr.el | 8 |
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 | |||
| 502 | copy any text properties. | 502 | copy any text properties. |
| 503 | @end defun | 503 | @end defun |
| 504 | 504 | ||
| 505 | @defun insert-into-buffer to-buffer &optional start end | ||
| 506 | This is like @code{insert-buffer-substring}, but works in the opposite | ||
| 507 | direction: 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 | ||
| 510 | end of the copied text. Is @code{start}/@code{end} is @code{nil}, the | ||
| 511 | entire 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 |
| 506 | text properties from the nearby text in addition to inserting it. | 515 | text properties from the nearby text in addition to inserting it. |
| 507 | Whitespace inserted by indentation functions also inherits text | 516 | Whitespace inserted by indentation functions also inherits text |
| @@ -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'. | ||
| 2190 | This 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'. |
| 2190 | This option allows controlling where lock files are written. It uses | 2194 | This option allows controlling where lock files are written. It uses |
| 2191 | the same syntax as 'auto-save-file-name-transforms'. | 2195 | the 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. | ||
| 3855 | If START/END, only insert that region from the current buffer. | ||
| 3856 | Point 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. |
| 3855 | START and END denote the start and end of the text to act on. | 3863 | START and END denote the start and end of the text to act on. |