How to create an empty file by elisp?

本秂侑毒 提交于 2019-12-05 18:24:15

问题


I set an explicit file to customization created via the UI. It's named custom.el. Currently, I use the followed snippets to create this file if not exist.

(defconst custom-file (expand-file-name "custom.el" user-emacs-directory))
(unless (file-exists-p custom-file)
  (shell-command (concat "touch " custom-file)))

There is an ugly shell-command touch in, any other elisp functions can do this?


回答1:


You can use (write-region "" nil custom-file) not sure that is the ideal solution.



来源:https://stackoverflow.com/questions/14071991/how-to-create-an-empty-file-by-elisp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!