public
Last active

pinboard.in is an awesome bookmarking service... this here is some EmacsLisp to pull the most recent bookmarks I have made (though it's easy to switch it to you) and present it as creole text. It relies on 2 other packages: creole-mode, web -- both can be found on http://marmalade-repo.org

  • Download Gist
pinboard.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
;;; pinboard.el --- get stuff from pinboard -*- lexical-binding: t -*-
 
;; Copyright (C) 2013 Nic Ferrier
 
;; Author: Nic Ferrier <nferrier@ferrier.me.uk>
;; Keywords: multimedia
;; Created: 10th March 2013
;; Version: 0.0.1
;; Created: 10th March 2013
;; Url: https://gist.github.com/nicferrier/5043465
 
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
 
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
 
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
 
;;; Commentary:
 
;; http://pinboard.in is an awesome tool for bookmarking with lots of
;; extensions. This Emacs extension let's you pull the data into a
;; creole-mode file presented in a creole like way.
 
;; I use it for making quick blog posts of stuff I've pinboarded.
 
;; I expect there are other uses that I'll add.
 
;;; Code:
 
(require 'web)
(require 'json)
(require 'creole-mode)
 
(defgroup pinboard nil
"Pull data from pinboard.in."
:group 'applications)
 
(defcustom pinboard-url
(format "http://feeds.pinboard.in/json/u:%s/?count=10" user-login-name)
"Your pinboard.in user, by default it's Emacs `user-login-name'."
:group 'pinboard)
 
(defun pinboard/data (data)
"The data is a vector of alists."
(with-current-buffer (get-buffer-create "*pinboard-latest*")
(let ((buffer-read-only nil))
(erase-buffer)
(loop for al across data
do
(progn
(setf (car (assoc 't al)) 'tags)
(destructuring-bind (&key tags a dt n d u)
(kvalist->plist al)
(insert
(format "=== %s ===
[[%s|%s]]
//%s//
%s
%s\n\n" n u n dt d (mapconcat 'identity tags "|"))))))
(creole-mode)
(visual-line-mode)
(goto-char (point-min))
(view-mode)
(switch-to-buffer (current-buffer)))))
 
;;;###autoload
(defun pinboard-latest ()
(interactive)
(let ((buf (get-buffer-create "*pinboard-data*")))
(with-current-buffer buf (erase-buffer))
(web-http-get
(lambda (htp headers data)
(let ((jsdata
(with-current-buffer buf
(goto-char (point-max))
(insert data)
(goto-char (point-min))
(json-read))))
(pinboard/data jsdata)))
:url pinboard-url)))
 
(provide 'pinboard)
 
;;; pinboard.el ends here

get stuff from pinboard, turn it into creole.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.