Gauche:Gauchebox

Gauche:Gauchebox

Lispboxと同様に、Emacs等を含んだGaucheの配布物を作ろうとする試み。 Gauche:NSISと重複する部分は割愛。

ダウンロード

http://sourceforge.net/project/showfiles.php?group_id=25227

インストール

  1. Gauchebox-<version>.exeをダブルクリックしてインストーラを実行する
  2. インストールの最後に黒い背景の画面が表示される。
    Enter the directory which Meadow read .emacs file from.
    If you do not specify, Meadow reads .emacs file in following directory.
    [C:\Program Files\Gauchebox\Meadow]
    
    通常はここで単に[Enter]を押すことを推奨
  3. もし上記で.emacsの読み込み先パスを設定した場合は、Meadow/.emacsをそのディレクトリにコピーする必要がある

※ 注意点: Meadowがすでにインストールされている環境では、GaucheboxはMeadowの設定を上書きする。 Meadowがすでにインストールされている場合はGauche-mingw-<version>.exeをインストールしてください。

開発方針

リポジトリ

http://gauche.svn.sourceforge.net/viewvc/gauche/Gauchebox/

開発時のソース構成

 Gauche            ;; GaucheのCVS版
 Gauchebox         ;; Gaucheboxのソースディレクトリ
 Meadow            ;; Meadowのバイナリ配布物
 ProgrammingGauche ;; フムフム本のサンプルソース

上記が同じ階層に存在することが前提。

スクリプトジェネレータ

※ うまく統一させたいけど、 現状ではGauche:NSISとは異なります。

;; -*- coding: utf-8 -*-
;;  Copyright (c) 2008 ENDO Yasuyuki, All rights reserved. 
;;  Copyright (c) 2008 Kahua Project, All rights reserved. 
;;  See COPYING for terms and conditions of using this software 

(use file.util)
(use srfi-1)
(use srfi-13)
(use gauche.parameter)
(use gauche.parseopt)
(use text.tree)

