--- Begin Message ---
Subject: |
Re: Drag-and-drop to attach file in vm mail composition buffer |
Date: |
Thu, 26 Aug 2004 18:03:50 GMT |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
kosowsky@consult.pretender (Jeffrey J. Kosowsky) writes:
> Using gnuserv, I can use drag-and-drop to open a file in emacs.
>
> I would like to modify the behavior when the buffer that is exposed is
> a mail composition buffer so that the dragged file is attached to the
> mail composition buffer rather than opening the file in a new buffer.
>
> Notionally, instead of doing something like '(find-file file)', I
> would do something like '(vm-mime-attach-file file)'.
>
> However, despite reading gnuserv.el, I can't figure out how and where
> to patch this in.
>
> Any thoughts on how to do this?
>
OK, I figured it out. Win32 drag-n-drop doesen't use
gnuserv/gnuclientw. The relevant functions are documented in
term/w32-win.el.
I was able to get the desired affect by making some slight
modifications to the function:
(defun w32-drag-n-drop (event)
"Edit the files listed in the drag-n-drop EVENT.
Switch to a buffer editing the last file dropped.
JJK: Added logic so that adds mime attachments if dragged over a buffer
in \"Mail\" mode"
(interactive "e")
(save-excursion
;; Make sure the drop target has positive co-ords
;; before setting the selected frame - otherwise it
;; won't work. <skx@tardis.ed.ac.uk>
(let* ((window (posn-window (event-start event)))
(coords (posn-x-y (event-start event)))
(x (car coords))
(y (cdr coords)))
(if (and (> x 0) (> y 0))
(set-frame-selected-window nil window))
; JJK addition start
(if (string= mode-name "Mail")
(mapcar
(lambda (file)
(vm-mime-attach-file file "application/octet-stream"))
(car (cdr (cdr event))))
(mapcar 'find-file (car (cdr (cdr event))))))
; JJK addition end
; (mapcar 'find-file (car (cdr (cdr event)))))
(raise-frame)))
--- End Message ---