読者です 読者をやめる 読者になる 読者になる

Gauche関連のメモ書き。

はてなブックマークで情報集めてたけど、一度outputしないと埋もれそうだったので備忘録化。

tips

今日学んだ関数。

(add-load-path "/path/to/dir/")
(load "some.scm")

GaucheEmacs

開発環境は整えないといけない。
EmacsでのGuacheキーバインドがまとめてあるサイト見つけた。

ひとまず今の私のemacs.el
~/.emacs.d/site-lisp/にはauto-completeが入ってる。

;load library                                                                                                                                
(setq load-path
      (append (list
               (expand-file-name "~/.emacs.d/site-lisp/")) load-path))

;~file go to backup-dir                                                                                                                      
(setq backup-dir "~/.emacs.d/backup/")
(setq backup-by-copying t)
(fset 'make-backup-file-name
      '(lambda (file) (concat (expand-file-name backup-dir)
                              (file-name-nondirectory file))))

;display transient-mark                                                                                                                      
(transient-mark-mode 1)

;display line-number                                                                                                                         
(line-number-mode t)

(setq-default tab-width 2)
(setq tab-width 2)
(setq-default tab-stop-list
  '(0 1 2 3 4 6 8 12 16 20))
(setq-default indent-tabs-mode nil)

;Show tab, zenkaku-space, white spaces at end of line                                                                                        
;; http://www.bookshelf.jp/soft/meadow_26.html#SEC317                                                                                        
(defface my-face-tab '((t (:background "Yellow"))) nil :group 'my-faces)
(defface my-face-zenkaku-spc '((t (:background "LightBlue")))
  nil :group 'my-faces)
(defface my-face-spc-at-eol '((t (:foreground "Red" :underline t)))
  nil :group 'my-faces)
(defvar my-face-tab 'my-face-tab)
(defvar my-face-zenkaku-spc 'my-face-zenkaku-spc)
(defvar my-face-spc-at-eol  'my-face-spc-at-eol)
(defadvice font-lock-mode (before my-font-lock-mode ())
  (font-lock-add-keywords
   major-mode
   '(("\t" 0 my-face-tab append)
     (" " 0 my-face-zenkaku-spc append)
     ("[ \t]+$" 0 my-face-spc-at-eol append)
     )))
(ad-enable-advice 'font-lock-mode 'before 'my-font-lock-mode)
(ad-activate 'font-lock-mode)

;settings for text file                                                                                                                      
(add-hook 'text-mode-hook
          '(lambda ()
             (progn
               (font-lock-mode t)
               (font-lock-fontify-buffer))))

;auto-complete                                                                                                                               
;;http://www.emacswiki.org/emacs/AutoComplete                                                                                                
(require 'auto-complete)
(global-auto-complete-mode t)

;gauche                                                                                                                                      
;;http://www.atmarkit.co.jp/fcoding/articles/gauche/02/gauche02c.html                                                                        
;;http://www.rokujyouhitoma.com/javapg/cat34/2008/12/                                                                                        

;; Gaucheのデフォルトエンコード                                                                                                              
(setq process-coding-system-alist
      (cons '("gosh" utf-8 . utf-8) process-coding-system-alist))
;; goshインタプリンタのパスに合わせる。-iは対話モードを意味する。                                                                            
;(setq scheme-program-name "/usr/local/bin/gosh -i")                                                                                         
(setq scheme-program-name "gosh-rl -i")

;; schemeモードとrun-schemeモードにcmuscheme.elを使用します。                                                                                
(autoload 'scheme-mode "cmuscheme" "Major mode for Scheme." t)
(autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process." t)

;; ウィンドウを2つに分け、一方でgoshインタプリタを実行するコマンドを定義する。                                                               
(defun scheme-other-window ()
  "Run scheme on other window"
  (interactive)
  (switch-to-buffer-other-window
   (get-buffer-create "*scheme*"))
  (run-scheme scheme-program-name))
;; そのコマンドをCtrl-csで呼び出す。                                                                                                         
(define-key global-map
  "\C-cs" 'scheme-other-window)

;; 直前/直簿の括弧に対応する括弧を点滅する                                                                                                   
(show-paren-mode)

;; 以下はインデントの定義                                                                                                                    
(put 'and-let* 'scheme-indent-function 1)
(put 'begin0 'scheme-indent-function 0)
(put 'call-with-client-socket 'scheme-indent-function 1)
(put 'call-with-input-conversion 'scheme-indent-function 1)
(put 'call-with-input-file 'scheme-indent-function 1)
(put 'call-with-input-process 'scheme-indent-function 1)
(put 'call-with-input-string 'scheme-indent-function 1)
(put 'call-with-iterator 'scheme-indent-function 1)
(put 'call-with-output-conversion 'scheme-indent-function 1)
(put 'call-with-output-file 'scheme-indent-function 1)
(put 'call-with-output-string 'scheme-indent-function 0)
(put 'call-with-temporary-file 'scheme-indent-function 1)
(put 'call-with-values 'scheme-indent-function 1)
(put 'dolist 'scheme-indent-function 1)
(put 'dotimes 'scheme-indent-function 1)
(put 'if-match 'scheme-indent-function 2)
(put 'let*-values 'scheme-indent-function 1)
(put 'let-args 'scheme-indent-function 2)
(put 'let-keywords* 'scheme-indent-function 2)
(put 'let-match 'scheme-indent-function 2)
(put 'let-optionals* 'scheme-indent-function 2)
(put 'let-syntax 'scheme-indent-function 1)
(put 'let-values 'scheme-indent-function 1)
(put 'let/cc 'scheme-indent-function 1)
(put 'let1 'scheme-indent-function 2)
(put 'letrec-syntax 'scheme-indent-function 1)
(put 'make 'scheme-indent-function 1)
(put 'multiple-value-bind 'scheme-indent-function 2)
(put 'match 'scheme-indent-function 1)
(put 'parameterize 'scheme-indent-function 1)
(put 'parse-options 'scheme-indent-function 1)
(put 'receive 'scheme-indent-function 2)
(put 'rxmatch-case 'scheme-indent-function 1)
(put 'rxmatch-cond 'scheme-indent-function 0)
(put 'rxmatch-if 'scheme-indent-function 2)
(put 'rxmatch-let 'scheme-indent-function 2)
(put 'syntax-rules 'scheme-indent-function 1)
(put 'unless 'scheme-indent-function 1)
(put 'until 'scheme-indent-function 1)
(put 'when 'scheme-indent-function 1)
(put 'while 'scheme-indent-function 1)
(put 'with-builder 'scheme-indent-function 1)
(put 'with-error-handler 'scheme-indent-function 0)
(put 'with-error-to-port 'scheme-indent-function 1)
(put 'with-input-convrsion 'scheme-indent-function 1)
(put 'with-input-from-port 'scheme-indent-function 1)
(put 'with-input-from-process 'scheme-indent-function 1)
(put 'with-input-from-string 'scheme-indent-function 1)
(put 'with-iterator 'scheme-indent-function 1)
(put 'with-module 'scheme-indent-function 1)
(put 'with-output-conversion 'scheme-indent-function 1)
(put 'with-output-to-port 'scheme-indent-function 1)
(put 'with-output-to-process 'scheme-indent-function 1)
(put 'with-output-to-string 'scheme-indent-function 1)
(put 'with-port-locking 'scheme-indent-function 1)
(put 'with-string-io 'scheme-indent-function 1)
(put 'with-time-counter 'scheme-indent-function 1)
(put 'with-signal-handlers 'scheme-indent-function 1)
(put 'with-locking-mutex 'scheme-indent-function 1)
(put 'guard 'scheme-indent-function 1)

;; gont-lockを有効化                                                                                                                         
(global-font-lock-mode t)

GaucheとC拡張

C,C++は書きたくないけど多言語APIを叩きたいので調べてる

GaucheRDBMS

データベースは大概のアプリケーションで必要になるでしょう。

古い関連記事