Hi Carsten, You can commit it whenever you like. I don't currently have access to Windows or OSX, so it's hard to see if the code works everywhere. regards, Oleh On Fri, Oct 18, 2013 at 11:28 AM, Carsten Dominik wrote: > Hi Oleh, > > this is very nice thank you. > > If you want, turn this into a patch to org.el. If not, I will do so later. > > - Carsten > > On Oct 18, 2013, at 11:24 AM, Oleh wrote: > > > Hi Carsten, > > > > The dependencies are async, dnd and wget. > > > > In case dnd doesn't work, there's a fallback to clipboard via > > `current-kill'. > > > > I've just added a custom variable that takes either 'wget or 'curl as > > the download method. > > > > I tried before url-retrieve, but it was giving me some garbage in > > addition to the image. So unless I know reliably the format of the > > garbage I can't use url-retrieve. But if I figure it out, I could add > > url-retrieve as the third custom method. > > > > The updates are at https://github.com/abo-abo/org-download > > > > regards, > > Oleh > > > > > > > > On Thu, Oct 17, 2013 at 2:04 PM, Carsten Dominik < > drostekirsten@gmail.com> wrote: > > Hi Oleh and others, > > > > does anyone know how general this code is? Does it works on different > operating systems? > > We might want to include this into the Org core. > > > > - Carsten > > > > On Oct 16, 2013, at 12:04 PM, Oleh wrote: > > > > > Hi all, > > > > > > Here's a little hack that I use to make my life easier: > > > > > > (require 'async) > > > (eval-when-compile > > > (require 'cl)) > > > (defun org-store-image (link basedir) > > > (async-start > > > `(lambda() (shell-command > > > ,(format "wget \"%s\" -P \"%s\"" > > > link > > > (expand-file-name basedir)))) > > > (lexical-let ((cur-buf (current-buffer))) > > > (lambda(x) > > > (with-current-buffer cur-buf > > > (org-display-inline-images)))))) > > > > > > (defun org-store-image-clipboard (link) > > > "Save image at address LINK to current directory's subdirectory DIR. > > > DIR is the name of the current level 0 heading." > > > (interactive (list (current-kill 0))) > > > (let ((filename (car (last (split-string link "/")))) > > > (dir (save-excursion > > > (org-up-heading-all (1- (org-current-level))) > > > (substring-no-properties > > > (org-get-heading))))) > > > (if (null (image-type-from-file-name filename)) > > > (message "not an image URL") > > > (unless (file-exists-p (expand-file-name filename dir)) > > > (org-store-image link dir)) > > > (insert (format "[[./%s/%s]]" dir filename)) > > > (org-display-inline-images)))) > > > > > > (setcdr (assoc "^\\(https?\\|ftp\\|file\\|nfs\\)://" > dnd-protocol-alist) 'dnd-org-insert) > > > > > > (defun dnd-org-insert (uri action) > > > (org-store-image-clipboard uri)) > > > > > > When it's a plain image, I can just drag it from the browser to > org-mode. > > > It will be downloaded in async to a subdirectory of the current > directory and the link will be inserted > > > at point. > > > For stubborn images that are links I can right click to copy image > location and call > > > `org-store-image-clipboard' interactively. > > > > > > I hope it's useful to someone and that I'm not re-implementing > standard functionality. > > > > > > regards, > > > Oleh > > > > > > regards, > > > Oleh > > > > > >