How to create an empty file by elisp?

2019-04-04 23:29发布

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?

标签: emacs lisp elisp
1条回答
Explosion°爆炸
2楼-- · 2019-04-04 23:39

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

查看更多
登录 后发表回答