Function: dired-create-empty-file

dired-create-empty-file is an autoloaded, interactive and byte-compiled function defined in dired-aux.el.gz.

Signature

(dired-create-empty-file FILE)

Documentation

Create an empty file called FILE.

Add a new entry for the new file in the Dired buffer. Parent directories of FILE are created as needed. If FILE already exists, signal an error.

View in manual

Probably introduced at or before Emacs version 27.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/dired-aux.el.gz
;;;###autoload
(defun dired-create-empty-file (file)
  "Create an empty file called FILE.
Add a new entry for the new file in the Dired buffer.
Parent directories of FILE are created as needed.
If FILE already exists, signal an error."
  (interactive (list (read-file-name "Create empty file: ")) dired-mode)
  (let* ((expanded (expand-file-name file))
         new)
    (if (file-exists-p expanded)
        (error "Cannot create file %s: file exists" expanded))
    (setq new (dired--find-topmost-parent-dir expanded))
    (make-empty-file file 'parents)
    (when new
      (dired-add-file new)
      (dired-move-to-filename))))