7.7 KiB
7.7 KiB
title | author | date | wordtwit_post_info | categories | ||
---|---|---|---|---|---|---|
グルメサイトを横断検索した結果を anything のソースにする | kazu634 | 2009-11-18 |
|
|
上記のスクリプトの結果を取り込んで、はてなダイアリー記法で店舗紹介テーブルを作成するソースを作成しました。
「M-x anything-gourmet」で電話番号の入力を促します。
入力された電話番号でスクリプトをキックし、出力された結果を anything のソースとします。
ソース
(defvar anything-c-source-gourmet-work "0") (defun anything_gourmet (tel) (interactive "sTelephone Number: ") (if (string-match "[0-9]+-[0-9]+-[0-9]+" tel) (progn (setq anything-c-source-gourmet-work tel) (anything 'anything-c-source-gourmet nil "Title: " nil nil anything-call-source-buffer)) (message "Please enter Telephone Number!"))) (defvar anything-c-source-gourmet '((name . "Cross-Gourmet Site Search") (candidates . (lambda () (delete "" (split-string (shell-command-to-string (format "gourmet %s" anything-c-source-gourmet-work)) "\n")))) (candidate-transformer . (lambda (candidates) (mapcar (function (lambda(arg) (let* ((str_list (split-string arg "\t")) (site (nth 0 str_list)) (shopname (nth 1 str_list))) (cons (format "[%s] %s" site shopname) arg)))) candidates))) (action . (("Insert" . insert_gourmet))) (migemo))) (defun insert_gourmet (candidate) (let* ((str-list (split-string candidate "\t")) (site (nth str-list)) (shopname (nth 1 str-list)) (address (nth 2 str-list)) (url (nth 3 str-list)) (tel (nth 4 str-list))) (insert (format "|*店名|[%s:title=%s]|\n" url shopname)) (insert (format "|*住所|%s|\n" address)) (insert (format "|*電話番号|%s|\n" tel))))