Skip to content

Add ghostel-send-files-function for dropped and pasted files - #793

Merged
dakra merged 1 commit into
mainfrom
feat/send-files-function
Nov 6, 2026
Merged

dakra merged 1 commit into
mainfrom
feat/send-files-function

Conversation

@dakra

@dakra dakra commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

A file dropped on a terminal, or an image pasted with yank-media, is pasted as a shell-quoted local path. A client that bridges a terminal on another machine, such as rexel, needs the files themselves: the local path does not exist where the program runs.

ghostel-send-files-function sits next to ghostel-pty-out-function and ghostel-resize-function. When set, it receives the list of local file names and nothing is pasted:

 ghostel--dnd-send-files (files)
+  if ghostel-send-files-function
+    call it with files
+  else
     paste the shell-quoted paths, followed by a space

All three entry points go through that function: the dnd-protocol-alist handler (X11, pgtk), ghostel--drop (NS, w32) and ghostel--yank-media-data. The call counts as user input, as the paste does.

A pasted image reaches the function as a file on this machine. Without the function it is still written to the temp directory of a remote default-directory, where the shell reads it. A bridged terminal can have a remote default-directory from the shell's OSC 7 report.

A terminal without a process but with ghostel-pty-out-function now counts as live for the two entry points that check:

  • ghostel--dnd-handle-file opened the dropped file in Emacs.
  • ghostel--yank-media-data signalled "Terminal has no live process".

ghostel--init-buffer clears the new variable with the other two bridge functions.

Testing

  • New tests: the hook receives the files on the dnd-layer and ghostel--drop paths and nothing is pasted; it gets a local file for a pasted image with a remote default-directory; a dead terminal opens a dropped file and does not call it; a processless terminal pastes a dropped file and accepts a pasted image; ghostel--init-buffer clears the variable.
  • Locally make test test-native test-evil test-consult lint passes against an existing module build, apart from 12 ghostel-module-test tests that fail the same way on main on my machine (a native-comp trampoline link error). The module build and make test-zig did not run locally: the machine has Zig 0.17.1. The change is Lisp only.
  • Exercised live from rexel against a Rex server: drops through dnd-handle-multiple-urls and a synthetic ghostel--drop event and an image through ghostel--yank-media-data all reached the hook and were uploaded.

@dakra
dakra force-pushed the feat/send-files-function branch 3 times, most recently from 76f63f5 to 62dd04a Compare November 6, 2026 22:07
A file dropped on a terminal, or an image pasted with yank-media, is
pasted as a shell-quoted local path.  That is wrong for a client that
bridges a terminal on another machine, such as rexel: the path does not
exist there.

ghostel-send-files-function, when set, receives the local file names
instead of the paste, next to ghostel-pty-out-function and
ghostel-resize-function.  ghostel--init-buffer clears it with them.
The call counts as user input, as the paste does.

A pasted image goes to the function as a file on this machine.  Without
the function it is still written to the temp directory of a remote
default-directory, where the shell reads it.

With the function set, a terminal needs no live process for either
entry point: the client decides what to do with the files.
@dakra
dakra force-pushed the feat/send-files-function branch from 62dd04a to 3f3631e Compare November 6, 2026 22:08
@dakra
dakra merged commit 3f3631e into main Nov 6, 2026
59 of 60 checks passed
@dakra
dakra deleted the feat/send-files-function branch November 6, 2026 22:43

This branch was previously deployed

1 inactive deployment
github-pages — 3f3631e8 Deployed Nov 6, 2026 by dakra via deploy #254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant