org-download icon indicating copy to clipboard operation
org-download copied to clipboard

Make org-download-edit work with org-attach-directories

Open codygman opened this issue 3 years ago • 0 comments

No time for a PR and I bet someone uses the shell-expansion I removed, so this is just to gauge interest and give others that need it a solution as a start:

(defun org-download-edit ()
  "Open the image at point for editing."
  (interactive)
  (let ((context (org-element-context)))
    (if (not (eq (car-safe context) 'link))
        (user-error "Not on a link")
      (let* ((filename (url-unhex-string (plist-get (cadr (org-element-context)) :path)))
	     (filepath (org-attach-expand filename)))
	(start-process-shell-command
	 "org-download-edit"
	 "org-download-edit"
	 (format org-download-edit-cmd filepath))))))

In my config I now have:

(defun my/org-download-edit ()
    "Open the image at point for editing."
    (interactive)
    (let ((context (org-element-context)))
      (if (not (eq (car-safe context) 'link))
          (user-error "Not on a link")
        (let* ((filename (url-unhex-string (plist-get (cadr (org-element-context)) :path)))
               (filepath (org-attach-expand filename)))
          (start-process-shell-command
           "org-download-edit"
           "org-download-edit"
           (format org-download-edit-cmd filepath))))))
  
  (advice-add 'org-download-edit :override
              'my/org-download-edit)

codygman avatar Oct 18 '21 14:10 codygman