I would like to code the same behavior as Mail: in the Finder, I copy the relevant file or files, go to a Mail message, and they are pasted as attachments.
I wrote this function to attach one file from the clipboard:
(defun add-attachment () "Include at the end of the buffer the attachment in the interprogram-paste-function, assuming it is from the Downloads folder." (interactive) (let ((prev-point (point))) (goto-char (point-max)) (insert (concat "\n\n" "<#part filename=\"/Users/username/Downloads/" (shell-command-to-string "pbpaste") "\" disposition=attachment>" "\n" "<#/part>")) (goto-char prev-point)))
The problem is that the file has to be in the Downloads folder. The Mail program has access to more information, such as the folder, because it attaches a document instead of pasting the filename (which is Emacs's behavior).
How can I access this information and include in Emacs the full path to the files in the clipboard?