drag and drop
[email protected] (ARISAWA Akihiro)
| Newsgroups | gmane.mail.emacs.mime.japanese |
|---|---|
| Message-ID | <[email protected]> |
MIME-Edit にて drag and drop でファイルを添付できるようにしてみました。 対応している環境は X 上の Emacs-21.3.50 と Windows 上の Emacs-21 や Meadow-2 です。 Windows 上の Emacs-20 や Meadow-1 でも動くかもしれませんが未確認です。 あと XEmacs は全く確認していませんが、X では間違いなく動作しません。 Windows 上の XEmacs も動かなそうですし、もしかしたらエラーが発生 するかもしれません。 ということで、まだ cvs に commit する勇気がありません(^^; みなさまの動作報告などお待ちしています。 -- 有沢 明宏
mime-edit-dnd.patch
(application/octet-stream, 1.5 KB)
Index: mime-edit.el
===================================================================
RCS file: /cvs/root/semi/mime-edit.el,v
retrieving revision 1.37.2.16
diff -u -r1.37.2.16 mime-edit.el
--- mime-edit.el 15 Jan 2004 12:22:47 -0000 1.37.2.16
+++ mime-edit.el 17 Feb 2004 03:47:17 -0000
@@ -788,6 +788,9 @@
mime-edit-mode-entity-prefix mime-edit-mode-entity-map)
(define-key mime-edit-mode-map
mime-edit-mode-enclosure-prefix mime-edit-mode-enclosure-map)
+(when (eq window-system 'w32)
+ (define-key mime-edit-mode-map [drag-n-drop] 'mime-edit-w32-dnd-attach-file))
+
(defconst mime-edit-menu-title "MIME-Edit")
@@ -1061,6 +1064,13 @@
(setq paragraph-separate
(regexp-or mime-edit-single-part-tag-regexp
paragraph-separate))
+
+ (when (boundp 'x-dnd-protocol-alist)
+ (set (make-local-variable 'x-dnd-protocol-alist)
+ '(("^file:///" . mime-edit-x-dnd-attach-file)
+ ("^file://" . x-dnd-open-file)
+ ("^file:" . mime-edit-x-dnd-attach-file))))
+
(run-hooks 'mime-edit-mode-hook)
(message
"%s"
@@ -2401,6 +2411,17 @@
)
))))
+;; drag and drop
+
+(defun mime-edit-w32-dnd-attach-file (event)
+ "Attach a drag and drop file."
+ (interactive "e")
+ (mapc #'(lambda (file) (mime-edit-insert-file file 'verbose))
+ (car (cdr (cdr event)))))
+
+(defun mime-edit-x-dnd-attach-file (uri action)
+ "Attach a drag and drop file."
+ (mime-edit-insert-file (x-dnd-get-local-file-name uri t) 'verbose))
;;; @ multipart enclosure
;;;