Search code examples
emacslispelisp

How to create an empty file by elisp?


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?


Solution

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