emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* capture, attach, link files from web
@ 2013-10-07 11:49 Myles English
  2013-10-07 13:08 ` Oleh
  2013-10-07 15:55 ` Eric Abrahamsen
  0 siblings, 2 replies; 9+ messages in thread
From: Myles English @ 2013-10-07 11:49 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


Hello,

Just thought I would share something I find useful.  What the code below
does is:

1) prompts for a link to a file on the internet
2) downloads the file
3) attaches the file to the current subtree
4) inserts at the current point a link to the attachment

This is useful if (e.g.) you are scouring Google images for ideas and
want to save lots of image files.

Requirements: wget, set $TMPDIR.
TODO: integrate properly with capture template

#+here_is_some elisp
(setq org-link-abbrev-alist '(("att" . org-attach-expand-link)))

(defun my-attach-and-link-web-file (lnk)
  "Download a file, attach it to our heading, insert a link"
  (interactive "*sAttach and link to url: \n")
  (let ((tmpdir (expand-file-name (getenv "TMPDIR")))
	(fname (file-name-nondirectory lnk)))
    (progn (message (concat "Downloading " lnk " to " tmpdir "/" fname))
	   (call-process "wget" nil '("*Messages*" t) nil "-P"
			 tmpdir "-d"
			 lnk)
	   (org-attach-attach (concat tmpdir "/" fname) nil 'mv)
	   (insert (concat "[[att:" fname "]]")))))

(define-key global-map "\C-cs" 'my-attach-and-link-web-file)
#+that_was_elisp

Myles

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-10-08 15:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-07 11:49 capture, attach, link files from web Myles English
2013-10-07 13:08 ` Oleh
2013-10-08 10:43   ` Myles English
2013-10-08 15:28     ` Oleh
2013-10-07 15:55 ` Eric Abrahamsen
2013-10-07 17:49   ` Myles English
2013-10-08  1:39     ` Eric Abrahamsen
2013-10-08 10:22       ` Myles English
2013-10-08 13:31         ` Eric Abrahamsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).