From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [patch] enhanced mac drag-n-drop Date: Wed, 06 Apr 2005 07:37:24 -0400 Message-ID: <87br8sdu99.fsf-monnier+emacs@gnu.org> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1112787373 19481 80.91.229.2 (6 Apr 2005 11:36:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Apr 2005 11:36:13 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 06 13:36:11 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DJ8p0-0006f5-Re for ged-emacs-devel@m.gmane.org; Wed, 06 Apr 2005 13:35:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DJ8O6-0001Ps-9k for ged-emacs-devel@m.gmane.org; Wed, 06 Apr 2005 07:07:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DJ8Nv-0001Oo-1N for emacs-devel@gnu.org; Wed, 06 Apr 2005 07:07:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DJ8Nu-0001O8-Mr for emacs-devel@gnu.org; Wed, 06 Apr 2005 07:07:46 -0400 Original-Received: from [209.226.175.110] (helo=tomts43-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DJ8r0-0005gm-Hd for emacs-devel@gnu.org; Wed, 06 Apr 2005 07:37:50 -0400 Original-Received: from alfajor ([67.68.217.126]) by tomts43-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20050406113724.BCKS28273.tomts43-srv.bellnexxia.net@alfajor>; Wed, 6 Apr 2005 07:37:24 -0400 Original-Received: by alfajor (Postfix, from userid 1000) id 3F9FCD75EC; Wed, 6 Apr 2005 07:37:24 -0400 (EDT) Original-To: "Sean O'Rourke" In-Reply-To: (Sean O'Rourke's message of "Tue, 05 Apr 2005 17:53:00 -0700") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:35621 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:35621 > "Perform the most common action for each type of item dropped > onto Emacs on Mac OS X. Currently, this means: > * File or directory -- call `find-file'. > * URL -- call `browse-url-browser-function'. > * Text -- insert text at point." I use my MacOSX system pretty much exclusively as an X11 server, so maybe I don't understand enough of Mac OS X's GUI philosophy, but I believe that the behavior by default for URL should be the same as for Text, except maybe when the browse-url function is configured to use one of the Emacs based webbrowsers (like W3, or emacs-w3m). The idea is that if I want to open a URL in Safari or Firefox, I'll drag&drop it there, whereas if I drop it onto Emacs I most likely *don't* intend it to go to my external browser. Of course, if I have url-handlers-mode enabled, maybe I intend URL-drops to call find-file as well ;-) > (interactive "e") > ;; Make sure the drop target has positive co-ords before setting the > ;; selected frame - otherwise it won't work. > (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)) Under which circumstances can X and/or Y be negative? > (mapcar > (lambda (name) > (case (car name) Please use dolist instead of mapcar here. > (text (insert (cdr name))) > (url (funcall browse-url-browser-function (cdr name))) Why not (browse-url (cdr name)) ? > (file > (setq name (cdr name)) > (if (and (file-exists-p name) > (not (string-match (image-file-name-regexp) name))) > (find-file name) > (insert name))))) What is the rationale for the (image-file-name-regexp) exception? > (cadd event))) > (raise-frame) > (recenter)) Why are raise-frame and recenter necessary? > (defun mac-secondary-dnd-function (event) Please factor out the commonality between the two functions into an auxiliary function. > (global-set-key [shift drag-n-drop] 'mac-secondary-dnd-function) Does this work? Shouldn't it be [(shift drag-n-drop)]? Stefan PS: When I ask a question about a piece of code, the answer should typically be either to change the code, or to add a comment answering the question.