Created
November 29, 2010 15:17
-
-
Save youz/720064 to your computer and use it in GitHub Desktop.
anything-sources for MOS BURGER #xyzzy
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
;;; -*- mode:lisp; package:mosburger -*- | |
;;; 元ネタ http://mattn.kaoriya.net/software/vim/20101117005222.htm | |
(require "dom") ; https://gist.github.com/705102 | |
(defpackage mosburger | |
(:use :lisp :editor)) | |
(in-package "mosburger") | |
(defvar *mos-menu* nil) | |
(defun load-mos-menu () | |
(unless *mos-menu* | |
(setq *mos-menu* (make-hash-table :test 'equal)) | |
(let* ((html (dom:get-doc-from-url "http://www.mos.co.jp/menu/all/")) | |
(elms (dom:find-node-by-class html "^heightLine-1")) | |
menu) | |
(dolist (e elms) | |
(let ((name (and (string-match "/\\([^/]+\\)/$" (dom:attr e :href)) (match-string 1))) | |
(url (format nil "http://www.mos.co.jp~A" (dom:attr e :href))) | |
(desc (dom:attr e :title))) | |
(push name menu) | |
(setf (gethash name *mos-menu*) (list url desc)))) | |
(setf (gethash "_index_" *mos-menu*) (sort menu #'string<)))) | |
(gethash "_index_" *mos-menu*)) | |
(defun open-mos-menu (name) | |
(dom::whenlet menu (gethash name *mos-menu*) | |
(shell-execute (car menu) t))) | |
(require "anything/anything") | |
(user::add-anything-sources | |
:name "MOS BURGER" | |
:type url | |
:candidates load-mos-menu | |
:action open-mos-menu | |
:move-action (lambda (name) | |
(dom::whenlet menu (gethash name *mos-menu*) | |
(popup-string (cadr menu) (point))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment