org: take attachments into account on file move/delete
This commit is contained in:
parent
65c0410925
commit
9303ad228d
1 changed files with 12 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue