<?xml version="1.0" encoding="UTF-8" ?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/"
     version="2.0">
  <channel>
  <title>ottt</title>
  <link>http://ottt.x0.com/xyzzy/</link>
  <description>xyzzy の覚え書き</description>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <pubDate>Sun, 27 Jan 2008 15:37:35 +0900</pubDate>
  <lastBuildDate>Sun, 27 Jan 2008 15:37:35 +0900</lastBuildDate>
  <language>ja</language>
    <item>
    <title>anything</title>
    <link>http://ottt.x0.com/xyzzy/anything.html</link>
    <guid>51983a2c-cb01-317b-7fca-83d4e5e32435</guid>
    <description>
複数の機能を一つにまとめてしまう lispemacs の anything とは動作が多分(かなりかも;))違ます。インクリメンタルに候補を絞り、カテゴリで実行したい動作が変わります。色横に表示バッファタブを消すフレーム はいらないanything の開始時と終了時に実行する場合migemo がインストールされていれば絞りこみに migemo を使います。migemo で絞り込む type 数sources を追加していくことで拡張できます。表示するための名前 カテゴリ属性を指定リストを返す関数引数を一つ取る関数初期値移動した時に呼ばれる関数表示したいモード(モード
    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
<div class="cp">
<h2><a name="ANYTHING (for xyzzy)">ANYTHING (for xyzzy)</a></h2>
<div class="cc">
<p>複数の機能を一つにまとめてしまう lisp</p>
<p>emacs の anything とは動作が多分(かなりかも;))違ます。</p>
</div>
<h3><a name="INSTALL">INSTALL</a></h3>
<div class="cc">
<div class="lisp">
<pre>  (require :anything/anything)
  (require :anything/sources)
  (require :anything/menu)</pre>
