Skip to content

Instantly share code, notes, and snippets.

@nicferrier
Created November 3, 2011 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicferrier/1335894 to your computer and use it in GitHub Desktop.
Save nicferrier/1335894 to your computer and use it in GitHub Desktop.
pinboard doodling for emacslisp using url-retrieve
(defun pinboard-get ()
"A little function to retrieve pinboard.in into a buffer.
The buffer is *pinboard*. We don't even switch to it."
(interactive)
(url-retrieve
"https://api.pinboard.in/v1/posts/all/?format=json"
(lambda (status &rest args)
(save-excursion
(re-search-forward "^$" nil 't)
(let ((json-array-type 'list))
(let ((bookmarks (json-read)))
(with-current-buffer (get-buffer-create "*pinboard*")
(erase-buffer)
(flet ((alist-sort-pred
(a b)
(string-lessp (symbol-name (car a))
(symbol-name (car b)))))
(loop for bm in (copy-tree bookmarks)
do
(loop for item in (sort bm 'alist-sort-pred)
do
(insert (format "%s: %s\n"
(car item)
(let ((s (cdr item)))
(string-match "[ \t]*\\(.*?\\)[ \t]*$" s)
(match-string 1 s)))))
(insert "\n"))))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment