A quick hack to bookmark a list of 50 pages using del.icio.us and Emacs.
Tonight I found 50 links that I wanted to add to my del.icio.us account. They are from a site that has
a series of articles comprising 50 "Writing Tools". I like to read this kind of
thing, because it's kind of my trade, at least educationally speaking. I like
to see how other people do it, and also see how other people teach it.
I went through the trouble of writing the delicious-el code for Emacs
partially so I could handle situations like this easily. I'm currently working
on some code to enable offline caching of posts which can then be batched and
uploaded to the server later, for those times when I'm reading email offline
and come across a link that I want to bookmark. That work will be helpful in
situations like this as well, because the batch uploading function will work by
taking a list of posts and related information.
But, that code's not done yet, and this situation was extra-easy, because I
wanted to give all of these posts the exact same two tags. So I didn't even
bother to write a function, just dumped the following in my *scratch* buffer
and evaluated it.
(mapcar '(lambda (post)
(let ((url (elt post 0))
(description (elt post 1))
(tags "to-read writing"))
(delicious-api-post url description tags)
(message "%s posted." description))
This posted everything in the list
feed-me. I set up that list
with something like:
(setq feed-me '(("first url" "first description")("second url" "second
The need to assemble that list is the reason why it's great to do these
things in Emacs rather than the web browser. I just opened w3m, loaded the
source for the page with the list of links to all 50 tools, and used a series
query-replace-regexp commands to whittle the HTML down to the
above list format. All in the *scratch* buffer.
Note the inclusion of the
(sleep-for 3). This is to avoid
hitting the server too hard. I started off with 2 seconds, but ended up with an
error from the server anyway --- luckily I had included the
(message) line so I could check the *Messages* buffer and see what
the last successful post was, trim the list accordingly, and start again.
All in all, I think I wrote the hack, posted the links, and wrote
this post in the amount of time it would have taken me to post all those links
by hand via the web interface. Next time it will be faster --- and I probably
won't bother you about it. I probably also could have done this by bookmarking
everything in w3m and then exporting the bookmarks via the w3m functions in the
same delicious-el codebase.
You can get the delicious-el code via darcs at
http://www.wjsullivan.net/darcs/delicious-el , or get the tar
archive. It's still developing, and I'm an amateur -- be careful, and send
me your bugs.