(define *instdir* "$INSTDIR")
(define *ignore-path* '("CVS" ".svn"))
(define *target-prefix* "    SetOutPath ")
(define *install-prefix* "    File ")
(define *delete-prefix* "    Delete /REBOOTOK ")
(define *cr-lf* "\r\n")
(define *path-separater* "\\")
(define *file-list* (make-parameter #f))
(define *current-version* (make-parameter #f))

(define (replace-inst prefix path)
  (receive (pref last ext)
      (decompose-path prefix)
    (regexp-replace (string->regexp pref)
                    path *instdir*)))

(define (file-list path)
  (directory-fold
   path cons '()
   :lister (lambda (path seed)
             (receive (d f)
                 (directory-list2 path :add-path? #t :children? #t)
               (values d
                       (cons (cons path f) seed))))))

(define (check-ignore-path str lis)
  (every identity
         (map
          (lambda (s)
            (not (string-contains str s)))
          lis)))

(define (initialize dist-list version)
  (begin0
    (*current-version* version)
    (*file-list*
     (map
      (lambda (path)
        (begin
          (cons path
                (reverse
                 (filter
                  (lambda (ls) (and (pair? (cdr ls))
                                    (check-ignore-path (car ls) *ignore-path*)))
                  (file-list path))))))
      dist-list))))

(define (inst-str root-path ls)
  (cons
   #`",|*target-prefix*|,(change-path (replace-inst root-path (car ls))),|*cr-lf*|"
   (map change-path
        (map
         (lambda (s) #`",|*install-prefix*|,|s|,|*cr-lf*|")
         (cdr ls)))))

(define (del-str root-path ls)
  (map
   (lambda (s) #`",|*delete-prefix*|,(change-path (replace-inst root-path s)),|*cr-lf*|")
   (cdr ls)))

(define (install-files)
  (append-map
   (lambda (ls)
     (let1 root-path (car ls)
       (map (cut inst-str root-path <>)
            (cdr ls))))
   (*file-list*)))

(define (delete-files)
  (append-map
   (lambda (ls)
     (let1 root-path (car ls)
       (map (cut del-str root-path <>) (cdr ls))))
   (*file-list*)))

(define (include line)
  (or
   (and-let* ((match (#/^(.*)##\(include (.*)\)(.*\r\n)$/ line))
              (exp (call-with-input-string (match 2) (cut read <>))))
     (list (match 1) (eval exp (current-module)) (match 3)))
   line))

(define (include-all lis)
  (map include lis))

(define (change-path str)
  (string-join (string-split str #\/) *path-separater*))

(define (read-line-crlf file)
  (let1 line (read-line file)
    (if (eof-object? line) line
        #`",|line|,|*cr-lf*|")))

(define (exist-filter path-list)
  (filter
   (cut file-exist <>)
   path-list))

(define (main args)
  (let1 path-list '()
    (let-args (cdr args)
        ((path "p|path=s"
               => (lambda (x) (push! path-list x)))
         (template "t|template=s" #f)
         (version "v|version=s" #f))
      (let* ((path-list (filter (cut file-exists? <>) path-list))
             (out (path-sans-extension template))
             (lines (file->list read-line-crlf template)))
        (begin
          (initialize path-list version)
          (call-with-output-file out
            (cut write-tree (include-all lines) <>))
          0)))))

.emacs

 (setq scheme-program-name "\"gosh.exe\" -i")

フムフム本の付録Bとの違いは上記のみ。 $INSTDIR\Meadowにコピーされる。

scheme-program-name

scheme-program-nameで空白を含むパスに対応するために以下を追加。 (thanks: 齊藤さん)

gosh.exeのフルパス埋め込み

setup.nsi.inの-postインストールセクションで以下を実行。

# Included files
!include WordFunc.nsh
!include TextReplace.nsh
(略)
!insertmacro WordReplace
(略)
    ## replace gosh.exe's full-path in .emacs
    ${WordReplace} "$INSTDIR\Gauche\bin\gosh.exe" "\" "\\" "+*" $0
    ${textreplace::ReplaceInFile} "$INSTDIR\Meadow\.emacs" "$INSTDIR\Meadow\.emacs" "gosh.exe" "$0" "/S=1 /C=1 /A0=1" $1

Gauche-glの取り込み

齊藤さんによるビルドを採用。

http://saito.s4.xrea.com/wiliki.scm?Gauche

出来れば自前でビルドしたい。

課題

既存のMeadow環境への影響

Meadow/install.exeはデスクトップやスタートメニューにショートカットを作成する。 すでにMeadowがインストール済みの環境ではこれらを上書きしてしまう。

すでにMeadowをインストールしている場合はGaucheboxではなくGauche-win32-0.8.13.exeを推奨。

gosh.exeでの日本語表示

gosh.exeを単体で起動して日本語表示してみる。

gosh> #\u3042
#\縺・

コードページはMS932な模様。

gosh> (sys-system "dir")
 ドライブ C のボリューム ラベルがありません。
 ボリューム シリアル番号は 045D-793E です

 C:\Documents and Settings\yasuyuki\スタート メニュー\プログラム\Gauchebox のデ
ィレクトリ

2008/05/02  14:44    <DIR>          .
2008/05/02  14:44    <DIR>          ..
2008/05/02  14:44             1,758 Gauchebox.lnk
2008/05/02  14:44             1,789 Meadow.lnk
2008/05/02  14:44               774 Uninstall Gauchebox.lnk
               3 個のファイル               4,321 バイト
               2 個のディレクトリ  123,822,731,264 バイトの空き領域
0
gosh> (sys-system "chcp")
現在のコード ページ: 932
0

MeadowでのUTF-8対応

Meadowでの日本語入力

(mw32-ime-initialize)
(setq default-input-method "MW32-IME")

Meadow 3なら不要。

コメント

Past comment(s)

yokota (2008/05/02 01:09:49):

日本語環境ではMeadowをやめてEmacs 22を使うのは現実的ではありません。Emacs22での日本語入力はUnixと同等になるので、Unixの日本語入力ソフトを自力でWindowsにインストールする必要があります。もしくは全てEmacsLispで記述されているSKKが必要です。Emacs22はLeimパッケージとして日本語入力については標準でSKKを外国人向けに改造したものが付属しています。
上記の理由でEmacs22ではなく、Meadowの現在の開発版であるMeadow3をお勧めします。これはEmacs22にMeadowの拡張を加えたものです。

yokota (2008/05/02 03:20:47):

.emacsに設定するgoshのパスは絶対パスか環境変数PATHを使う方が良いです。 絶対パスを用いる場合はフォルダ名などに空白があると動作がおかしくなります。 インストール先が"Program Files"等の場合など空白が入る場合は"progra~1"等と空白が入らないものにする必要があります。 Meadow等はこのような事態を防ぐために標準設定では"c:\Meadow"など空白の無いフォルダにインストールしようとします。ただし、このようなインストール先の設定はWindowsの標準ではありません。

えんどう (2008/05/07 01:47:34):

インストール時に.emacsにgosh.exeのフルパスを埋め込むようにしました。

Post a comment

Name:

 rio sosh

Last modified : 2012/01/27 16:26:29 UTC