mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-02 14:53:38 -05:00
defuns-file: handle modified buffers on :mv and :rm
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
(when (file-exists-p file)
|
(when (file-exists-p file)
|
||||||
(delete-file file t)))
|
(delete-file file t)))
|
||||||
(narf/org-attachments)))
|
(narf/org-attachments)))
|
||||||
|
(set-buffer-modified-p nil)
|
||||||
(delete-file filename)
|
(delete-file filename)
|
||||||
(kill-this-buffer)
|
(kill-this-buffer)
|
||||||
(unless (narf/real-buffer-p)
|
(unless (narf/real-buffer-p)
|
||||||
@@ -33,7 +34,8 @@ provided."
|
|||||||
(let ((dir (f-dirname path))
|
(let ((dir (f-dirname path))
|
||||||
(fullpath (f-full path))
|
(fullpath (f-full path))
|
||||||
(is-auto t))
|
(is-auto t))
|
||||||
(when (and bang (not (file-exists-p dir))) (f-mkdir dir))
|
(when (and bang (not (file-exists-p dir)))
|
||||||
|
(f-mkdir dir))
|
||||||
(if (file-exists-p dir)
|
(if (file-exists-p dir)
|
||||||
(if (file-exists-p fullpath)
|
(if (file-exists-p fullpath)
|
||||||
(error "File already exists: %s" path)
|
(error "File already exists: %s" path)
|
||||||
@@ -61,6 +63,8 @@ provided."
|
|||||||
(when (file-exists-p file)
|
(when (file-exists-p file)
|
||||||
(rename-file file (f-expand (f-filename old-path) (f-dirname new-path)) t)))
|
(rename-file file (f-expand (f-filename old-path) (f-dirname new-path)) t)))
|
||||||
(narf/org-attachments)))
|
(narf/org-attachments)))
|
||||||
|
(when (buffer-modified-p)
|
||||||
|
(save-buffer))
|
||||||
(rename-file old-path new-path 1)
|
(rename-file old-path new-path 1)
|
||||||
(rename-buffer (f-filename new-path))
|
(rename-buffer (f-filename new-path))
|
||||||
(set-visited-file-name new-path)
|
(set-visited-file-name new-path)
|
||||||
|
Reference in New Issue
Block a user