+ (defun sd/dired-new-file (file)
+ "Create a new file called FILE.
+ If FILE already exists, signal an error."
+ (interactive
+ (list (read-file-name "Create file: " (dired-current-directory))))
+ (let* ((expanded (expand-file-name file)))
+ (if (file-exists-p expanded)
+ (error "Cannot create file %s: file exists" expanded))
+ (write-region "" nil expanded t)
+ (when expanded
+ (dired-add-file expanded)
+ (dired-move-to-filename))))
+