我需要将文件的一部分(带re-search-forward
)复制到标记下的另一个文件中。我知道如何使用re-search-forward
,但我遇到缓冲区问题。
我的逻辑是对的吗?
re-search-forward
所需的行并将其复制到新的行中
缓冲insert-buffer-substring
现在我有这样的功能:
(defun my-insert-file-name (filename)
(interactive "*fInsert file name: ")
(save-excursion
(goto-char (point-min))
(when (re-search-forward "#here")
(forward-line 1)
(------something should be here-----)))
答案 0 :(得分:1)
你的问题很简短,但也许是这样的?
(let (buf)
(with-temp-buffer
(setq buf (current-buffer))
(insert-file-contents "/file/to/insert")
(do-stuff-to-temp-buffer)
(with-current-buffer "buffer-to-insert-into"
(insert-buffer-substring buf))))