How to create an empty file by elisp?

Perhaps a simpler solution to the underlying problem would be:

(defconst custom-file (expand-file-name "custom.el" user-emacs-directory))
;; NOERROR to ignore nonexistent file - Emacs will create it
(load custom-file t)

In other words, instead of manually creating custom.el, simply don't error when you try to load it (optional arg NOERROR is only for file existence error). Emacs will create the file the first time it writes out custom variables.

This is what I'm currently using in my init.el


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

Tags:

Emacs

Lisp

Elisp