aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/term
diff options
context:
space:
mode:
authorAlan Third2019-01-05 16:11:37 +0000
committerAlan Third2019-01-10 19:24:19 +0000
commitc342b26371480316024e1e5d63cd8b3f035dda69 (patch)
treeec999f6d48e5737528f48f9c0224de5db8a13d10 /lisp/term
parent7ae0a24c87c2bbefe78717d5e89cf3fe14f4af4c (diff)
downloademacs-c342b26371480316024e1e5d63cd8b3f035dda69.tar.gz
emacs-c342b26371480316024e1e5d63cd8b3f035dda69.zip
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."
501 (find-file f))))) 501 (find-file f)))))
502 502
503 503
504(defun ns-drag-n-drop (event &optional new-frame force-text) 504(defun ns-drag-n-drop (event)
505 "Edit the files listed in the drag-n-drop EVENT. 505 "Edit the files listed in the drag-n-drop EVENT.
506Switch to a buffer editing the last file dropped." 506Switch to a buffer editing the last file dropped, or insert the
507string dropped into the current buffer."
507 (interactive "e") 508 (interactive "e")
508 (let* ((window (posn-window (event-start event))) 509 (let* ((window (posn-window (event-start event)))
509 (arg (car (cdr (cdr event)))) 510 (arg (car (cdr (cdr event))))
510 (type (car arg)) 511 (type (car arg))
511 (data (car (cdr arg))) 512 (operations (car (cdr arg)))
512 (url-or-string (cond ((eq type 'file) 513 (objects (cdr (cdr arg)))
513 (concat "file:" data)) 514 (string (mapconcat 'identity objects "\n")))
514 (t data))))
515 (set-frame-selected-window nil window) 515 (set-frame-selected-window nil window)
516 (when new-frame
517 (select-frame (make-frame)))
518 (raise-frame) 516 (raise-frame)
519 (setq window (selected-window)) 517 (setq window (selected-window))
520 (if force-text 518 (cond ((memq 'ns-drag-operation-generic operations)
521 (dnd-insert-text window 'private data) 519 ;; Perform the default action for the type.
522 (dnd-handle-one-url window 'private url-or-string)))) 520 (if (eq type 'file)
523 521 (dolist (data objects)
524 522 (dnd-handle-one-url window 'private (concat "file:" data)))
525(defun ns-drag-n-drop-other-frame (event) 523 (dnd-insert-text window 'private string)))
526 "Edit the files listed in the drag-n-drop EVENT, in other frames. 524 ((memq 'ns-drag-operation-copy operations)
527May create new frames, or reuse existing ones. The frame editing 525 ;; Try to open the file/URL. If type is nil, try to open
528the last file dropped is selected." 526 ;; it as a URL anyway.
529 (interactive "e") 527 (dolist (data objects)
530 (ns-drag-n-drop event t)) 528 (dnd-handle-one-url window 'private (if (eq type 'file)
531 529 (concat "file:" data)
532(defun ns-drag-n-drop-as-text (event) 530 data))))
533 "Drop the data in EVENT as text." 531 (t
534 (interactive "e") 532 ;; Insert the text as is.
535 (ns-drag-n-drop event nil t)) 533 (dnd-insert-text window 'private string)))))
536
537(defun ns-drag-n-drop-as-text-other-frame (event)
538 "Drop the data in EVENT as text in a new frame."
539 (interactive "e")
540 (ns-drag-n-drop event t t))
541 534
542(global-set-key [drag-n-drop] 'ns-drag-n-drop) 535(global-set-key [drag-n-drop] 'ns-drag-n-drop)
543(global-set-key [C-drag-n-drop] 'ns-drag-n-drop-other-frame)
544(global-set-key [M-drag-n-drop] 'ns-drag-n-drop-as-text)
545(global-set-key [C-M-drag-n-drop] 'ns-drag-n-drop-as-text-other-frame)
546 536
547;;;; Frame-related functions. 537;;;; Frame-related functions.
548 538