[mew-dist 29546] Re: Q: attach file by drag&drop

Hideyuki SHIRAI ( 白井秀行 ) shirai at example.com
2012年 12月 30日 (日) 16:38:03 JST


こんにちは。最近 MBA 使っている白井です。

From: moto kawasaki <moto at example.com> さん曰く
Subject: [mew-dist 29545] Q: attach file by drag&drop
Message-ID: <20121230.113312.117957834876184743.moto at example.com>
Date: Sun, 30 Dec 2012 11:33:12 +0900 (JST)

> 最近、OS/Emacs/Mew のバージョンを上げたのですが、昔の環境ではできてい
> たところの
> 
>     Mew でメイル作成中にファイルをドラッグ&ドロップすれば、
>     そのファイルが添付される
> 
> ができなくて困っております。
> 解決策があれば教えてくださいませ。
> # C-c C-a からファイルを添付することは可能です。
> 
> 今の環境は次のとおりです。
> 
>     OS:     Mac OS X 10.7.5 (Darwin 11.4.2 x86_64)
>     Emacs:  GNU Emacs 24.2.50.2 (x86_64-apple-darwin11.4.2, NS
>             apple-appkit-1138.51) of 2012-10-13
>     Mew:    Mew version 6.5

OSX だと drag & drop が ns-drag-file という key で ns-find-file
に割り当てられているからの様ですね。OSX のことをよくわかっていな
いので見落としがあるような気もしますが、

(add-hook
 'mew-draft-mode-hook
 (lambda ()
   (define-key mew-draft-body-map [ns-drag-file] 'mew-draft-ns-attach-file)
   (define-key mew-draft-header-map [ns-drag-file] 'mew-draft-ns-attach-file)
   (define-key mew-draft-attach-map [ns-drag-file] 'mew-draft-ns-attach-file)))

(defun mew-draft-ns-attach-file ()
  "File attach with the `ns-input-file' as argument."
  (interactive)
  (let* ((from (file-truename
		(expand-file-name (pop ns-input-file)
				  command-line-default-directory)))
	 (to (file-name-nondirectory from)))
    (when from
      (unless (mew-attach-p)
	(mew-draft-prepare-attachments))
      (goto-char (point-max))
      (forward-line -2)
      (mew-attach-next)
      (cond
       ((file-directory-p from)
	(message "Directory cannot be attached"))
       (t
	(mew-attach-copy from to))))))

で(とりあえずは)出来ました。

-- 
白井秀行 (mailto:shirai at example.com)


Mew-dist メーリングリストの案内