GNU bug report logs - #5248
23.1.90; Patch for OS X drag-and-drop

Previous Next

Package: emacs;

Reported by: bodhi <bodhi <at> 5263.org>

Date: Sat, 19 Dec 2009 17:26:02 UTC

Severity: wishlist

Tags: patch

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5248 in the body.
You can then email your comments to 5248 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5248; Package emacs. (Sat, 19 Dec 2009 17:26:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to bodhi <bodhi <at> 5263.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 19 Dec 2009 17:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: bodhi <bodhi <at> 5263.org>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.1.90; Patch for OS X drag-and-drop
Date: Sat, 19 Dec 2009 23:42:13 +1100
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;
    }




bug reassigned from package 'emacs' to 'emacs,ns'. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 19 Dec 2009 20:08:02 GMT) Full text and rfc822 format available.

Added tag(s) patch. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 19 Dec 2009 20:08:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5248; Package emacs,ns. (Tue, 13 Jul 2010 10:57:02 GMT) Full text and rfc822 format available.

Message #12 received at 5248 <at> debbugs.gnu.org (full text, mbox):

From: Adrian Robert <adrian.b.robert <at> gmail.com>
To: bodhi <at> 5263.org
Cc: 5248 <at> debbugs.gnu.org
Subject: Re: 23.1.90; Patch for OS X drag-and-drop
Date: Tue, 13 Jul 2010 13:56:13 +0300
Hi,

Thanks for this patch, it looks good.  In thinking about committing it, I would just like to know what is your rationale for setting this behavior:

drag file URL -> NS_DRAG_FILE -> (current handling)
drag non-fileURL -> NS_DRAG_URL -> (ns-drag-url vkey) -> ns-insert-text

I think this makes sense, but did you go by analogy to emacs under W32, or Aquamacs, or GTK, or other apps on the Mac, or your own intuitions, or... ?

thanks,
Adrian





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5248; Package emacs. (Wed, 17 Feb 2016 03:37:01 GMT) Full text and rfc822 format available.

Message #15 received at 5248 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Hyatt <ahyatt <at> gmail.com>
To: Adrian Robert <adrian.b.robert <at> gmail.com>
Cc: bodhi <at> 5263.org, 5248 <at> debbugs.gnu.org
Subject: Re: bug#5248: 23.1.90; Patch for OS X drag-and-drop
Date: Tue, 16 Feb 2016 22:36:01 -0500
I can drag & drop URLs with Emacs 25, however it doesn't look like this
patch was every accepted.

Still, this doesn't looks more like an improvement than a bugfix, so I'm
marking this as wishlist.

Adrian Robert <adrian.b.robert <at> gmail.com> writes:

> Hi,
>
> Thanks for this patch, it looks good.  In thinking about committing it, I would just like to know what is your rationale for setting this behavior:
>
> drag file URL -> NS_DRAG_FILE -> (current handling)
> drag non-fileURL -> NS_DRAG_URL -> (ns-drag-url vkey) -> ns-insert-text
>
> I think this makes sense, but did you go by analogy to emacs under W32, or Aquamacs, or GTK, or other apps on the Mac, or your own intuitions, or... ?
>
> thanks,
> Adrian




Severity set to 'wishlist' from 'normal' Request was from Andrew Hyatt <ahyatt <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 17 Feb 2016 03:37:02 GMT) Full text and rfc822 format available.

Reply sent to Alan Third <alan <at> idiocy.org>:
You have taken responsibility. (Sat, 06 Apr 2019 16:21:01 GMT) Full text and rfc822 format available.

Notification sent to bodhi <bodhi <at> 5263.org>:
bug acknowledged by developer. (Sat, 06 Apr 2019 16:21:02 GMT) Full text and rfc822 format available.

Message #22 received at 5248-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Third <alan <at> idiocy.org>
To: Andrew Hyatt <ahyatt <at> gmail.com>
Cc: bodhi <at> 5263.org, Adrian Robert <adrian.b.robert <at> gmail.com>,
 5248-done <at> debbugs.gnu.org
Subject: Re: bug#5248: 23.1.90; Patch for OS X drag-and-drop
Date: Sat, 06 Apr 2019 17:20:38 +0100
Andrew Hyatt <ahyatt <at> gmail.com> writes:

> I can drag & drop URLs with Emacs 25, however it doesn't look like this
> patch was every accepted.
>
> Still, this doesn't looks more like an improvement than a bugfix, so I'm
> marking this as wishlist.

I don't think this patch is relevant any more. I think the desired
behaviour is available, and besides, the drag and drop code has been
rewritten for Emacs 27.
-- 
Alan Third




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 05 May 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 358 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.