summaryrefslogtreecommitdiff
path: root/lisp/term
diff options
context:
space:
mode:
authorAlan Third <alan@idiocy.org>2019-01-05 16:11:37 +0000
committerAlan Third <alan@idiocy.org>2019-01-10 19:24:19 +0000
commitc342b26371480316024e1e5d63cd8b3f035dda69 (patch)
treeec999f6d48e5737528f48f9c0224de5db8a13d10 /lisp/term
parent7ae0a24c87c2bbefe78717d5e89cf3fe14f4af4c (diff)
downloademacs-c342b26371480316024e1e5d63cd8b3f035dda69.tar.gz
Fix drag and drop behaviour on NS (bug#30929)
* doc/emacs/macos.texi (Mac / GNUstep Events): Describe the new drag and drop behaviour. * lisp/term/ns-win.el (ns-drag-n-drop): Handle the new event format. (ns-drag-n-drop-other-frame): (ns-drag-n-drop-as-text): (ns-drag-n-drop-as-text-other-frame): Remove functions and key bindings. * src/nsterm.m ([EmacsView performDragOperation:]): Send Emacs event in new format without setting any modifiers.
Diffstat (limited to 'lisp/term')
-rw-r--r--lisp/term/ns-win.el54
1 files changed, 22 insertions, 32 deletions
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index c9f5bfef520..6a668b213dd 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -501,48 +501,38 @@ unless the current buffer is a scratch buffer."
(find-file f)))))
-(defun ns-drag-n-drop (event &optional new-frame force-text)
+(defun ns-drag-n-drop (event)
"Edit the files listed in the drag-n-drop EVENT.
-Switch to a buffer editing the last file dropped."
+Switch to a buffer editing the last file dropped, or insert the
+string dropped into the current buffer."
(interactive "e")
(let* ((window (posn-window (event-start event)))
(arg (car (cdr (cdr event))))
(type (car arg))
- (data (car (cdr arg)))
- (url-or-string (cond ((eq type 'file)
- (concat "file:" data))
- (t data))))
+ (operations (car (cdr arg)))
+ (objects (cdr (cdr arg)))
+ (string (mapconcat 'identity objects "\n")))
(set-frame-selected-window nil window)
- (when new-frame
- (select-frame (make-frame)))
(raise-frame)
(setq window (selected-window))
- (if force-text
- (dnd-insert-text window 'private data)
- (dnd-handle-one-url window 'private url-or-string))))
-
-
-(defun ns-drag-n-drop-other-frame (event)
- "Edit the files listed in the drag-n-drop EVENT, in other frames.
-May create new frames, or reuse existing ones. The frame editing
-the last file dropped is selected."
- (interactive "e")
- (ns-drag-n-drop event t))
-
-(defun ns-drag-n-drop-as-text (event)
- "Drop the data in EVENT as text."
- (interactive "e")
- (ns-drag-n-drop event nil t))
-
-(defun ns-drag-n-drop-as-text-other-frame (event)
- "Drop the data in EVENT as text in a new frame."
- (interactive "e")
- (ns-drag-n-drop event t t))
+ (cond ((memq 'ns-drag-operation-generic operations)
+ ;; Perform the default action for the type.
+ (if (eq type 'file)
+ (dolist (data objects)
+ (dnd-handle-one-url window 'private (concat "file:" data)))
+ (dnd-insert-text window 'private string)))
+ ((memq 'ns-drag-operation-copy operations)
+ ;; Try to open the file/URL. If type is nil, try to open
+ ;; it as a URL anyway.
+ (dolist (data objects)
+ (dnd-handle-one-url window 'private (if (eq type 'file)
+ (concat "file:" data)
+ data))))
+ (t
+ ;; Insert the text as is.
+ (dnd-insert-text window 'private string)))))
(global-set-key [drag-n-drop] 'ns-drag-n-drop)
-(global-set-key [C-drag-n-drop] 'ns-drag-n-drop-other-frame)
-(global-set-key [M-drag-n-drop] 'ns-drag-n-drop-as-text)
-(global-set-key [C-M-drag-n-drop] 'ns-drag-n-drop-as-text-other-frame)
;;;; Frame-related functions.