93 lines
7.7 KiB
Markdown
93 lines
7.7 KiB
Markdown
---
|
|
title: グルメサイトを横断検索した結果を anything のソースにする
|
|
author: kazu634
|
|
date: 2009-11-18
|
|
url: /2009/11/18/_1396/
|
|
wordtwit_post_info:
|
|
- 'O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:4933;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}'
|
|
categories:
|
|
- Emacs
|
|
|
|
---
|
|
<div class="section">
|
|
<p>
|
|
<a href="http://d.hatena.ne.jp/sirocco634/20091118#1258549834" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://d.hatena.ne.jp/sirocco634/20091118#1258549834', '上記のスクリプト');" target="_blank">上記のスクリプト</a>の結果を取り込んで、はてなダイアリー記法で店舗紹介テーブルを作成するソースを作成しました。
|
|
</p>
|
|
|
|
<p>
|
|
「M-x anything-gourmet」で電話番号の入力を促します。
|
|
</p>
|
|
|
|
<p>
|
|
<center>
|
|
</center>
|
|
</p>
|
|
|
|
<p>
|
|
<a href="http://flickr.com/photos/42332031@N02/4114969084/" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://flickr.com/photos/42332031@N02/4114969084/', '');" title="電話番号の入力を求める"><img src="http://farm3.static.flickr.com/2781/4114969084_3059f08baa.jpg" /></a>
|
|
</p></p>
|
|
|
|
<p>
|
|
入力された電話番号でスクリプトをキックし、出力された結果を anything のソースとします。
|
|
</p>
|
|
|
|
<p>
|
|
<center>
|
|
</center>
|
|
</p>
|
|
|
|
<p>
|
|
<a href="http://flickr.com/photos/42332031@N02/4114199813/" onclick="__gaTracker('send', 'event', 'outbound-article', 'http://flickr.com/photos/42332031@N02/4114199813/', '');" title="anything上の見え方"><img src="http://farm3.static.flickr.com/2611/4114199813_2bdbd10425.jpg" /></a>
|
|
</p></p>
|
|
|
|
<h4>
|
|
ソース
|
|
</h4>
|
|
|
|
<pre class="syntax-highlight">
|
|
<span class="synSpecial">(</span><span class="synStatement">defvar</span> anything-c-source-gourmet-work <span class="synConstant">"0"</span><span class="synSpecial">)</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">defun</span> anything_gourmet <span class="synSpecial">(</span>tel<span class="synSpecial">)</span>
|
|
<span class="synSpecial">(</span>interactive <span class="synConstant">"sTelephone Number: "</span><span class="synSpecial">)</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">if</span> <span class="synSpecial">(</span>string-match <span class="synConstant">"[0-9]+-[0-9]+-[0-9]+"</span> tel<span class="synSpecial">)</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">progn</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">setq</span> anything-c-source-gourmet-work tel<span class="synSpecial">)</span>
|
|
<span class="synSpecial">(</span>anything <span class="synSpecial">'</span><span class="synIdentifier">anything-c-source-gourmet</span>
|
|
<span class="synStatement">nil</span>
|
|
<span class="synConstant">"Title: "</span>
|
|
<span class="synStatement">nil</span>
|
|
<span class="synStatement">nil</span>
|
|
anything-call-source-buffer<span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>message <span class="synConstant">"Please enter Telephone Number!"</span><span class="synSpecial">)))</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">defvar</span> anything-c-source-gourmet
|
|
<span class="synSpecial">'((</span>name . <span class="synConstant">"Cross-Gourmet Site Search"</span><span class="synSpecial">)</span>
|
|
<span class="synSpecial">(</span>candidates . <span class="synSpecial">(</span><span class="synStatement">lambda</span> <span class="synSpecial">()</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">delete</span> <span class="synConstant">""</span>
|
|
<span class="synSpecial">(</span>split-string
|
|
<span class="synSpecial">(</span>shell-command-to-string
|
|
<span class="synSpecial">(</span><span class="synStatement">format</span> <span class="synConstant">"gourmet %s"</span>
|
|
anything-c-source-gourmet-work<span class="synSpecial">))</span>
|
|
<span class="synConstant">"\n"</span><span class="synSpecial">))))</span>
|
|
<span class="synSpecial">(</span>candidate-transformer . <span class="synSpecial">(</span><span class="synStatement">lambda</span> <span class="synSpecial">(</span>candidates<span class="synSpecial">)</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">mapcar</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">function</span> <span class="synSpecial">(</span><span class="synStatement">lambda</span><span class="synSpecial">(</span>arg<span class="synSpecial">)</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">let*</span>
|
|
<span class="synSpecial">((</span>str_list <span class="synSpecial">(</span>split-string arg <span class="synConstant">"\t"</span><span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>site <span class="synSpecial">(</span><span class="synStatement">nth</span> 0 str_list<span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>shopname <span class="synSpecial">(</span><span class="synStatement">nth</span> 1 str_list<span class="synSpecial">)))</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">cons</span> <span class="synSpecial">(</span><span class="synStatement">format</span> <span class="synConstant">"[%s] %s"</span> site shopname<span class="synSpecial">)</span> arg<span class="synSpecial">))))</span>
|
|
candidates<span class="synSpecial">)))</span>
|
|
<span class="synSpecial">(</span>action . <span class="synSpecial">((</span><span class="synConstant">"Insert"</span> . insert_gourmet<span class="synSpecial">)))</span>
|
|
<span class="synSpecial">(</span>migemo<span class="synSpecial">)))</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">defun</span> insert_gourmet <span class="synSpecial">(</span>candidate<span class="synSpecial">)</span>
|
|
<span class="synSpecial">(</span><span class="synStatement">let*</span>
|
|
<span class="synSpecial">((</span>str-list <span class="synSpecial">(</span>split-string candidate <span class="synConstant">"\t"</span><span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>site <span class="synSpecial">(</span><span class="synStatement">nth</span> <span class="synConstant"></span> str-list<span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>shopname <span class="synSpecial">(</span><span class="synStatement">nth</span> <span class="synConstant">1</span> str-list<span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>address <span class="synSpecial">(</span><span class="synStatement">nth</span> <span class="synConstant">2</span> str-list<span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>url <span class="synSpecial">(</span><span class="synStatement">nth</span> <span class="synConstant">3</span> str-list<span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>tel <span class="synSpecial">(</span><span class="synStatement">nth</span> <span class="synConstant">4</span> str-list<span class="synSpecial">)))</span>
|
|
<span class="synSpecial">(</span>insert <span class="synSpecial">(</span><span class="synStatement">format</span> <span class="synConstant">"|*店名|[%s:title=%s]|\n"</span> url shopname<span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>insert <span class="synSpecial">(</span><span class="synStatement">format</span> <span class="synConstant">"|*住所|%s|\n"</span> address<span class="synSpecial">))</span>
|
|
<span class="synSpecial">(</span>insert <span class="synSpecial">(</span><span class="synStatement">format</span> <span class="synConstant">"|*電話番号|%s|\n"</span> tel<span class="synSpecial">))))</span>
|
|
</pre>
|
|
</div> |