defuns-file: handle modified buffers on :mv and :rm

This commit is contained in:
Henrik Lissner 2016-03-31 03:18:03 -04:00
parent 1cd492d301
commit 10bc312a62

View file

@ -15,6 +15,7 @@
(when (file-exists-p file)
(delete-file file t)))
(narf/org-attachments)))
(set-buffer-modified-p nil)
(delete-file filename)
(kill-this-buffer)
(unless (narf/real-buffer-p)
@ -33,7 +34,8 @@ provided."
(let ((dir (f-dirname path))
(fullpath (f-full path))
(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 fullpath)
(error "File already exists: %s" path)
@ -61,6 +63,8 @@ provided."
(when (file-exists-p file)
(rename-file file (f-expand (f-filename old-path) (f-dirname new-path)) t)))
(narf/org-attachments)))
(when (buffer-modified-p)
(save-buffer))
(rename-file old-path new-path 1)
(rename-buffer (f-filename new-path))
(set-visited-file-name new-path)