You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some terminals allow you to drag and drop files from the Finder/Nautilus/etc. and the path name will be inserted into the terminal window. If you do this in Emacs (GUI), the file is opened instead.
To overcome this problem, I wrote this function to insert an escaped path name into Emacs when vterm-mode is in use:
(defun rpaulo-dnd-handle-one-url (orig-fun &rest args)
"Overrides dnd-handle-one-url in vterm-mode so that when
dragging and dropping a file to vterm the entire shell escaped
path name is inserted instead."
(if (string= major-mode "vterm-mode")
(let ((window (nth 0 args))
(action (nth 1 args))
(text (nth 2 args)))
(if (string-match "^file:" text)
(let ((filename (substring text 5)))
(dnd-insert-text window action (shell-quote-argument filename))
(vterm-yank))
(dnd-insert-text window action text)
(vterm-yank)))
(apply orig-fun args)))
(advice-add 'dnd-handle-one-url :around #'rpaulo-dnd-handle-one-url)
I think it may be useful for vterm to have an option that implements this functionality. If you don't agree, feel free to close.
P.S.: This proof of concept elisp code doesn't work on Windows and in some operating systems it adds a couple of extra forward slashes in the beginning (but these cause no problems whatsover).
The text was updated successfully, but these errors were encountered:
Some terminals allow you to drag and drop files from the Finder/Nautilus/etc. and the path name will be inserted into the terminal window. If you do this in Emacs (GUI), the file is opened instead.
To overcome this problem, I wrote this function to insert an escaped path name into Emacs when vterm-mode is in use:
I think it may be useful for vterm to have an option that implements this functionality. If you don't agree, feel free to close.
P.S.: This proof of concept elisp code doesn't work on Windows and in some operating systems it adds a couple of extra forward slashes in the beginning (but these cause no problems whatsover).
The text was updated successfully, but these errors were encountered: