From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: bodhi Newsgroups: gmane.emacs.bugs,gmane.emacs.pretest.bugs Subject: bug#5248: 23.1.90; Patch for OS X drag-and-drop Date: Sat, 19 Dec 2009 23:42:13 +1100 Message-ID: Reply-To: bodhi , 5248@debbugs.gnu.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: ger.gmane.org 1261375511 26852 80.91.229.12 (21 Dec 2009 06:05:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Dec 2009 06:05:11 +0000 (UTC) To: emacs-pretest-bug@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 21 07:05:04 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NMbO7-0008Rn-Rg for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Dec 2009 07:05:00 +0100 Original-Received: from localhost ([127.0.0.1]:59426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMbO8-0006oc-0g for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Dec 2009 01:05:00 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NM3I1-0000jW-W9 for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2009 12:40:26 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NM3Hw-0000fQ-IX for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2009 12:40:25 -0500 Original-Received: from [199.232.76.173] (port=35704 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NM3Hv-0000ew-QO for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2009 12:40:19 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:34850) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NM3Hv-0007yM-HJ for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2009 12:40:19 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1NM346-0004vK-Kz; Sat, 19 Dec 2009 12:26:02 -0500 X-Loop: bug-gnu-emacs@gnu.org Mail-Followup-To: bodhi , 5248@debbugs.gnu.org Resent-From: bodhi Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Dec 2009 17:26:02 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-Emacs-PR-Message: report 5248 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.126124354618906 (code B ref -1); Sat, 19 Dec 2009 17:26:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Dec 2009 17:25:46 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NM33p-0004up-G0 for submit@debbugs.gnu.org; Sat, 19 Dec 2009 12:25:46 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NLyzV-0003DX-6b for submit@debbugs.gnu.org; Sat, 19 Dec 2009 08:05:14 -0500 Original-Received: from mx10.gnu.org ([199.232.76.166]:33197) by fencepost.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NLyzQ-0007B8-9g for emacs-pretest-bug@gnu.org; Sat, 19 Dec 2009 08:04:56 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NLyzO-0002Ud-Ik for emacs-pretest-bug@gnu.org; Sat, 19 Dec 2009 08:04:55 -0500 Original-Received: from 60-241-63-147.tpgi.com.au ([60.241.63.147]:63631 helo=pasokun.local) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NLyzN-0002UH-LN for emacs-pretest-bug@gnu.org; Sat, 19 Dec 2009 08:04:54 -0500 Original-Received: by pasokun.local (Postfix, from userid 501) id 264E05796F9; Sat, 19 Dec 2009 23:42:13 +1100 (EST) X-detected-operating-system: by monty-python.gnu.org: FreeBSD 6.x (1) X-Greylist: delayed 1352 seconds by postgrey-1.27 at monty-python; Sat, 19 Dec 2009 08:04:50 EST X-Mailman-Approved-At: Sat, 19 Dec 2009 12:25:41 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 19 Dec 2009 12:26:02 -0500 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Mon, 21 Dec 2009 01:01:58 -0500 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:33707 gmane.emacs.pretest.bugs:25342 Archived-At: Hi, I made a patch on the latest emacs git repository, I guess this is mirrored regularly from the canonical repository? The patch modifies emacs to accept all dropped urls, not just files. The file-url behaviour should be unchanged, but when a non-file url is dropped it sends a new event with the text of the url, which by default inserts the text. Maybe a new event isn't necessary, and it could be treated as dropping text? The patch is included below, and is also available at http://gist.github.com/260042 Thanks, Bodhi ---- diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index 157b2dd..13bd0ac 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -277,6 +277,7 @@ The properties returned may include `top', `left', `height', and `width'." (define-key global-map [ns-new-frame] 'make-frame) (define-key global-map [ns-toggle-toolbar] 'ns-toggle-toolbar) (define-key global-map [ns-show-prefs] 'customize) +(define-key global-map [ns-drag-url] 'ns-insert-text) ;; Set up a number of aliases and other layers to pretend we're using @@ -315,6 +316,7 @@ The properties returned may include `top', `left', `height', and `width'." (cons (logior (lsh 0 16) 12) 'ns-new-frame) (cons (logior (lsh 0 16) 13) 'ns-toggle-toolbar) (cons (logior (lsh 0 16) 14) 'ns-show-prefs) + (cons (logior (lsh 0 16) 15) 'ns-drag-url) (cons (logior (lsh 1 16) 32) 'f1) (cons (logior (lsh 1 16) 33) 'f2) (cons (logior (lsh 1 16) 34) 'f3) diff --git a/src/nsterm.h b/src/nsterm.h index 29d312a..8536660 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -365,6 +365,7 @@ typedef unsigned int NSUInteger; #define KEY_NS_NEW_FRAME ((1<<28)|(0<<16)|12) #define KEY_NS_TOGGLE_TOOLBAR ((1<<28)|(0<<16)|13) #define KEY_NS_SHOW_PREFS ((1<<28)|(0<<16)|14) +#define KEY_NS_DRAG_URL ((1<<28)|(0<<16)|15) /* could use list to store these, but rest of emacs has a big infrastructure for managing a table of bitmap "records" */ diff --git a/src/nsterm.m b/src/nsterm.m index 9256c08..73ede9a 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5456,20 +5456,24 @@ extern void update_window_cursor (struct window *w, int on); } else if ([type isEqualToString: NSURLPboardType]) { - NSString *file; - NSURL *fileURL; - - if (!(fileURL = [NSURL URLFromPasteboard: pb]) || - [fileURL isFileURL] == NO) - return NO; - - file = [fileURL path]; + NSString *path; + NSURL *url; + + if (!(url = [NSURL URLFromPasteboard: pb])) { + return NO; + } else if ([url isFileURL] == YES) { + path = [url path]; + emacs_event->code = KEY_NS_DRAG_FILE; + ns_input_file = append2 (ns_input_file, build_string ([path UTF8String])); + } else { + path = [url absoluteString]; + emacs_event->code = KEY_NS_DRAG_URL; + ns_input_text = build_string ([path UTF8String]); + } emacs_event->kind = NS_NONKEY_EVENT; - emacs_event->code = KEY_NS_DRAG_FILE; + emacs_event->modifiers = EV_MODIFIERS (theEvent); XSETINT (emacs_event->x, x); XSETINT (emacs_event->y, y); - ns_input_file = append2 (ns_input_file, build_string ([file UTF8String])); - emacs_event->modifiers = EV_MODIFIERS (theEvent); EV_TRAILER (theEvent); return YES; }