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

Hideyuki SHIRAI (白井秀行) <[email protected]> Sun, 30 Dec 2012 16:38:03 +0900 (JST)
Newsgroups gmane.mail.mew.general.japanese
Organization Resident at Meadowy farm.
Message-ID <[email protected]>
 MBA 

From: moto kawasaki <[email protected]> 
Subject: [mew-dist 29545] Q: attach file by drag&drop
Message-ID: <[email protected]>
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:[email protected])