mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
Revert "Don't auto-create directory when opening files"
This reverts commit 4d7640b4c2
.
This commit is contained in:
@ -72,6 +72,19 @@ possible."
|
|||||||
;; warning as it will redirect you to the existing buffer anyway.
|
;; warning as it will redirect you to the existing buffer anyway.
|
||||||
(setq find-file-suppress-same-file-warnings t)
|
(setq find-file-suppress-same-file-warnings t)
|
||||||
|
|
||||||
|
;; Create missing directories when we open a file that doesn't exist under a
|
||||||
|
;; directory tree that may not exist.
|
||||||
|
(add-hook! 'find-file-not-found-functions
|
||||||
|
(defun doom-create-missing-directories-h ()
|
||||||
|
"Automatically create missing directories when creating new files."
|
||||||
|
(unless (file-remote-p buffer-file-name)
|
||||||
|
(let ((parent-directory (file-name-directory buffer-file-name)))
|
||||||
|
(and (not (file-directory-p parent-directory))
|
||||||
|
(y-or-n-p (format "Directory `%s' does not exist! Create it?"
|
||||||
|
parent-directory))
|
||||||
|
(progn (make-directory parent-directory 'parents)
|
||||||
|
t))))))
|
||||||
|
|
||||||
;; Don't generate backups or lockfiles. While auto-save maintains a copy so long
|
;; Don't generate backups or lockfiles. While auto-save maintains a copy so long
|
||||||
;; as a buffer is unsaved, backups create copies once, when the file is first
|
;; as a buffer is unsaved, backups create copies once, when the file is first
|
||||||
;; written, and never again until it is killed and reopened. This is better
|
;; written, and never again until it is killed and reopened. This is better
|
||||||
|
Reference in New Issue
Block a user