Function: ghostel--drop

ghostel--drop is an interactive and natively compiled function defined in ghostel.el.

Signature

(ghostel--drop EVENT)

Documentation

Handle a drag-and-drop EVENT into the terminal.

File drops paste their shell-quoted paths, text drops paste as-is, into the terminal shown in the event's window.

Key Bindings

ghostel--dnd-area-map <header-line> <drag-n-drop> ghostel--dnd-area-map <left-fringe> <drag-n-drop> ghostel--dnd-area-map <mode-line> <drag-n-drop> ghostel--dnd-area-map <right-fringe> <drag-n-drop> ghostel-char-mode-map <drag-n-drop> ghostel-mode-map <drag-n-drop>

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--drop (event)
  "Handle a drag-and-drop EVENT into the terminal.
File drops paste their shell-quoted paths, text drops paste as-is,
into the terminal shown in the event's window."
  (interactive "e")
  ;; On macOS (NS port) the event structure is:
  ;;   (drag-n-drop POSN (TYPE OPERATIONS . OBJECTS))
  ;; where (nth 2 event) carries the drop data, not the position.
  ;; Not `event-start': its posn-at-point fallback would invent a
  ;; selected-window position for a posn-less synthetic event.
  (let ((arg (nth 2 event))
        (window (posn-window (nth 1 event))))
    (when (and arg (not (eq arg 'lambda)))
      (let ((type (car arg))
            (objects (cddr arg)))
        ;; Drop events arrive with the selected window's buffer current.
        (with-current-buffer (if (windowp window)
                                 (window-buffer window)
                               (current-buffer))
          (if (eq type 'file)
              (ghostel--dnd-send-files objects)
            (ghostel-paste-string (mapconcat #'identity objects "\n"))))))))