Elisp一天一函数——write-region

2019-01-11  本文已影响0人  m2fox
(write-region START END FILENAME &optional APPEND VISIT LOCKNAME MUSTBENEW)
hello,
world!
are you ok?

下面写一段代码,实现读取d:/test.txt文件的内容,并将内容写入到一个新的文件d:/test_copy.txt中:

(with-temp-buffer
  (insert-file-contents "d:/test.txt")
  (setq copy-test-path "d:/test_copy.txt")
  (write-region (point-min) (point-max) copy-test-path)
  (write-region "new  content" nil copy-test-path t))

执行上述代码后,发现在D盘根目录自动创建出来了一个新的文件test_copy.txt,其内容为:

hello,
world!
are you ok?
new  content
上一篇 下一篇

猜你喜欢

热点阅读