this post was submitted on 24 Oct 2023
1 points (100.0% liked)

Emacs

305 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

In Emacs' Dired, You could conveniently move files from outside into Emacs by simply dragging them there.

Drag files in dired

That is effective.

Emacs has been my faithful companion for over 5 years, and I just stumbled upon this remarkable feature minutes ago.

Typically, I rely on async-shell-commands to open the current buffer directory in Windows 10's File Manager, then move files from folder to folder.

But, now, this seeming-trival discovery has greatly enhanced my workflow, instill in me a strong sence that Emacs not only coexists within the operating system, but rather embodies the operating system itself.

While it is true that Windows does not support dragging files to external locations, I seldom encounter such a requirement in my day-to-day workflows.

Have you ever had such an experience? Discovered an amazing feature after a long time using Emacs?

top 17 comments
sorted by: hot top controversial new old
[–] mickeyp@alien.top 1 points 11 months ago

You can drag files into many different places and have the drop action do different things. The compose email interface will automatically attach the dragged files as attachments.

Another minor point: if you use VMWare workstation as I do, you can drag files from the host straight into an Emacs buffer. I'm sure this also works for other hypervisors like Virtualbox.

[–] uniteduniverse@alien.top 1 points 11 months ago

Is this only in Emacs 29 or have I really never known this existed for this long???

[–] whudwl@alien.top 1 points 11 months ago

I think everyone has had that kind of experience :)

[–] Zwzhhh@alien.top 1 points 11 months ago (3 children)

Set `dired-mouse-drag-files` to t, and you can also drag file from dired to other programs!

[–] AbstProcDo@alien.top 1 points 11 months ago (1 children)

Yes, it not support Windows temporarily:

This feature is supported only on X Windows, Haiku, and Nextstep (macOS or GNUstep

That does not matter at all, I rarely have such a requirement to move file out from emacs, since it could easily move around within Emacs.

[–] github-alphapapa@alien.top 1 points 11 months ago (1 children)

This feature is supported only on X Windows

Friendly correction: It's called the X Window System, X11, or simply X (Xorg now being the standard implementation of it). I tell you this only because if you call it "X Windows" it sounds like you don't know better. :)

[–] AbstProcDo@alien.top 1 points 11 months ago

Yes, I understand it better now.

[–] Thaodan@alien.top 1 points 11 months ago (1 children)

Doesn't seem to work with PGTK for me.

[–] AbstProcDo@alien.top 1 points 11 months ago

PGTK

thank you, I will try it.

[–] mumbo1134@alien.top 1 points 11 months ago

if i have two dired splits, can i drag a file from one to the other this way?

[–] bravosierrasierra@alien.top 1 points 11 months ago

wow! thank you for that cool feature :) 8 years with Emacs and dont know about it :)

[–] jsled@alien.top 1 points 11 months ago

instill in me a strong sence that Emacs not only coexists within the operating system, but rather embodies the operating system itself.

It just implements being a drag-and-drop target; it does not "coexist within the operating system"

While it is true that Windows does not support dragging files from dired buffer to external locations, but I seldom encounter such a requirement in my day-to-day workflows.

~~Windows folders support being a drop-target; this is likely emacs not supporting /its/ side of the protocol.~~

Ah, I see the dired-mouse-drag-files note, below.

[–] VirginiaSteaks@alien.top 1 points 11 months ago (1 children)

Still an absolute beginner but was hyped yesterday when I used "SPC m e l o" in Doom Emacs to export an Org file to PDF and opened it in an Emacs buffer and the PDF file looked amazing right off the bat. This moment was so awesome! How can it just work so smoothly? Already fell in love with this OS ;)

[–] AbstProcDo@alien.top 1 points 11 months ago

agreed, this OS is amazing.

[–] gruzel@alien.top 1 points 10 months ago (1 children)

The dragging also works here on windows with emacs 27.1 where tramp default method is set to plink (with putty's plink.exe in windows executable path

[–] AbstProcDo@alien.top 1 points 10 months ago

Thank you for the information provided. This confirms that it is indeed not a new feature of version 29.

[–] desquared@alien.top 1 points 10 months ago

The mouse does seem to work in dired, it's just that it does emacs things, not OS things. :)

For example, on Windows, I can drag a file from the Windows Explorer and drop it into dired and it copies the file -- as OP observed. (Thanks for that, it's nice!)

But for the reverse, if I click on a file in dired and drag, it highlights a region, because click-and-drag in emacs does that. Likewise left-clicking on a file opens the file...in emacs, because that's what hitting RET would do when point is on the same line.

(There is a nice right-click context menu in dired, but it doesn't include anything for browse-url-of-dired-file -- bound to W -- which for the most part opens a file using the default Windows application.)