Emacs で Scheme (Gauche)する設定

(quack とか auto-complete とか scheme-complete とか他にもいくつか必要かもしれないので、このままコピペしても動かないと思いますが)
;; ********************************************************************
;;  scheme
;; ********************************************************************

;; (defvar gauche-program-path "~/../gauche/bin/gosh")
(defvar gauche-program-path "~/../cygwin/usr/local/bin/gosh")
(defvar gauche-program-params
  (apply #'concat (intersperse " "
                                 ;; "-I" ,(expand-file-name "~/../gauche/liv")
                                 ;; "-I" ,(expand-file-name "~/../gauche/other")
                                 ;; "-u" "liv.init"

;; scheme-mode-hook
(defvar ac-source-scheme
     . (lambda ()
         (require 'scheme-complete)
         (all-completions ac-target (car (scheme-current-env)))))))

(add-hook 'scheme-mode-hook
          '(lambda ()
             (make-local-variable 'ac-sources)
             (setq ac-sources (append ac-sources '(ac-source-scheme)))))

(defun gauche-info-index (topic)
   (list (read-string
          (concat "Gauche help topic : ")
  (get-buffer-create "*info*")
  (info "gauche-refj.info")
  (Info-index topic))

(define-key global-map "\C-xH" 'gauche-info-index)

(setq process-coding-system-alist
      (cons '("gosh" utf-8 . utf-8) process-coding-system-alist))

(autoload 'scheme-mode "cmuscheme" "Major mode for Scheme." t)
(autoload 'run-scheme "cmuscheme" "Run an inferior Scheme process." t)

    (defun scheme-args-to-list (string)
      (if (string= string "") nil
        (let ((where (string-match "[ \t]" string)))
          (cond ((null where) (list string))
                ((not (= where 0))
                 (let ((qpos (string-match "^\"\\([^\"]*\\)\"" string)))
                   (if (null qpos)
                       (cons (substring string 0 where)
                              (substring string (+ 1 where)
                                         (length string))))
                     (cons (substring string
                                      (match-beginning 1)
                                      (match-end 1))
                            (substring string
                                       (match-end 0)
                                       (length string)))))))
                (t (let ((pos (string-match "[^ \t]" string)))
                     (if (null pos)
                        (substring string pos
                                   (length string))))))))))))

(setq gauche-program-name
      (apply #'concat
             (intersperse " "

;; split window
(defun scheme-other-window ()
  "Run Gauche on other window"
  (setq scheme-program-name gauche-program-name)
  (split-window-horizontally 90)
  (let ((buf-name (buffer-name (current-buffer))))
     (get-buffer-create "*scheme*"))
    (run-scheme scheme-program-name)
     (get-buffer-create buf-name))))

;; indent settings
(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-conversion '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)

;; scheme-mode
(autoload 'scheme-smart-complete "scheme-complete" nil t)
(eval-after-load 'scheme
  '(progn (define-key scheme-mode-map "\t" 'scheme-complete-or-indent)))
(autoload 'scheme-get-current-symbol-info "scheme-complete" nil t)
(add-hook 'scheme-mode-hook
          (lambda ()
            (make-local-variable 'eldoc-documentation-function)
            (setq eldoc-documentation-function 'scheme-get-current-symbol-info)
            (eldoc-mode t)
            (setq lisp-indent-function 'scheme-smart-indent-function)))

;; ********************************************************************
;;  quak.el
;; ********************************************************************

;; C-c C-q m   View a manual in your Web browser.
;; C-c C-q k   View the manual documentation for a keyword
;;             (currently only works for PLT manuals).
;; C-c C-q s   View an SRFI.
;; C-c C-q r   Run an inferior Scheme process.
;; C-c C-q f   Find a file using context of point for default.
;; C-c C-q l   Toggle `lambda' syntax of `define'-like form.
;; C-c C-q t   Tidy the formatting of the buffer.

;;(load "unparen")
(load "quack")
(setq quack-remap-find-file-bindings-p nil)
(setq quack-pltish-keywords-to-fontify
      (append '("let1" "rlet1" "if-let1" "and-let*" "let/cc"
                "use" "export" "export-all" "extend" "select-module"
                "guard" "error" "apply"
                "^" "^_" "^a" "^b" "^c" "^d" "^e" "^f" "^g"
                "^h" "^i" "^j" "^k" "^l" "^m" "^n" "^o" "^p"
                "^q" "^r" "^s" "^t" "^u" "^v" "^w" "^x" "^y" "^z")
 '(quack-default-program gauche-program-name)
 '(quack-fontify-style 'plt)
 '(quack-pretty-lambda-p t)
 '(quack-programs '("/server:hoge@foo.org#1234:/usr/local/bin/gosh" "gauche" "gosh" "guile" "ironscheme.console.exe" "mit-scheme" "mzscheme" "mzscheme3m" "mzschemecgc" "scheme" ))
 '(quack-run-scheme-always-prompts-p t)
 '(quack-smart-open-paren-p nil))

;; custom faces
;; quack-pltish-comment-face
;; quack-pltish-selfeval-face
;; quack-pltish-paren-face
;; quack-banner-face
;; quack-pltish-class-defn-face
;; quack-pltish-module-defn-face
;; quack-pltish-keyword-face
;; quack-threesemi-h2-face
;; quack-threesemi-h3-face
;; quack-pltfile-prologue-face
;; quack-pltfile-dir-face
;; quack-pltfile-file-face
;; quack-about-title-face
;; quack-about-face
;; quack-smallprint-face
 '(quack-pltish-defn-face ((t (:bold t :foreground "darkgoldenrod3"))))
 '(quack-pltish-keyword-face ((t (:bold t :foreground "maroon2"))))
 '(quack-threesemi-semi-face ((t (:bold t :foreground "blue1"))))
 '(quack-threesemi-text-face ((t (:bold t :foreground "royalblue2")))))

(define-key global-map
  "\C-cG" 'scheme-other-window)

プログラミングGauche に載っている設定をベースにしたような記憶があります。


gauche-mode というのもいくつかあるそうで。


0 件のコメント: