home *** CD-ROM | disk | FTP | other *** search
/ MacPeople 2003 February 1 / MACPEOPLE-2003-02-01.ISO.7z / MACPEOPLE-2003-02-01.ISO / ぶらりオンラインウェアの旅 / 定番ソフト / Jedit(OS9) / MacroCollectionJ.sea / MacroCollection-J / 英単語半角スペース削除 / スクリプト解説 < prev    next >
Text File  |  2001-01-01  |  1KB  |  42 lines

  1. 英単語前後の半角スペースを削除 マクロ
  2. programmed by Satoshi Matsumoto <satoshi@matsumoto.co.jp>
  3. 選択領域のなかにある英単語の前後が半角スペースで日本語に隣接しているときは、その半角スペースを削除する。
  4.  
  5. ーーーーーーーーーーーー
  6.  
  7. tell application "Jedit4"
  8.     Jeditのバージョンチェック。Rev4.0.4より古いときは中止
  9.     if version < 404 then
  10.         preDialog
  11.         display dialog "Jedit4.0 Rev4.0.4 以降を使用してください" buttons {" 了解"}
  12.         postDialog
  13.         error number -128
  14.     end if
  15.     書類がなにも開いていないときは警告をだして終了
  16.     if (count document) < 1 then
  17.         preDialog
  18.         display dialog "書類を先に開いてください。" buttons {" 了解"}
  19.         postDialog
  20.         error number -128
  21.     end if
  22.     tell document 1
  23.         Jeditの書類を前面へ
  24.         activate
  25.         なにも選択されていないときは全てを選択
  26.         if length of selection = 0 then
  27.             select (bytes 1 thru -1)
  28.         end if
  29.         選択領域の開始オフセットをtheStart
  30.         copy byteoffset of the selection to theStart
  31.         選択領域の終了オフセットを文末からの距離として負の値でtheEnd
  32.         copy length of the selection to theEnd
  33.         copy theStart + theEnd - (data size) - 2 to theEnd
  34.         英単語の左隣の半角スペースを削除
  35.         replace "{[1-熙]}¥¥s{¥¥w[!-¥¥h7E]+}" to "¥¥1¥¥2" in selection with grep
  36.         選択をし直す
  37.         select (bytes theStart thru theEnd)
  38.         英単語の右隣の半角スペースを削除
  39.         replace "{¥¥w[!-¥¥h7E]+}¥¥s{[1-熙]}" to "¥¥1¥¥2" in selection with grep
  40.     end tell
  41. end tell
  42.