 ;;; defuns-org-attach.el --- custom attachment system
+
+;; I know Org has its own attachment system, but I don't like it.
 
 ;;;###autoload (autoload 'narf:org-attach "defuns-org-attach" nil t)
 (evil-define-command narf:org-attach (&optional bang link)
   (interactive "<!><a>")
   (if (not link)
-      (narf/org-attachment-list)
+      (narf:org-attachment-list bang)
     (require 'org-download)
     (let ((new-path (if bang
                         (format "%s/%s" (expand-file-name org-download-image-dir org-directory)

         (f-dirname (org-element-property :path context))
       org-download-image-dir))))

;;;###autoload
(defun narf--org-attachments ()
  (org-element-map (org-element-parse-buffer) 'link
    (lambda (link)
      (when (and (string= (org-element-property :type link) "file")

                                        (format-time-string org-download-timestamp)
                                        (file-name-extension link))) buffer-file-name
                                        (org-download--fullname link))))
      (unless new-path
        (user-error "No file was provided"))
      (cond ((string-match-p "^https?://" link)
             (url-copy-file link new-path))
            (t (copy-file link new-path)))
      (insert (format "[[./%s]]" (f-relative new-path default-directory))))))

;;;###autoload (autoload 'narf:org-attachment-list "defuns-org-attach" nil t)
(evil-define-command narf:org-attachment-list (&optional bang)
  (interactive "<!>")
  (if bang
      (narf:org-attachment-cleanup)
    (let ((attachments (narf-org--get-attachments)))
      (unless attachments
        (user-error "No attachments in this file"))
      (helm :sources
            (helm-build-sync-source "Attachments"
              :candidates attachments
              :real-to-display 'narf-org--attachment-real-to-display
              :action '(("Go to Attachment in Buffer" . narf-org--attachment-find)
                        ("Reveal Attachment in Finder" . narf-org--attachment-reveal)
                        ("Open Attachment" . narf-org--attachment-open)
                        ("Delete Attachment" . narf-org--attachment-delete)))))))

;; TODO Improve
;;;###autoload
(defun narf/org-attachment-reveal ()
  (interactive)
  (let ((context (org-element-context)))
    (narf-open-with
