fix(org): org-download-delete and [[download:...]] links
org-download-delete doesn't accommodate a non-standard value for org-download-link-format. Now it does. Close: #6202 Co-authored-by: zrquan <zrquan@users.noreply.github.com>
This commit is contained in:
parent
7ca50e0ce8
commit
1f4b9b73fc
1 changed files with 20 additions and 0 deletions
|
@ -56,6 +56,26 @@
|
|||
(file-relative-name path org-download-image-dir)
|
||||
path)))
|
||||
|
||||
(defadvice! +org--fix-org-download-delete-a (fn beg end &optional times)
|
||||
"Fix `org-download-delete' for a non-standard `org-download-link-format'."
|
||||
:around #'org-download--delete
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(goto-char beg)
|
||||
(let ((times (or times most-positive-fixnum))
|
||||
(linkname
|
||||
(or (and (string-match "\\[\\[\\(\\w+\\):" org-download-link-format)
|
||||
(match-string 1 org-download-link-format))
|
||||
"file")))
|
||||
(while (and (>= (cl-decf times) 0)
|
||||
(re-search-forward (format "\\[\\[%s:\\([^]]*\\)\\]\\]"
|
||||
(regexp-quote linkname))
|
||||
end t))
|
||||
(let ((str (match-string-no-properties 2)))
|
||||
(delete-region beg (match-end 0))
|
||||
(when (file-exists-p str)
|
||||
(delete-file str))))))))
|
||||
|
||||
(defadvice! +org--dragndrop-then-display-inline-images-a (_link filename)
|
||||
:after #'org-download-insert-link
|
||||
(when (image-type-from-file-name filename)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue