org: take attachments into account on file move/delete

This commit is contained in:
Henrik Lissner 2016-03-11 19:30:58 -05:00
parent 65c0410925
commit 9303ad228d

View file

@ -9,6 +9,12 @@
(if (not (file-exists-p filename))
(error "File doesn't exist: %s" filename)
(when (or bang (and (not bang) (y-or-n-p (format "Delete %s?" (f-base filename)))))
;; Delete attachments if in org-mode
(when (eq major-mode 'org-mode)
(mapc (lambda (file)
(when (file-exists-p file)
(delete-file file t)))
(narf/org-attachments)))
(delete-file filename)
(kill-this-buffer)
(unless (narf/real-buffer-p)
@ -49,6 +55,12 @@ provided."
(f-full path))
(t (user-error "Not a valid destination: %s" path))))
(project-root (narf/project-root)))
;; Move all attachments if in org-mode
(when (eq major-mode 'org-mode)
(mapc (lambda (file)
(when (file-exists-p file)
(rename-file file (f-expand (f-filename old-path) (f-dirname new-path)) t)))
(narf/org-attachments)))
(rename-file old-path new-path 1)
(rename-buffer (f-filename new-path))
(set-visited-file-name new-path)