From: Oleh <ohwoeowho@gmail.com>
To: Myles English <mylesenglish@gmail.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: capture, attach, link files from web
Date: Mon, 7 Oct 2013 15:08:50 +0200 [thread overview]
Message-ID: <CAA01p3rTThk0EoLDcTV_egME0eh5ZRWs2f6hUx1rPF0Kx-smPg@mail.gmail.com> (raw)
In-Reply-To: <87wqlpuwpl.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3055 bytes --]
Hi Myles,
I counter your tip with my own on capturing pdfs.
Maybe you'll find some of this stuff useful for your case.
My capture template captures a pdf file that I have to read.
It works for:
1. A pdf file in doc-view mode.
2. Any dired buffer with point on a pdf file.
What it does:
1. Create a new TODO item under gtd.org/Projects/Scientific Articles
2. The item title is "Read blah-blah by Foo", if the pdf name has
proper format, otherwise it's just "Read blah-blah".
3. The pdf is attached to the TODO item.
4. A note is added with the capture time.
Here's the code:
(setq org.d "~/Dropbox/org/")
(require 'org-attach)
(require 'org-capture)
(defun org-process-current-pdf ()
(let* ((buffer (org-capture-get :buffer))
(buffer-mode (with-current-buffer buffer major-mode))
(filename (org-capture-get :original-file)))
(when (file-directory-p filename)
(with-current-buffer (org-capture-get :original-buffer)
(setq filename (dired-get-filename))))
(when (string= (file-name-extension filename) "pdf")
(let ((org-attach-directory (concat org.d "data/"))
(name (file-name-sans-extension
(file-name-nondirectory filename))))
(org-attach-attach filename nil 'cp)
(if (string-match "\\[\\(.*\\)\\] \\(.*\\)(\\(.*\\))" name)
(format "\"%s\" by %s"
(match-string 2 name)
(match-string 1 name))
name)))))
(add-to-list 'org-capture-templates
'("p" "Pdf article" entry (file+olp (concat org.d "gtd.org")
"Projects" "Scientific Articles")
"* TODO Read %(org-process-current-pdf)\nAdded: %U %i\n
%?\n"))
regards,
Oleh
On Mon, Oct 7, 2013 at 1:49 PM, Myles English <mylesenglish@gmail.com>wrote:
>
> 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
>
>
[-- Attachment #2: Type: text/html, Size: 4571 bytes --]
next prev parent reply other threads:[~2013-10-07 13:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-07 11:49 capture, attach, link files from web Myles English
2013-10-07 13:08 ` Oleh [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAA01p3rTThk0EoLDcTV_egME0eh5ZRWs2f6hUx1rPF0Kx-smPg@mail.gmail.com \
--to=ohwoeowho@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=mylesenglish@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).