</div>
<dl>
<dt>anything/sources </dt>
<dd>anything/menu なんて飾りです。</dd>
</dl>
</div>
<h3><a name="UI">UI</a></h3>
<div class="cc">
<pre> M-x anything</pre>
<p>インクリメンタルに候補を絞り、カテゴリで実行したい動作が変わります。</p>
</div>
<h3><a name="KEYMAP">KEYMAP</a></h3>
<div class="cc">
<table>
<tr><td>#\C-p   </td><td>anything-previous-line   </td><td> 次行       </td></tr>
<tr><td>#\C-n   </td><td>anything-next-line       </td><td> 前行       </td></tr>
<tr><td>#\C-v   </td><td>anything-next-source     </td><td> 次のソース </td></tr>
<tr><td>#\M-v   </td><td>anything-previous-source </td><td> 前のソース </td></tr>
<tr><td>#\C-M-n </td><td>anything-next-page       </td><td> 次のページ </td></tr>
<tr><td>#\C-M-p </td><td>anything-previous-page   </td><td> 前のページ </td></tr>
<tr><td>#\C-h   </td><td>anything-backward-char   </td><td> 訂正       </td></tr>
<tr><td>#\C-l   </td><td>anything-recenter        </td><td> 真ん中に   </td></tr>
<tr><td>#\C-g   </td><td>anything-quit            </td><td> 中止       </td></tr>
<tr><td>#\C-i   </td><td>anything-action-tab      </td><td> 属性指定   </td></tr>
<tr><td>#\RET   </td><td>anything-action-return   </td><td> 実行       </td></tr>
<tr><td>#\LFD   </td><td>anything-action-return   </td><td> 実行       </td></tr>
<tr><td>#\C-@   </td><td>anything-set-mark-action </td><td>file に mark をつけて開く</td></tr>
<tr><td>#\C-s   </td><td>anything-isearch-forward </td><td> isearch    </td></tr>
<tr><td>#\C-r   </td><td>anything-isearch-backward</td><td> isearch    </td></tr>
<tr><td>#\C-z   </td><td>anything-upper-directory </td><td>up directory</td></tr>
</table>
</div>
<h3><a name="CUSTUMIZE">CUSTUMIZE</a></h3>
<div class="cc">
</div>
<h4><a name="LOOK">LOOK</a></h4>
<div class="cc">
<p>色</p>
<div class="lisp">
<pre> (setq *anything-select-color*
   '(:foreground 0 :background 14 :bold t))
 (setq *anything-sources-name-color*
   '(:color 0 15 :bold :line))</pre>
</div>
<p>横に表示</p>
<div class="lisp">
<pre> ;; with-output-to-temp-buffer の説明を参考にして下さい
 (setq *anything-buffer-popup* t)
 (setq *anything-buffer-vert* t)</pre>
</div>
<p>バッファタブを消す</p>
<div class="lisp">
<pre> (setq *anything-buffer* &#34; *anything*&#34;)</pre>
</div>
<p>フレーム はいらない</p>
<div class="lisp">
<pre> (setq *anything-use-frame* nil)</pre>
</div>
</div>
<h4><a name="HOOK">HOOK</a></h4>
<div class="cc">
<p>anything の開始時と終了時に実行する場合</p>
<div class="lisp">
<pre> *anything-open-hook*
 *anything-close-hook*</pre>
</div>
</div>
<h4><a name="MIGEMO">MIGEMO</a></h4>
<div class="cc">
<p>migemo がインストールされていれば絞りこみに migemo を使います。</p>
<div class="lisp">
<pre> (setq *anything-migemo-on* t)</pre>
</div>
<p>migemo で絞り込む type 数</p>
<div class="lisp">
<pre> (setq *anything-migemo-length* 4)</pre>
</div>
</div>
<h4><a name="SOURCES">SOURCES</a></h4>
<div class="cc">
<p>sources を追加していくことで拡張できます。</p>
</div>
<h5><a name="add-anything-sources">add-anything-sources</a></h5>
<div class="cc">
<div class="lisp">
<pre> :name string</pre>
</div>
<p>表示するための名前 カテゴリ</p>
<div class="lisp">
<pre> :type attribute</pre>
</div>
<p>属性を指定</p>
<div class="lisp">
<pre> :candidates function</pre>
</div>
<p>リストを返す関数</p>
<div class="lisp">
<pre> :action function arg</pre>
</div>
<p>引数を一つ取る関数</p>
<div class="lisp">
<pre> :init init</pre>
</div>
<p>初期値</p>
<div class="lisp">
<pre> :move-action function</pre>
</div>
<p>移動した時に呼ばれる関数</p>
<div class="lisp">
<pre> :visible-mode buffer-mode , list</pre>
</div>
<p>表示したいモード(モードのリスト)</p>
</div>
<h5><a name="add-anything-attribute">add-anything-attribute</a></h5>
<div class="cc">
<div class="lisp">
<pre> :type source type</pre>
</div>
<p>ソースでしている属性を指定</p>
<div class="lisp">
<pre> :display string</pre>
</div>
<p>表示するための名前</p>
<div class="lisp">
<pre> :action function</pre>
</div>
<p>引数を一つ取る関数</p>
<div class="lisp">
<pre> :default variable</pre>
</div>
<p>RET の場合実行される関数</p>
</div>
<h3><a name="ANOTHER ANYTHING">ANOTHER ANYTHING</a></h3>
<div class="cc">
<p>通常の anything とは別に sources を作り呼び出せます。</p>
</div>
<h4><a name="another-anything">another-anything</a></h4>
<div class="cc">
<div class="lisp">
<pre> name</pre>
</div>
<p>name-anything という関数が生成されます。</p>
<div class="lisp">
<pre> body sources attribute ...</pre>
</div>
<p>name-anything で使う source と attribute </p>
</div>
<h3><a name="ToDo">ToDo</a></h3>
<div class="cc">
<ol>
<li> 括弧好きな人が拡張を公開してくれるのを待つ
<li> multi-line
</li>
<li> process 用の関数の提供
</li>
</li>
</ol>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Wed, 05 Mar 2008 17:20:57 +0900</pubDate>
    </item>
    <item>
    <title>odoc-readme</title>
    <link>http://ottt.x0.com/xyzzy/odoc-readme.html</link>
    <guid>ce85ca98-98a5-732f-7345-13bf7ccb0f52</guid>
    <description>
odoc おれおれドキュメント Publisherテキストを html に置き換える xyzzy lisp です。日付でメモを取っていくと日記ツールにもなるかと思います。site-lisp に odoc 以下を放り込む。.xyzzy siteinit.l に書式は以下ol,ul,table,pre,p,dl,blockquote の書式に従って書いた始めの行に$...$ , %...% を指定しておくと要素を &#60;div&#62; で囲み、囲まれた文字は class と id 名になります。class は $foo$ =&#62; &#60;div class=&#34;foo&#34;&#62; 二行目 ..&#60;/div&#62;id は %bar% =&#62; &#60;div id=&#34;bar&#34;&#62; 二行目 ..&#60;/div&#62;(注) 囲まれた文字以降は無視されます。エスケープは \%~% ,\$~$ です。入れ子にすることはできますが、階層をとばすとタグをきちっと閉じられないバグがあるので気をつけて下さい。publish 用設定ファ
    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
<div class="cp">
<h2><a name="Description">Description</a></h2>
<div class="cc">
<p>odoc おれおれドキュメント Publisher
テキストを html に置き換える xyzzy lisp です。
日付でメモを取っていくと日記ツールにもなるかと思います。</p>
</div>
</div>
<div class="cp">
<h2><a name="Install">Install</a></h2>
<div class="cc">
<p>site-lisp に odoc 以下を放り込む。
.xyzzy siteinit.l に</p>
<div class="lisp">
<pre>  (require &#34;odoc&#34;)</pre>
</div>
</div>
</div>
<div class="cp">
<h2><a name="odoc-mode">odoc-mode</a></h2>
<div class="cc">
<pre> [foo] RET で新しく foo.od を作成します。
 [index] RET で編集中のディレクトリの ~.od を集めてきて表示</pre>
<table>
<tr><td> keybind </td><td> function </td></tr>
<tr><td> C-c p   </td><td> publish  </td></tr>
<tr><td> C-c i   </td><td> index    </td></tr>
<tr><td> RET     </td><td> action   </td></tr>
</table>
</div>
</div>
<div class="cp">
<h2><a name="Format">Format</a></h2>
<div class="cc">
<p>書式は以下</p>
<pre>  ^=..       h
  ^-..       ol (space2 つで入れ子)
  ^*..       ul (space2 つで入れ子)
  ^|..|      table
  ^ ..       pre
  ^..        p  (閉じる時は空行にする)
  ^----      hr
  ^:. :.     dl
  ^&#62;..       blockquote
  http://    absolute link
  [http://..|name] absolute link
  [name]     relative link
  [img|x,y|path|alt]    img link
   \[fug] \http:// はエスケープ</pre>
</div>
<h3><a name="要素 のオプション">要素 のオプション</a></h3>
<div class="cc">
<p>ol,ul,table,pre,p,dl,blockquote の書式に従って書いた始めの行に
$...$ , %...% を指定しておくと要素を &#60;div&#62; で囲み、
囲まれた文字は class と id 名になります。</p>
<p>class は 
$foo$ =&#62; &#60;div class=&#34;foo&#34;&#62; 二行目 ..&#60;/div&#62;</p>
<p>id は 
%bar% =&#62; &#60;div id=&#34;bar&#34;&#62; 二行目 ..&#60;/div&#62;</p>
<p>(注) 囲まれた文字以降は無視されます。エスケープは \%~% ,\$~$ です。</p>
</div>
<h3><a name="list">list</a></h3>
<div class="cc">
<p>入れ子にすることはできますが、階層をとばすとタグをきちっと閉じられない
バグがあるので気をつけて下さい。</p>
</div>
</div>
<div class="cp">
<h2><a name="Config File">Config File</a></h2>
<div class="cc">
<p>publish 用設定ファイル odoc/.odocrc に好みの設定を書く、もしくは編集して
いるディレクトリに .odocrc を作ればそれを読み込みます。</p>
<dl>
<dt>#</dt>
<dd> comment line</dd>
<dt>%site_title</dt>
<dd> Site タイトル名</dd>
<dt>%site_sub</dt>
<dd> Site の簡単な説明</dd>
<dt>%header</dt>
<dd> html の head 内を記述しておく</dd>
<dt>%encode</dt>
<dd> エンコードを xyzzy の定数を使って指定 例 *encoding-utf8n*</dd>
<dt>%footer</dt>
<dd> フッター</dd>
<dt>%date</dt>
<dd>  フッターに表示する日付</dd>
<dt>%macro</dt>
<dd> 置換文字 TAB で区切る</dd>
<dt>%regex</dt>
<dd> 正規表現置換 TAB で区切る</dd>
<dt>%author</dt>
<dd> 著者</dd>
<dt>%host</dt>
<dd> http://ホスト名  (Feed を吐き出す場合に使います)</dd>
<dt>%mail</dt>
<dd> メールアドレス your_address@example.com</dd>
<dt>%menu</dt>
<dd> Publish した HTML に menu{toc,recent,..}</dd>
<dt>%menu plugins</dt>
<dd> menu の recent 以下に追加するもの</dd>
</dl>
<p>が設定できます。</p>
</div>
</div>
<div class="cp">
<h2><a name="UI">UI</a></h2>
<div class="cc">
<ul>
<li> odoc-publish で html index.html recent.html atom rss 作成
<li> odoc-inedx で現在の作業ディレクトリの ~.od を集めて来ます。
</li>
<li> odoc-mode ~.od を色分け
</li>
<li> odoc-config-mode .odocrc を色分け
</li>
</li>
</ul>
</div>
</div>
<div class="cp">
<h2><a name="Customize">Customize</a></h2>
<div class="cc">
<p>publish 後に html+-mode でインデントしてもらう場合
.xyzzy 等に</p>
<div class="lisp">
<pre> (add-hook '*odoc-publish-hook*
          #'(lambda()
              (indent-region(point-min)(point-max))))</pre>
</div>
</div>
<h3><a name="odoc-mode">odoc-mode</a></h3>
<div class="cc">
<p>~/odoc/.odoc-mode の始めに(in-package :odoc-mode)を追加して
lisp を書いていく必要があります。 
add-toggle-switch,add-action,add-action-list</p>
</div>
<h4><a name="toggle switch">toggle switch</a></h4>
<div class="cc">
<p>任意の文字列二文字以上で {*} =&#62; {-} =&#62; { } 等を RET で変更する。
追加したい場合の例</p>
<div class="lisp">
<pre> (add-toggle-switch 
     '((&#34;}?&#34;&#34;}+&#34;&#34;}*&#34;)
      (&#34;[+    ]&#34;&#34;[++   ]&#34;&#34;[+++  ]&#34;&#34;[++++ ]&#34; &#34;[+++++]&#34;)))</pre>
</div>
</div>
<h4><a name="action">action</a></h4>
<div class="cc">
<p>任意の正規表現上で RET すると関数を呼び出して実行します。</p>
<div class="lisp">
<pre> ; 一つずつ追加する場合
 (add-action regex function &#38;optional delete goto)
 ; まとめて追加する場合
 (add-action-list '((regex func)
                    (regex2 func2 1 1)))</pre>
</div>
</div>
</div>
<div class="cp">
<h2><a name="diary">diary</a></h2>
<div class="cc">
<p>日記風につけたい場合は、.xyzzy 等に</p>
<div class="lisp">
<pre> (defun diary()
  (interactive)
  (find-file(merge-pathnames
             (concat (format-date-string &#34;%Y-%m-%d&#34;) &#34;.&#34; *odoc-extension*)
             &#34;~/oDiary&#34;)))
 M-x diary</pre>
</div>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Sun, 27 Jan 2008 20:10:53 +0900</pubDate>
    </item>

    <item>
    <title>Graph</title>
    <link>http://ottt.x0.com/xyzzy/Graph.html</link>
    <guid>0c3e348c-ba0d-ae4b-7274-a4ef1adef1b7</guid>
    <description>
turtle.l で地味にグラフ表示してみる(*scrath* でテスト), spreadsheet-mode で使えると嬉しいかも
    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
<div class="cp">
<h2><a name="graph">graph</a></h2>
<div class="cc">
<p>turtle.l で地味にグラフ表示してみる(*scrath* でテスト), spreadsheet-mode で使えると嬉しいかも</p>
<pre>    (require &#34;wip/turtle&#34;)
    (defun pole-graph(&#38;rest rest)
      (let*((min (apply #'min rest))
            (max (apply #'max rest))
            (total (apply #'+ rest))
            (width win-user::*turtle-window-width*)
            (height win-user::*turtle-window-height*)
            (win-hi (* (-(- min max))))
            (digit(do((x 1 (* x 10)))((&#62;= x win-hi)(/ x 1000))))
            (i 0) (ii ()))
        (setq win-user::*turtle-window-width* (+ 30(* 30 (length rest))))
        (setq win-user::*turtle-window-height* (/ win-hi digit 2)) ;
        (win-user::with-turtle-paint
          (win-user::turtle-right 90)
            (dolist (a rest)
              (setq ii (* 25 (incf i)))
              (dotimes (b (/ (if (plusp a) a (* (- a)))
                             (* digit 10))) ;
                (win-user::turtle-setpos ii (if(plusp a)
                                                (- (/ win-user::*turtle-window-height* 2) b)
                                              (+ (/ win-user::*turtle-window-height* 2) b)))
                (win-user::turtle-lineto 20))
              ))
          (setq win-user::*turtle-window-width* width)
          (setq win-user::*turtle-window-height* height)
    (format t &#34;min:~15T~D~%max:~15T~D~%average:~15T~D~%total:~15T~D~%&#34;
            min max (round (/ total (length rest))) total)
        ))
    (pole-graph 10 20 30 20 50 100 5)
    =&#62;min:           5
    =&#62;max:           100
    =&#62;average:       34
    =&#62;total:         235
    =&#62;nil</pre>
<pre>    (defun circle-graph(&#38;rest rest)
      (let((total (apply #'+ rest))
           (p 360)(x 50)(y 200)
           percent result radius)
        (setq radius (/ p pi));?2
        (dolist (x rest (setq percent (nreverse percent)))
          (push (* (/ x total) p) percent)
          (push (list x (floor (* (/ x total) 100))) result))
        (win-user::with-turtle-paint
          (win-user::turtle-setpos x y)
          ;circle
          (dotimes (a p)
            (win-user::turtle-right 1)
            (win-user::turtle-lineto 2))
          ;base line
          (win-user::turtle-setpos (+ x radius) y)
          (win-user::turtle-lineto radius)
          ;
          (dolist (b percent)
            (win-user::turtle-right b)
            (win-user::turtle-setpos (+ x radius) y)
            (win-user::turtle-lineto radius))
          (format t &#34;~{~{~D~5T:~10T~A%~}~%~}&#34; (nreverse result))
          )))
    (circle-graph 31 3 6 8 9 45 8 32 43 35)
    =&#62;31   :    14%
    =&#62;3    :    1%
    =&#62;6    :    2%
    =&#62;8    :    3%
    =&#62;9    :    4%
    =&#62;45   :    20%
    =&#62;8    :    3%
    =&#62;32   :    14%
    =&#62;43   :    19%
    =&#62;35   :    15%
    =&#62;nil</pre>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Sun, 27 Jan 2008 15:40:02 +0900</pubDate>
    </item>


    <item>
    <title>getelements</title>
    <link>http://ottt.x0.com/xyzzy/getelements.html</link>
    <guid>7142d64b-eb03-25e6-1515-2bf5da3da89a</guid>
    <description>
DOM 全部実装ってのはあんまり意味ないと思ったので get.. だけにしたけど、最低半分は実装しないと使い勝手が悪そうだな~ かといって何か使い道があるかといゆうと疑問使い方はコード
    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
<div class="cp">
<h2><a name="getElementById とか">getElementById とか</a></h2>
<div class="cc">
<p>DOM 全部実装ってのはあんまり意味ないと思ったので get.. だけにしたけど、
最低半分は実装しないと使い勝手が悪そうだな~ かといって何か使い道があるか
といゆうと疑問</p>
<p>使い方は</p>
<div class="lisp">
<pre> (setq g(parse &#34;e:/test/test.html&#34;))
 =&#62; #&#60;hashtable 51908756&#62;
 (value g)
 =&#62; .......
 
 (setq m(get-elements-by-class-name gg &#34;menu&#34;))
 =&#62; #&#60;hashtable 51910572&#62;
 (value m)
 =&#62; .............
 </pre>
</div>
<p>コード</p>
<div class="lisp">
<pre> (defvar *parse-cache* ())
 (defun parse(file)
   (let((i 0)(n -1)(ln)(cache)(hash))
    (if(setq cache(assoc file *parse-cache* :test 'equal))
        (return-from parse (cdr cache)))
    (setq hash (make-hash-table))
    (with-open-file(f file)
      (while(setq ln (read-line f nil nil nil))
        (when ln
          (setq ln (split-string ln #\&#62;))
          (dolist (x ln)
            (if(string-match &#34;&#60;&#34; x)
                (setf(gethash (incf n) hash)(concat x &#34;&#62;&#34;))
              (setf(gethash (incf n) hash) x))))))
    (pushnew  (cons file hash) *parse-cache*
              :test 'equal :key 'cdr)
    hash
    ))
 
 (defun dom-scanner(document regex &#38;optional once)
   (let((i 0)(ct 0)(n -1)(nn -1)(tag)(hash)(rhash))
    (setq hash (make-hash-table))
    (setq rhash (make-hash-table))
    (dotimes (c (hash-table-count document))
      (let((s (gethash c document)))
        (cond
         ((string-match regex s)
          (and (= i 0)
               (setq tag (car(split-string(match-string 2) #\SPC))))
          (setf (gethash (incf n) hash) (match-string 1))
          (setq i 1)
          (cond
           ((string-match (concat &#34;.*&#60;/&#34; tag &#34;&#62;&#34;) s)
            (setq i 0))
           ((string-match (concat &#34;&#60;&#34; tag &#34;.*&#62;&#34;) s)
            (incf ct)))
          )
         ((and(&#60; 0 ct)
              (string-match (concat &#34;\\(.*&#60;/&#34; tag &#34;&#62;\\)&#34;) s))
          (setf (gethash(incf n) hash)(match-string 1))
          (decf ct)
          (if(zerop ct)(setq i 0))
          (when(zerop ct)
            (setf (gethash (incf nn) rhash)hash)
            (setq hash(make-hash-table))
            (setq n -1))
          (if once (return-from dom-scanner rhash))
          )
         ((= i 1)
          (and(string-match(concat &#34;&#60;&#34; tag &#34;.*&#62;&#34;) s)
              (incf ct))
          (setf (gethash (incf n) hash) s)
          )
         (t ()))))
    rhash))
 
 (setq get-tag-regex-list '(&#34;\\(&#60;\\(&#34;
                           &#34;[^&#60;&#62;/]+?&#34;
                           &#34;\\)[^&#60;&#62;]*?&#34;
                           &#34;&#62;.*\\)&#34;))
 
 (defmacro get-document(document &#38;optional once &#38;rest arg)
   `(dom-scanner
    ,document
    (concat (nth 0 get-tag-regex-list)
            (if (&#60; 1 (length(list ,@arg)))
                (nth 1 get-tag-regex-list))
            ,@arg
            (nth 2 get-tag-regex-list)
            (nth 3 get-tag-regex-list)
            )
    ,once
    ))
 
 (defmacro get-value(dom)
   (let((g (gensym)))
    `(let((g))
       (maphash
        #'(lambda(a b)
            (setq g (concat g(string b))))
        (if(hash-table-p(gethash 0 ,dom))
            (gethash 0 ,dom)
          ,dom))
       g)))
 
 ;; ここから使う関数
 (defun get-element-by-id(document id)
   (get-document document t &#34; id=\&#34;&#34; id &#34;\&#34;&#34;))
 
 (defun get-elements-by-name(document id)
   (get-document document t &#34; name=\&#34;&#34; name &#34;\&#34;&#34;))
 
 (defun get-elements-by-tag-name(document tag)
   (get-document document nil tag ))
 
 (defun get-elements-by-class-name(document class)
   (get-document document nil &#34; class=\&#34;&#34; class &#34;\&#34;&#34;))
 
 (defun get-attribute(dom name)
   (string-match(concat &#34;\\([^ ]+?\\)=&#34; name) (gethash 0 dom))
   (match-string 1))
 
 (defun get-attribute-node(dom node)
   (string-match(concat node &#34;= *\&#34;\\([^ ]+?\\)\&#34;&#34;) (gethash 0 dom))
   (match-string 1))
 
 (defun value(dom)
   (get-value dom))
 
 (defun title(dom)
   (get-value (dom-scanner dom &#34;\\(&#60;\\(title\\).*?&#62;\\)&#34; t)))
 </pre>
</div>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Sun, 27 Jan 2008 15:39:42 +0900</pubDate>
    </item>


    <item>
    <title>css-generator</title>
    <link>http://ottt.x0.com/xyzzy/css-generator.html</link>
    <guid>fb7e4c45-25e2-0a90-1093-b641619ea390</guid>
    <description>
HTML を編集しているバッファの HTML を解析して､ CSS を吐き出します。ネストしたやつも多分大丈夫だと思います。CSS のことよく解ってないのでこれでいいのか解りませんが ^^)
    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
<div class="cp">
<h2><a name="CSS Generator">CSS Generator</a></h2>
<div class="cc">
<p>HTML を編集しているバッファの HTML を解析して､ CSS を吐き出します。
ネストしたやつも多分大丈夫だと思います。
CSS のことよく解ってないのでこれでいいのか解りませんが ^^)</p>
<pre>    (defun get-elemement-init(regex)
      (let(result tmp tag p1 p2 st)
        (save-excursion
          (goto-char(point-min))
          (scan-buffer &#34;&#60;body.*&#62;&#34; :regexp t :case-fold t :tail t)
          (while
              (scan-buffer (concat &#34;&#60;\\(&#34;
                                   regex
                                   &#34;[^&#60;&#62;]*?\\)&#62;&#34; )
                           :regexp t :no-dup t)
            (when
                (not(member
                     (car(split-string (match-string 1) #\SPC))
                     ; exclusion
                     '(&#34;head&#34; &#34;title&#34; &#34;area&#34; &#34;hr&#34; &#34;br&#34; &#34;frame&#34; &#34;frameset&#34;
                       &#34;map&#34; &#34;noframes&#34; &#34;noscript&#34; &#34;optgroup&#34; &#34;option&#34; &#34;param&#34;
                       &#34;script&#34; &#34;style&#34; &#34;tbody&#34; &#34;tfoot&#34; &#34;thead&#34;)
                     :test #'(lambda(a b)(string= b a))))
              (setq tag (car(split-string(match-string 1) #\SPC)))
              (message &#34;Study Tag Name: &#60;~A&#62;.&#34;(string-upcase tag))
              (setq tmp nil)
              (push (match-string 0) tmp)
              (setq p1 (point))
              (scan-buffer (concat &#34;&#60;\\(/&#34; tag &#34;\\)&#62;&#34;)
                           :regexp t :no-dup t :tail t)
              (setq p2 (point))
              (goto-char p1)
              ;この処理が重い
              (while(forward-char 1)
                (and(&#60;= p2 (point))(return))
                (if(looking-at &#34;&#60;\\([^\/!&#60;&#62;]+?\\)&#62;&#34;)
                    (push (match-string 0) tmp)))
              (push (remove-duplicates (nreverse tmp) :test 'string-equal) result)
              (goto-char p1))))
        (nreverse result)))
    
    (defun css-generator()
      (interactive)
      (let*((l  (get-elemement-init &#34;[^\/!&#60;&#62;]+&#34;) ))
        (with-output-to-temp-buffer(&#34;CSS&#34;)
          (format t &#34;/*-*- mode:css -*-*/~%~{/* */~%~{~A~^ ~}{~%}~2%~}&#34;
                  (mapcar
                   #'(lambda(b)
                       (mapcar
                        #'(lambda(a)
                            (concat
                             (substitute-string a &#34;^&#60;\\([^ ]+\\).*&#62;&#34; &#34;\\1&#34;)
                             (if (string-matchp  &#34;class&#34; a)
                                 (substitute-string
                                  a &#34;^&#60;.+class *= *\&#34;\\([^ ]+\\)\&#34;.*&#62;&#34; &#34;.\\1&#34;))
                             (if (string-matchp &#34;id&#34; a)
                                 (substitute-string
                                  a &#34;^&#60;.+id *= *\&#34;\\([^ ]+\\)\&#34;.*&#62;&#34; &#34;#\\1&#34;))))
                        b)
                       )
                   (remove-duplicates
                    (append (mapcar #'(lambda(x)(list(car x))) l) l)
                    :test 'equal)
                   )))))</pre>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Sun, 27 Jan 2008 15:39:36 +0900</pubDate>
    </item>


    <item>
    <title>shtml</title>
    <link>http://ottt.x0.com/xyzzy/shtml.html</link>
    <guid>e96f4878-b8c4-cdb7-566e-0f9ae5d2bd7e</guid>
    <description>
(format nil &#34;~A~A&#34; :foo &#34;bar&#34;) こう書けるみたいなので , s式html もどきをでっち上げ(attribute をきっちり html の属性を書いてやれば補完もできるっぽいけど、めんどくさい)文字列が悩む所だけど、インデントで読みやすかったりする気が少しする。自動生成版に変更し多少メンテしやすくした。例えば , こういう s式を *scratch* で評価括弧を減らした。
    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
</div>
</div>
<div class="cp">
<h2><a name="S 式 で html を出力してみる">S 式 で html を出力してみる</a></h2>
<div class="cc">
<p>(format nil &#34;~A~A&#34; :foo &#34;bar&#34;) こう書けるみたいなので , s式html もどきをでっち上げ(attribute をきっちり html の属性を書いてやれば補完もできるっぽいけど、めんどくさい)
文字列が悩む所だけど、インデントで読みやすかったりする気が少しする。</p>
<p>自動生成版に変更し多少メンテしやすくした。</p>
<pre> (provide &#34;shtml&#34;)
 (defmacro !DOCTYPE (&#38;rest rest)
  `(format nil &#34;~%&#34;
           (list ,@rest)))
 (defmacro !-- (&#38;rest rest)
  `(format nil &#34;~%~%&#34;
           (list ,@rest)))
 
 (defmacro tag (tag
               container
               (&#38;rest rest &#38;key attribute)
               (&#38;rest child))
  `(format nil &#34;~[~;~%~;~:;~%~]&#60;~A~{~^ ~A=\&#34;~A\&#34;~^ ~}&#62;~{~A~}~[~;~%~;~:;~%~]&#34;
           ,container
           ,tag
           (list ,@rest)
           (list ,@child)
           ,tag
           ,container))
 
 (defmacro html-tag-mac(tag container)
  `(defmacro ,tag((&#38;rest rest &#38;key attribute) &#38;rest child)
     `(tag ,,(string tag) ,,container ,rest ,child)))
 
 (defvar *html-style*
  '((html 1)
    (head 1)
    (title 1)
    (body 1 )
    (h1 1)
    (h2 1)
    (h3 1)
    (h4 1)
    (h5 1)
    (h6 1)
    (div 1)
    (ol 1)
    (ul 1)
    (li 1)
    (a 0 )
    (abbr 0)
    (acronym 0)
    (address 0)
    (applet 0 )
    (b 0 )
    (basefont 1)
    (bdo 0)
    (big 0)
    (blink 0)
    (blockquote 1)
    (button 1)
    (caption 1)
    (center 1)
    (cite 0)
    (code 0)
    (colgroup 1)
    (comment 1)
    (dd 1)
    (del 0)
    (dfn 0)
    (dir 1)
    (dl 1)
    (dt 1)
    (em 0)
    (embed 1)
    (fieldset 1)
    (font 0)
    (form 1)
    (frameset 1)
    (i 1)
    (iframe 0)
    (ilayer 1)
    (ins 0)
    (kbd 0)
    (label 1)
    (layer 1)
    (legend 1)
    (listing 1)
    (map 1)
    (marquee 1)
    (menu 1)
    (multicol 1)
    (nobr 1)
    (noembed 1)
    (noframes 1)
    (nolayer 1)
    (noscript 1)
    (object 1)
    (optgroup 1)
    (option 1)
    (p 1)
    (pre 1)
    (q 0)
    (rb 0)
    (rp 0)
    (rt 0)
    (ruby 1)
    (s 0)
    (samp 0)
    (script 1)
    (select 1)
    (server 1)
    (small 0)
    (span 0)
    (strike 0)
    (strong 0)
    (style 1)
    (sub 0)
    (sup 0)
    (table 1)
    (tbody 1)
    (td 1)
    (textarea 1)
    (tfoot 1)
    (th 1)
    (thead 1)
    (title 1)
    (tr 1)
    (tt 1)
    (u 0)
    (var 0)
    (xmp 0)
    ))
 (dolist(x *html-style*)
  (eval `(html-tag-mac ,(car x) ,(cadr x))))
 (defmacro tag-c (tag (&#38;rest rest &#38;key attribute))
  `(format nil &#34;&#60;~A~{~^ ~A=\&#34;~A\&#34;~} /&#62;~%&#34;
           ,tag
           (list ,@rest)))
 (defmacro html-single-tag-mac(tag)
  `(defmacro ,tag(&#38;rest rest &#38;key attribute)
     `(tag-c ,,(string tag) ,rest)))
 (defvar *html-single-style*
  '(meta
    link
    br
    hr
    base
    area
    frame
    img
    input
    bgsound
    col
    keygen
    param
    wbr))
 (dolist(x *html-single-style*)
  (eval `(html-single-tag-mac ,x)))</pre>
<p>例えば , こういう s式を *scratch* で評価</p>
<pre> (html()
     (head()
          (title () &#34;test&#34;)
          (meta (:name &#34;EE&#34;)))
     (body()
          (h1 (:id &#34;H1&#34;)
              &#34;FOOOOOO!&#34;)
          (div ()
               (p ()
                  &#34;ふがふが&#34; (a(:href &#34;foo&#34;)&#34;ふう&#34;)
                  &#34;RoR&#34;)
               (p () &#34;ほげほげ&#34;))
          (ol ()
              (li () &#34;list1&#34;)
              (li () &#34;list2&#34;))
          (h2 (:id &#34;H2&#34; :class &#34;hoge&#34;)
              (a (:href &#34;hoge&#34;) &#34;ほげ&#34;)
              (table(:background &#34;blue&#34;
                     :border &#34;3&#34;)
                    (tr ()
                         (td ()  &#34;1&#34;)
                          (td () &#34;2&#34;))
                     (tr ()
                         (td () &#34;1234&#34;)
                         (td () &#34;5678&#34;))
                     ))))
   =&#62;
   &#34;
   &#60;html&#62;
   &#60;head&#62;
   &#60;title&#62;test&#60;/title&#62;
   &#60;/head&#62;
   
   
   &#60;body&#62;
   &#60;h1 id=\&#34;H1\&#34;&#62;FOOOOOO!&#60;/h1&#62;
   
   
   &#60;div&#62;
   &#60;p&#62;ふがふが
   &#60;a href=\&#34;foo\&#34;&#62;ふう&#60;/a&#62;
   &#60;/p&#62;
   
   
   &#60;p&#62;ほげほげ&#60;/p&#62;
   &#60;/div&#62;
   
   
   &#60;ol&#62;
   &#60;li&#62;list1&#60;/li&#62;
   
   
   &#60;li&#62;list2&#60;/li&#62;
   &#60;/ol&#62;
   
   
   &#60;h2 class=\&#34;hoge\&#34; id=\&#34;H2\&#34;&#62;
   &#60;a href=\&#34;hoge\&#34;&#62;ほげ&#60;/a&#62;
   
   
   &#60;table border=\&#34;3\&#34; background=\&#34;blue\&#34;&#62;
   &#60;tr&#62;
   &#60;td&#62;1&#60;/td&#62;
   
   
   &#60;td&#62;2&#60;/td&#62;
   &#60;/tr&#62;
   
   
   &#60;tr&#62;
   &#60;td&#62;1234&#60;/td&#62;
   
   
   &#60;td&#62;5678&#60;/td&#62;
   &#60;/tr&#62;
   &#60;/table&#62;
   &#60;/h2&#62;
   &#60;/body&#62;
   &#60;/html&#62;
   &#34;</pre>
<p>括弧を減らした。</p>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Sun, 27 Jan 2008 15:39:21 +0900</pubDate>
    </item>


    <item>
    <title>get-memory</title>
    <link>http://ottt.x0.com/xyzzy/get-memory.html</link>
    <guid>85ee2598-2179-4606-1f11-b426a44c4b07</guid>
    <description>

    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
</div>
</div>
<div class="cp">
<h2><a name="time もどき">time もどき</a></h2>
<div class="cc">
<dl>
<dt>working-set-size</dt>
<dd> xyzzy が現在使用しているメモリ。 </dd>
<dt>use-memory(var)(body)</dt>
<dd>body がどの位メモリを使用するか調べるためのマクロ。 </dd>
<dt>get-process-memory-info</dt>
<dd>values で memory-info を返します。 </dd>
<dt>get-performance-info</dt>
<dd>values で performance-info を返します。</dd>
</dl>
<pre>    (eval-when (:compile-toplevel :load-toplevel :execute)
               (require &#34;foreign&#34;)
               (require &#34;wip/winapi&#34;))
 
    (in-package &#34;winapi&#34;)
    (provide &#34;psapi&#34;)
    ;;// Structure for GetProcessMemoryInfo()
    ;;typedef unsigned int size_t
    (*define-c-type u_int SIZE_T)
 
    (*define-c-struct
     PROCESS_MEMORY_COUNTERS
     (DWORD cb)
     (DWORD PageFaultCount)
     (SIZE_T PeakWorkingSetSize)
     (SIZE_T WorkingSetSize)
     (SIZE_T QuotaPeakPagedPoolUsage)
     (SIZE_T QuotaPagedPoolUsage)
     (SIZE_T QuotaPeakNonPagedPoolUsage)
     (SIZE_T QuotaNonPagedPoolUsage)
     (SIZE_T PagefileUsage)
     (SIZE_T PeakPagefileUsage)
     )
 
    (*define-dll-entry BOOL GetProcessMemoryInfo (HANDLE (PROCESS_MEMORY_COUNTERS *) DWORD) &#34;psapi&#34;)
    (*define-dll-entry HANDLE GetCurrentProcess (LPVOID) &#34;kernel32&#34;)
 
    (*define-c-struct PERFORMANCE_INFORMATION
                      (DWORD cb)
                      (SIZE_T CommitTotal)
                      (SIZE_T CommitLimit)
                      (SIZE_T CommitPeak)
                      (SIZE_T PhysicalTotal)
                      (SIZE_T PhysicalAvailable)
                      (SIZE_T SystemCache)
                      (SIZE_T KernelTotal)
                      (SIZE_T KernelPaged)
                      (SIZE_T KernelNonpaged)
                      (SIZE_T PageSize)
                      (DWORD HandleCount)
                      (DWORD ProcessCount)
                      (DWORD ThreadCount)
                      )
    (*define-dll-entry BOOL GetPerformanceInfo ((PERFORMANCE_INFORMATION *) DWORD) &#34;psapi&#34;)
 
 
    (defun get-process-memory-info()
      (let((MemInfo (make-PROCESS_MEMORY_COUNTERS))
           (cb (c:c-struct-size-of PROCESS_MEMORY_COUNTERS))
           (hd (GetCurrentProcess 0)))
        (values
         (PROCESS_MEMORY_COUNTERS-PageFaultCount MemInfo)
         (PROCESS_MEMORY_COUNTERS-PeakWorkingSetSize MemInfo)
         (PROCESS_MEMORY_COUNTERS-WorkingSetSize MemInfo)
         (PROCESS_MEMORY_COUNTERS-QuotaPeakPagedPoolUsage MemInfo)
         (PROCESS_MEMORY_COUNTERS-QuotaPagedPoolUsage MemInfo)
         (PROCESS_MEMORY_COUNTERS-QuotaPeakNonPagedPoolUsage MemInfo)
         (PROCESS_MEMORY_COUNTERS-QuotaNonPagedPoolUsage MemInfo)
         (PROCESS_MEMORY_COUNTERS-PagefileUsage MemInfo)
         (PROCESS_MEMORY_COUNTERS-PeakPagefileUsage MemInfo))))
 
    (defun get-performance-info()
      (let ((PI (make-PERFORMANCE_INFORMATION))
            (cb (c:c-struct-size-of PERFORMANCE_INFORMATION)))
        (GetPerformanceInfo PI cb)
        (make-PERFORMANCE_INFORMATION)
        (values
         (PERFORMANCE_INFORMATION-CommitTotal PI)
         (PERFORMANCE_INFORMATION-CommitLimit PI)
         (PERFORMANCE_INFORMATION-CommitPeak PI)
         (PERFORMANCE_INFORMATION-PhysicalTotal PI)
         (PERFORMANCE_INFORMATION-PhysicalAvailable PI)
         (PERFORMANCE_INFORMATION-SystemCache PI)
         (PERFORMANCE_INFORMATION-KernelTotal PI)
         (PERFORMANCE_INFORMATION-KernelPaged PI)
         (PERFORMANCE_INFORMATION-KernelNonpaged PI)
         (PERFORMANCE_INFORMATION-PageSize PI)
         (PERFORMANCE_INFORMATION-HandleCount PI)
         (PERFORMANCE_INFORMATION-ProcessCount PI)
         (PERFORMANCE_INFORMATION-ThreadCount PI)
         )))
    ; xyzzy use memory size
    (defun working-set-size()
      (let((MemInfo (make-PROCESS_MEMORY_COUNTERS))
           (cb (c:c-struct-size-of PROCESS_MEMORY_COUNTERS))
           (hd (GetCurrentProcess 0))
           beg end)
        (GetProcessMemoryInfo hd MemInfo cb)
        (PROCESS_MEMORY_COUNTERS-WorkingSetSize MemInfo)))
 
    (in-package :user)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; 使用する関数
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun get-process-memory-info()
      (winapi::get-process-memory-info))
 
    (defun get-performance-info()
      (winapi::get-performance-info))
 
    (defun working-set-size()
      (winapi::working-set-size))
 
    (defmacro use-memory ((var) &#38;body body)
      `(let((,var (working-set-size)))
         ,@body
         (- (working-set-size) ,var)))
    ;; 何故こうしたのかは、忘れた。
    ;; before (- after before)
    ;;(use-memory(x)(princ x))
 
    ;;
    ;; (defmacro use-memory (&#38;body body)
    ;;   `(let((var (working-set-size)))
    ;;  ,@body
    ;;   (- (working-set-size) var)))
 
    上記をふまえた上で time 風な物をでっちあげてみた。
 
    (setq *time-macro-fmt*  &#34;
    Varsion:~20t[~A ~A]
    Try Test:~20t[~D times]
    Execution Time:~20t[~D /ms]
    Average Time:~20t[~A /ms]
    Maximum Time:~20t[~D /ms]
    Over Zero:~20t[~D itmes]
    Execution Memory:~20t[~D /b]
    Average Memory:~20t[~A /b]
    Maximum Memory:~20t[~D /b]
    Over Zero:~20t[~D itmes]
    ~{S-Expression:~20t~S~%Result:~20t~S~}
    &#34;)
 
    (defmacro time((&#38;optional(how 1)) &#38;body body)
      (labels((tgensym()(gensym &#34;time&#34;)))
        (let((g (tgensym))(result (tgensym))
             (start (tgensym))(total (tgensym))(time (tgensym))
             (memory (tgensym))(mstart (tgensym))(mtotal (tgensym)))
          (gc)
          `(let (,total ,mtotal
                 (,time (get-internal-real-time))
                 (,memory (working-set-size)))
             (dotimes(,g ,how (setq ,result (list (car ',body) ,result)))
               (setq ,start (get-internal-real-time))
               (setq ,mstart (working-set-size))
               (setq ,result ,@body)
               (push (- (get-internal-real-time) ,start) ,total)
               (push (- (working-set-size) ,mstart) ,mtotal)
               )
             (labels((average(x)(apply #'+ (multiple-value-list
                                            (float (/ (apply #'+ x)(length x)))))))
               (format t *time-macro-fmt*
                       (software-type) (software-version)
                       ,how
                       ; time
                       (- (get-internal-real-time) ,time )
                       (average ,total)
                       (apply #'max ,total)
                       (count-if #'(lambda(x)(&#60; 0 x)) ,total)
                       ; memory
                       (- (working-set-size) ,memory)
                       (average ,mtotal)
                       (apply #'max ,mtotal)
                       (count-if #'(lambda(x)(&#60; 0 x)) ,mtotal)
                       ,result)
               )))))
 
    ;; 使えるかどうかは解らない
    (defun do-time-list(how list)
      (dolist(x list)
        (eval `(time (,how) ,x))))
 
    (defmacro time+((&#38;optional(how 1))&#38;body body)
      (let((f (gensym &#34;gFunction:=&#34;)))
        `(progn(defun ,f() ,@body)
           (format t &#34;~%~5t[before-compile]&#34;)
           (time (,how) ,@body)
           (format t &#34;~60,,,'=A&#34; &#34;&#34;)
           (compile ',f)
           (format t &#34;~%~5t[after-compile]&#34;)
           (time (,how)(,f))
           (format t &#34;~60,,,'=A&#34; &#34;&#34;))))
 
    (defun do-time+-list(how list)
      (dolist(x list)
        (eval `(time+ (,how) ,x))))</pre>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Sun, 27 Jan 2008 15:38:37 +0900</pubDate>
    </item>


    <item>
    <title>miswitchb</title>
    <link>http://ottt.x0.com/xyzzy/miswitchb.html</link>
    <guid>f4f9313d-b9e2-37b5-d752-ab4f42fbac2d</guid>
    <description>
iswitchb の場合、目線が minibaffer にいくので目線はそのままでバッファの表示量を増やし  *do-completion を利用してかっちり補完移動と曖昧補完移動。(↑↓→← C-f C-b C-p C-n でも移動)きっちりモードに仕上げるのがいいと思ったけど、長くなるので個人的に使うのでここまでにした。
    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
<div class="cp">
<h2><a name="バッファの移動">バッファの移動</a></h2>
<div class="cc">
<p>iswitchb の場合、目線が minibaffer にいくので目線はそのままでバッファの表示量を増やし  *do-completion を利用してかっちり補完移動と曖昧補完移動。(↑↓→← C-f C-b C-p C-n でも移動)
きっちりモードに仕上げるのがいいと思ったけど、長くなるので個人的に使うのでここまでにした。</p>
<pre>    (defun list/n(list n)
      (unless(atom list)
        (let ((i (if(&#60; n (length list)) n (length list))))
          (cons(subseq list 0 i)
               (list/n (subseq list i nil)n)))))
    
    (defun miswitchb-color(search)
      (let((from (progn(scan-buffer search)(point))))
        (save-excursion
          (set-text-attribute from
                              (progn
                                (scan-buffer search :tail t)
                                (point))
                              'buf  :foreground 9 :bold t))))
    
    (defun miswitchb-switch(buf)
      (find-buffer buf)
      (delete-window)
      (switch-to-buffer buf))
    
    (defun vague-amiswitchb-list(str)
      (sort
       (remove-if #'(lambda (x)
                      (eq(char (buffer-name x) 0) #\SPC))
                  (let(r)
                    (dolist(x (remove-if
                               #'(lambda (x)
                                   (not (string-matchp(regexp-quote str)
                                                      (buffer-name x))))
                               (buffer-list))
                              r)
                      (push (buffer-name x) r))))
       #'string-lessp))
    
    (defun miswitchb(arg)
      (interactive &#34;P&#34;)
      (and(get-ime-mode)
          (toggle-ime nil))
      (let((str &#34;&#34;)
           (fmt &#34; Completion Buffer~%~60,,,'-@A~%~{~{ ~20,@A ~}~%~}&#34;)
           (buf &#34; *Buffer List Completion*&#34;)
           (i 0)
           ib c sym complete blst from to fbl ime)
        (and(get-ime-mode)
            (setq ime t)
            (toggle-ime nil))
        ;; 実行時にただ表示させるだけ
        (with-output-to-temp-buffer(buf)
          (multiple-value-bind(a b)
              (*do-completion str :buffer-name)
            (format t fmt &#34;&#34;
                    (list/n (setq fbl(sort
                                      (delete buf b :test 'equal)
                                      #'string-lessp)) 4))))
        (miswitchb-color(setq complete (car fbl)))
        (loop
          (minibuffer-message &#34;Buffer: ~A&#34; str)
          ;;RETで決定 複数の場合car
          (when(and(eq #\RET (setq c (read-char *keyboard*)))
                   ;; どうにかならんか
                   (if arg
                       (if (eq sym :no-match)
                         t
                       (if sym (stringp sym) t))
                     t))
            (miswitchb-switch complete)
            (and ime (toggle-ime ime))
            (return complete))
          (setq ib (1- (length blst)))
          (case c
            ((#\RET)
             (miswitchb-switch (car blst))
             (return (car blst)))
            ((#\C-g) (quit))
            ((#\C-h)
             (or(eq (length str) 0)
                (setq str (subseq str 0 (1- (length str))))))
            ((#\Left #\C-b)
             (if(&#60; 0 i)(decf i)))
            ((#\Right #\C-f)
             (cond((= 0 i)
                   (setq i 1))
                  ((&#60; i  ib)
                   (incf i))
                  (t (setq i 0))))
            ((#\Up #\C-p)
             (cond((&#60;= 0 (- i 4)) (decf i 4))
                  ((&#60; 0 i 4) (decf i))
                  (t (setq i ib))))
            ((#\Down #\C-n)
             (cond((&#60; (- ib 4) i  ib)(incf i))
                  ((&#60; ib i) (setq i 0))
                  ((&#60; (+ i 3) ib)(incf i 4))
                  (t (setq i 0))))
            (t (setq i 0)
               (if(eq (lookup-key-command c) 'self-insert-command)
                   (setq str (concatenate 'string str (string c)))
                 t)))
          (message &#34;~A&#34; i)
          (with-output-to-temp-buffer(buf)
            (multiple-value-bind(a b)
                (*do-completion str :buffer-name)
              (format t fmt &#34;&#34;
                      (list/n (setq blst
                                    ;; 切り替え
                                    (if arg
                                        (sort (delete buf b :test 'equal)  #'string-lessp)
                                        (or (vague-amiswitchb-list str) fbl)
                                      ))
                              4))
              ;; 切り替え
              (and arg (setq sym a))
              (setq complete (nth i blst))
              ;書き換えた後の始めの位置
              (and blst (miswitchb-color (car blst)))
              ))
          (delete-text-attributes 'buf);前回の色を消す
          (and blst (miswitchb-color complete))
          (refresh-screen))
        ))
    
    </pre>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Sun, 27 Jan 2008 15:37:59 +0900</pubDate>
    </item>


    <item>
    <title>js-shell</title>
    <link>http://ottt.x0.com/xyzzy/js-shell.html</link>
    <guid>ca580ba0-2377-9835-15d8-8e72cf42fdbc</guid>
    <description>
リージョンをshellに投げつけるので編集しながらちょこっとテストする時に使える、*javascript-mode-map* に追加しておくと少し幸せになれるかもwindow の高さは *js-shell-popup-width*を調整することで幅を変えられるその都度、一時ファイルに書き出してjsshell.exeを立ち上げて実行しているのであまり効率が良くないような気がするけど一応メモしておく。function,var,空白行を探して戻り現在行を実行しているので、それなりな所で実行しないとSyntaxErrorを吐きまくります。^^;ファイルに書き出さなくてもいいバージョン、こっちの方がエラーで出てファイルが残ったりしないのでいいと思う。
    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
<div class="cp">
<h2><a name="js-shell">js-shell</a></h2>
<div class="cc">
<pre> ;; インタラクティブに xyzzy から javascript しようといゆうことで
 ;; shell-mode を少しいじっただけ
 ;;
 ;;  (require &#34;js-shell&#34;)
 ;;  javascript-mode が必要です。
 ;;
 ;; パスを指定する
 ;;  rhino な場合
 ;;  (setq *js-shell-path* (merge-pathnames &#34;rhino1_6R2/js.jar&#34; &#34;C:/usr/bin/&#34;))
 ;;  InteractiveJS な場合 64 行目辺り
 ;;  (setq *js-shell-path* (merge-pathnames &#34;imjs.js&#34; &#34;C:/usr/bin/&#34;)) imjsv3.js は手に入らないかも
 ;;  http://d.hatena.ne.jp/nak2k/ 辺り
 ;;
 ;; SpiderMonkey の js.exe はわからなかった
 ;;
 ;;
 ;; javascript-mode の keyword と abbrev-table *js-shell-mode-abbrev-table* を追加
 ;;
 ;;
 (provide &#34;js-shell&#34;)
 
 (in-package &#34;editor&#34;)
 
 (export '(*js-shell-mode-hook* *js-shell-prompt-regexp* *js-shell-mode-map*
           *js-shell-ret* *js-shell-echo* js-shell js-shell-send-input
           js-shell-send-interrupt js-shell-alternate-send-input
          js-execute-region))
 
 (defvar *js-shell-buffer* &#34;*js-shell*&#34; )
 (defvar *js-shell-path* nil)
 ;;;(setq *js-shell-path* (merge-pathnames &#34;rhino1_6R2/js.jar&#34; &#34;C:/usr/bin/&#34;))
 (defvar *js-shell-mode-hook* nil)
 (defvar *js-shell-prompt-regexp* &#34;^\[^#$%&#62;?\n]*\[#$%&#62;?] *&#34;)
 (defvar-local *js-shell-ret* &#34;\n&#34;)
 (defvar-local *js-shell-echo* nil)
 
 
 (defvar *js-shell-mode-map* nil)
 (unless *js-shell-mode-map*
  (setq *js-shell-mode-map* (make-sparse-keymap))
  (define-key *js-shell-mode-map* #\RET 'js-shell-send-input)
  (define-key *js-shell-mode-map* #\q 'js-shell-exit)
  (define-key *js-shell-mode-map* #\C-j 'js-shell-alternate-send-input)
  (define-key *js-shell-mode-map* #\C-i 'javascript-completion)
  (define-key *js-shell-mode-map* '(#\C-c #\C-c) 'js-shell-send-interrupt))
 
 (defvar *js-shell-mode-abbrev-table*  nil)
 (unless *js-shell-mode-abbrev-table*
  (define-abbrev-table '*js-shell-mode-abbrev-table*))
 
 (defun js-shell-exit()
  (interactive)
  (when(find-buffer *js-shell-buffer*)
    (switch-to-buffer *js-shell-buffer*)
    (goto-char(point-max))
    (js-shell-send-input)
    (insert &#34;quit();&#34;)
    (js-shell-send-input)
    (sit-for 1)
    (delete-buffer *js-shell-buffer*)
    (delete-window)))
 
 
 (defun js-shell-mode ()
  (setq mode-name &#34;js-shell&#34;)
  (setq buffer-mode 'js-shell-mode)
  (use-keymap *js-shell-mode-map*)
  (setq need-not-save t)
  (setq auto-save nil)
  (setq kept-undo-information nil)
  (set-buffer-fold-width 80)
  (setq *local-abbrev-table* *js-shell-mode-abbrev-table*)
  (cond ((string-matchp *eshell* &#34;command.com$&#34;)
         (setq *js-shell-ret* &#34;\r&#34; *js-shell-echo* t))
        ((string-matchp *eshell* &#34;cmd.exe$&#34;)
         (setq *js-shell-ret* &#34;\n&#34; *js-shell-echo* t))
        (t
         (setq *js-shell-ret* &#34;\n&#34; *js-shell-echo* nil)))
  (run-hooks '*js-shell-mode-hook*))
 
 
 (defun js-shell ()
  (interactive)
  (set-buffer (get-buffer-create *js-shell-buffer*))
  (let ((proc (buffer-process (selected-buffer))))
    (and proc (eq (process-status proc) ':run)
         (return-from js-shell t)))
  (goto-char (point-max))
  (js-shell-mode)
  ;;imjs(WSH) な人はここをコメントアウトを外して下をコメントアウト
  ;;(make-process (concat *eshell* &#34; /c cscript &#34; *js-shell-path*) :output (selected-buffer)))
  (make-process (concat *eshell* &#34; /c &#34; &#34;java -jar &#34; *js-shell-path*):output (selected-buffer)))
 
  ;;;
  ;;; This code is loosely based on version 0.1 by Yutaka Oiwa .
  ;;;
 
 (defun js-shell-send-input ()
  (interactive)
  (let ((process (buffer-process (selected-buffer)))
        start end prompt)
    (when (and process
               (eq (process-status process) :run))
      (cond ((&#62;= (point) (marker-point (process-marker process)))
             (setq start (marker-point (process-marker process)))
             (setq end (progn (goto-eol) (point))))
            ((save-excursion
               (goto-bol)
               (looking-at *js-shell-prompt-regexp*))
             (setq start (match-end 0))
             (setq end (progn (goto-eol) (point)))
             (setq prompt (match-string 0)))
            (t
             (return-from js-shell-send-input nil)))
      (let ((cmd (buffer-substring start end)))
        (cond ((eobp)
               (if *js-shell-echo*
                   ;;(delete-region start end)
                   (insert &#34;\n&#34;)
                 (insert &#34;\n&#34;)))
              (t
               (goto-char (point-max))
               (or (bolp)
                   (insert &#34;\n&#34;))
               (and prompt (insert prompt))
               (unless *js-shell-echo*
                 (insert cmd))))
        (set-marker (process-marker process))
        (process-send-string process (concatenate 'string cmd *js-shell-ret*)))))
  (recenter (round (/ (window-lines) 2))))
 
 (defun js-shell-alternate-send-input ()
  (interactive)
  (let ((*js-shell-echo* (if (equal *js-shell-echo* &#34;\n&#34;)&#34;\r&#34; &#34;\n&#34;)))
    (declare (special *js-shell-echo*))
    (js-shell-send-input)))
 
 (setf (symbol-function 'js-shell-send-interrupt) #'kill-subprocess)</pre>
</div>
</div>
<div class="cp">
<h2><a name="便利かもしれないもの">便利かもしれないもの</a></h2>
<div class="cc">
<p>リージョンをshellに投げつけるので編集しながらちょこっとテストする時に使える、*javascript-mode-map* に追加しておくと少し幸せになれるかも</p>
<pre> (defvar *js-shell-popup-width* 0)
 (defun js-execute-region(beg end)
  (interactive &#34;*r&#34;)
  (let(str b
           (send (split-string (buffer-substring beg end) #\LFD))
           (curent (selected-buffer))
           (buf *js-shell-buffer*))
    (setq b (get-buffer-create buf))
    (js-shell)
    (let ((proc (buffer-process (selected-buffer))))
      (loop
        (when
            (and proc (eq (process-status proc) ':run))
          (return)))
      (set-buffer b)
      (goto-char(point-max))
      (let((p1(point)))
        (dolist (x send )
          (insert (format nil &#34;~A&#34; x))
          (funcall 'js-shell-send-input))
        (set-buffer curent)
        (pop-to-buffer b *js-shell-popup-width*)
        (set-buffer b)
        (dotimes (i (length send)) (scroll-window 1) (sit-for .05))
        (goto-char(point-max))
        (recenter (if (zerop *js-shell-popup-width*)
                      5
                    (round(/ *js-shell-popup-width* 2))))
        (refresh-screen)
        (other-window)
        ))))
 
 (defun js-eval-function(&#38;optional arg)
  (interactive &#34;P&#34;)
  (if arg
      (if(find-buffer *js-shell-buffer*)
          (switch-to-buffer *js-shell-buffer*)
        (js-shell))
    (let((p (point)) p1)
      (save-excursion
        (scan-buffer &#34;^\\(\(?function\\|var\\)&#34;
                     :regexp t :reverse t :no-dup t)
        (setq p1 (point))
        (js-execute-region p p1)))
    ))</pre>
<p>window の高さは *js-shell-popup-width*を調整することで幅を変えられる</p>
</div>
</div>
<div class="cp">
<h2><a name="SpiderMonkey用">SpiderMonkey用</a></h2>
<div class="cc">
<p>その都度、一時ファイルに書き出してjsshell.exeを立ち上げて実行しているのであまり効率が良くないような気がするけど一応メモしておく。</p>
<p>function,var,空白行を探して戻り現在行を実行しているので、それなりな所で実行しないとSyntaxErrorを吐きまくります。^^;</p>
<pre> (defun spidermonkey-eval-print()
  (interactive)
  (let*((beg (save-excursion
              (goto-eol)
              (scan-buffer &#34;^\\($\\|\\(\(?function\\|var\\).+\\({\\|;\\)$\\)&#34;
                           :regexp t :reverse t :no-dup t)
              (point)))
        (str (buffer-substring beg (progn(goto-eol)(point))))
        (print (split-string  str #\LFD))
        (file (make-temp-file-name &#34;$js_&#34; &#34;tmp&#34; &#34;~/&#34;));一時ファイルを作る
        (cur (selected-buffer))
        (buf (get-buffer-create ed::*js-shell-buffer*))
        (line (buffer-substring(progn(goto-bol)(point))(progn(goto-eol)(point)))))
    (with-open-file(f file :direction :output)
      (princ str f)
      (dolist(x print)
        (format f &#34;~&#38;print(\&#34;~A\&#34;)~%&#34;
                (substitute-string x &#34;\[\&#34;\']\\(.*?\\)\[\&#34;\']&#34; &#34;\\\\\&#34;\\1\\\\\&#34;&#34;)))
      (format f &#34;~&#38;print(\&#34;js&#62; \&#34; +~A)~%&#34; line))
    (set-buffer buf)
    (set-buffer cur)
    (pop-to-buffer buf 8);分割
    (setq need-not-save t)
    (setq auto-save nil)
    (setq kept-undo-information nil)
    (goto-char (point-max))
    (make-process (format nil  &#34;js.exe -f \&#34;~A\&#34;&#34; file)
                   :output (selected-buffer)) ; jsshell.exe?
    (dotimes (i (length print)) (sit-for 1)(scroll-window 1) )
    (refresh-screen)
    (goto-char (point-max))
    (recenter (window-height))(refresh-screen)
    (other-window)
    (start-timer 5 #'(lambda()(delete-file file)) t)
    ))</pre>
<p>ファイルに書き出さなくてもいいバージョン、こっちの方がエラーで出てファイルが残ったりしないのでいいと思う。</p>
<pre> (defun spidermonkey-eval-region(from to)
  (interactive &#34;*r&#34;)
  (spidermonkey-eval-print
   (buffer-substring from
                     (if(not(eolp))
                         (progn(goto-eol)(point))
                       to))))
 (defun spidermonkey-eval-print(&#38;optional string)
  (interactive)
  (let*((end (save-excursion(goto-eol)(point)))
        (beg (save-excursion
               ;どこまで戻るか
               (scan-buffer &#34;^\\($\\|\\(\(?function\\|var\\).+\\({\\|;\\)$\\)&#34;
                            :regexp t :reverse t :no-dup t)
               (point)))
        (str (if string string (buffer-substring beg end)))
        (print (split-string  str #\LFD))
        (cur (selected-buffer))
        (buf (get-buffer-create ed::*js-shell-buffer*))
        (line (buffer-substring(save-excursion(goto-bol)(point)) end))
        (proc))
    (set-buffer buf)
    (setq need-not-save t)
    (setq auto-save nil)
    (setq kept-undo-information nil)
    (goto-char (point-max))
    (set-buffer cur)
    (pop-to-buffer buf 8)
 
    (setq proc(make-process &#34;js&#34; :output (selected-buffer)))
    ; 評価しておく
    (process-send-string proc (format nil &#34;~A~%&#34; str))
    ; 一行宛表示
    (dolist(x print)
      (process-send-string
       proc
       (format nil &#34;print(\&#34;js&#62; ~A\&#34;)~%&#34;
               (substitute-string x &#34;\[\&#34;\']\\(.*?\\)\[\&#34;\']&#34;
                                  &#34;\\\\\&#34;\\1\\\\\&#34;&#34;))))
    ; キャレットのある行を評価
    (process-send-string
     proc
     (format nil &#34;~&#38;print(\&#34;js&#62; \&#34; + ~A)~%&#34;
             (cond ((string-match &#34;.*//.*&#34; line)
                    &#34;\&#34;comment line\&#34;&#34;)
                   ((string-match &#34;^[ \t]?+?[}].*&#34; line)
                    (if(string-match &#34;^\\(function\\|var\\) \\(\[^ ]+?\\)\[ (=]&#34; (car print))
                        (concat &#34;\&#34;&#34;(match-string 2)&#34;\&#34;&#34;)
                      &#34;\&#34;not test function\&#34;&#34;))
                   ((string-match &#34;var&#34; line)
                    (substitute-string line &#34;var \\(\[^ ]+?\\) =.*&#34; &#34;\\1&#34;))
                   (t line))
             ))
    (process-send-string proc (string #\C-z)); process end
    (sit-for .5)
    (goto-char (point-max))
    (recenter (1- (window-height)))
    (refresh-screen)
    (other-window)
    ))</pre>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Sun, 27 Jan 2008 15:37:54 +0900</pubDate>
    </item>


    <item>
    <title>multiple-insert</title>
    <link>http://ottt.x0.com/xyzzy/multiple-insert.html</link>
    <guid>7f222158-e87a-ca7c-7047-9ee99caa9f5d</guid>
    <description>
矩形やら選択範囲を操作するのは silog さんとこの surround.l が便利なのでそれを使っているのですが何ヶ所か離れた所を同時編集する時に使う為と register って便利だなと思ったので使ってみた。上記の物よりはコードが短くすんだので満足した。;とりあえずマウスで指定していく
    </description>
    <content:encoded>
    <![CDATA[
<!-- main contents start -->
<div class="mc">
<div class="cp">
<h2><a name="register を使ってみた物">register を使ってみた物</a></h2>
<div class="cc">
<p>矩形やら選択範囲を操作するのは silog さんとこの surround.l が便利なのでそれを使っているのですが何ヶ所か離れた所を同時編集する時に使う為と register って便利だなと思ったので使ってみた。上記の物よりはコードが短くすんだので満足した。</p>
<pre> (defvar *multi-register-r* 0)
 (defun multi-set-register ()
  (interactive)
  (mouse-left-press)
  (setq *multi-register-r* (1+ *multi-register-r*))
  (ed::set-register (code-char *multi-register-r*)(point-marker)))
 
 (defun multi-type-register()
  (interactive)
  (let(c)
    (while(setq c (read-char *standard-input*))
      (if(eq #\C-h c)
        (do((i 1 (1+ i)))
            ((&#62; i *multi-register-r*)nil)
          (jump-to-register (code-char i))
          (delete-char -1)(refresh-screen))
        (progn
      (when(and(not(eq #\C-h c))(fboundp (lookup-key-command c))
               (not(eq (lookup-key-command c) 'self-insert-command)))
        (setq *multi-register-r* 0)(unread-char c)
        (return-from multi-type-register))
      (do((i 1 (1+ i)))
          ((&#62; i *multi-register-r*)nil)
        (jump-to-register (code-char i))
        (insert c)
        (ed::set-register (code-char i)(point-marker))
        (refresh-screen)
        ))))))</pre>
<p>;とりあえずマウスで指定していく</p>
<pre> (global-set-key #\C-LBtnDown 'multi-set-register)
 (global-set-key #\C-RBtnDown 'multi-type-register)</pre>

</div>
</div>
</div>
<!-- main contents end -->

    ]]>
    </content:encoded>
    <pubDate>Sun, 27 Jan 2008 15:37:35 +0900</pubDate>
    </item>


  </channel>
</rss>
