2012-12-28 16 views
10

我设置了一个显式文件来通过UI创建自定义。它的名字叫做custom.el。目前,如果不存在,我使用后面的代码片段来创建该文件。如何通过elisp创建一个空文件?

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

有一个丑陋的外壳命令touch中,任何其他elisp的功能都可以做到这一点?

+0

几乎是一个重复:http://stackoverflow.com/q/2592095/596361 –

回答

14

您可以使用(write-region "" nil custom-file)不确定这是否是理想的解决方案。

+3

如果你把第一个'nil'改成'“”'',那么你会有理想的解决方案,我想。 – Sean

+0

正确,我没有仔细阅读文档 – mathk