My notes had two image piles: org-download threw everything into one folder, and org-attach had files called
WechatIMG7604.jpg or some 64-char hash. Every time I added a file I had to think about where it should go. Got tired of it.Now anything that enters an Org buffer becomes an attachment of the current heading and gets a link inserted. The nice part is how little it took, because everything already ends up in
org-attach-attach:(setq org-yank-dnd-method 'attach
org-yank-image-save-method 'attach
org-download-method 'attach)
Then one
:around advice on org-attach-attach does the rest:junk names (hashes, `IMG_1234`, `Screenshot…`) become `20261010-083713-heading-title.png`; names that already mean something are left alone
files are moved instead of copied, so
~/Downloads doesn't fill up with leftoverss-v pastes an image as an attachment if the clipboard has one, otherwise it's a normal yank. This was the annoying bit. "Clipboard has an image" isn't enough: browsers put the URL next to the image, and spreadsheets put a rendered picture next to the cells you copied. I ended up with "image + a single line that looks like a URL or image filename = image, anything else = text". Works for the apps I use, probably not for all of them.There's also a transient on
C-c C-a (attach newest download, rename and fix the links, Quick Look, reveal in Finder).Full file: https://gist.github.com/yibie/9bd280522c24eec41ce0b32b327967cd
Caveats: the clipboard part is macOS only (needs
pngpaste), and since it moves files, don't point it at a folder you want to keep intact.How do you all tell "image" from "text" on paste? Curious if there's a better rule.
https://redd.it/1x4kb1e
@r_emacs