this post was submitted on 18 Oct 2023
2 points (100.0% liked)

Emacs

311 readers
3 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
 

Hello,

Anyone aware of any package/code snipped that could replicate the paste behavior of vs code? To elaborate what I mean by that. When I copy image in file manager and paste it in a markdown file in vscode it automatically converts it into relative path from the current file. Alternatively is there a way to auto complete in the `C-c C-i` mini buffer?

top 6 comments
sorted by: hot top controversial new old
[–] [email protected] 1 points 1 year ago (1 children)

I guess you want to write a custom interprogram-paste-function which checks to see if the value is a valid filename and, if so, establishes it relative to default-directory in the current buffer.

(Sounds like freakish behaviour to me, but maybe that's just me.)

[–] [email protected] 1 points 1 year ago

Thank you appreciate it

[–] [email protected] 1 points 1 year ago

You can use yank-media to do whatever you want with non-text selections in your clipboard. You can find an example of a function that attaches files copied using a file manager to an org file in this patch: https://yhetil.org/orgmode/[email protected]/

HTH.

[–] [email protected] 1 points 1 year ago

There's a thing called org-download that does a similar thing but I don't know how trustworthy it is.

[–] [email protected] 1 points 1 year ago (1 children)

The latest version of markdown-mode already support media handler for images and drag and drop images.

https://github.com/jrblevin/markdown-mode/commit/e10e5af

You need to to update to Emacs 29.1 or later version to use this new feature.

And the org-mode support will also coming soon.

https://list.orgmode.org/[email protected]/T/#m3c072c13b245eedd20241a84e7ee2efbde8dd88a

[–] [email protected] 1 points 1 year ago

Note that if you want to copy (image path or image contents) and paste, you need to use yank-media on the emacs side, otherwise it just pastes the latest copied text.

(But drag and drop will just do what you mean.)