Created
November 3, 2011 06:16
-
-
Save nicferrier/1335894 to your computer and use it in GitHub Desktop.
pinboard doodling for emacslisp using url-retrieve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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