2009年11月26日木曜日

Emacsの設定(プログラミング)

.emacsを晒す(その2)

プログラミング関係の設定。

;;Compile C-c c
(define-key mode-specific-map "c" 'compile)
(define-key mode-specific-map "n" 'next-error)
(setq compilation-window-height 12)

;;gdb Emacsからはろくに使ってないけど。
(setq gdb-many-windows t)
(setq gdb-use-sepapate-io-buffer t)
(setq gdb-find-source-frame nil)

;;indent style for c
(add-hook 'c-mode-hook
'(lambda ()
(c-set-style "linux")
(setq c-basic-offset 2)
(setq tab-width c-basic-offset)))

;;indent style for c++
(add-hook 'c++-mode-hook
'(lambda ()
(c-set-style "linux")
(setq c-basic-offset 2)
(setq tab-width c-basic-offset)))

;; C# mode ほんの少しだけLinux(mono)で触ったので。
(add-hook 'csharp-mode-hook (lambda ()
(setq c-basic-offset 4
tab-width 4
indent-tabs-mode nil)))
(autoload 'csharp-mode "csharp-mode" "C# editing mode." t)
(nconc auto-mode-alist '(("\\.cs$" . csharp-mode)))

;;haskell-mode 一応GHCはインストールされてるけど使われてない。
(load "~/emacslib/haskell-mode-2.4/haskell-site-file")
(setq auto-mode-alist
(append auto-mode-alist
'(("\\.[hg]s$" . haskell-mode)
("\\.hi$" . haskell-mode)
("\\.l[hg]s$" . literate-haskell-mode))))
(autoload 'haskell-mode "haskell-mode"
"Major mode for editing Haskell scripts." t)
(autoload 'literate-haskell-mode "haskell-mode"
"Major mode for editing literate Haskell scripts." t)
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)
(add-hook 'haskell-mode-hook 'font-lock-mode)
(add-hook 'haskell-mode-hook 'imenu-add-menubar-index)
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-ghc)
(setq haskell-program-name "/usr/bin/ghci")


;;;;common lisp & slime
;;;;slimeは3.0アルファ(?)と書かれたリファレンスを見て設定した
(setq inferior-lisp-program "/usr/local/bin/sbcl")
(add-to-list 'load-path "/home/kurohuku/emacslib/slime/")
(add-to-list 'load-path "/home/kurohuku/emacslib/slime/contrib/")
(setq slime-backend (expand-file-name
"~/emacslib/slime/swank-loader.lisp"))
(setq slime-truncate-lines nil)
(setq slime-enable-evaluate-in-emacs t)
(setq inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))
(require 'slime)
(slime-setup '(inferior-slime slime-repl slime-c-p-c slime-xref-browser))
;; '(
;; inferior-slime
;; slime-asdf
;; slime-autodoc
;; slime-banner
;; slime-c-p-c
;; slime-editing-commands
;; slime-fancy-inspector
;; slime-fancy
;; slime-fuzzy
;; ; slime-highlight-edits
;; slime-parse
;; slime-presentation-streams
;; slime-presentations
;; slime-references
;; slime-scratch
;; slime-tramp
;; ; slime-typeout-frame
;; slime-xref-browser
;; ))
(setq slime-net-coding-system 'utf-8-unix)
(add-hook 'lisp-mode-hook (lambda ()
(slime-mode t)
(show-paren-mode t)
(global-set-key "\C-cH" 'hyperspec-lookup)))

;;slimeで日本語を使うための設定.Lisp側の対応も必要
(setq slime-net-coding-system 'utf-8-unix)

;;;;coreファイルから起動.起動時に自前の関数を定義するutil.lispを読み込む。
(setq slime-lisp-implementations
'((sbcl
("/usr/local/bin/sbcl"
"--core" "/home/kurohuku/emacslib/sbcl.core-with-swank")
:init (lambda (port-file _)
(format "(progn
(load \"/home/kurohuku/emacslib/util.lisp\")
(setf swank::*coding-system* \"utf-8-unix\")
(swank:start-server %S))\n" port-file))
:coding-system utf-8-unix)))

;;;slimeのインデントを変更
(add-hook 'slime-mode-hook
(lambda ()
(setq lisp-indent-function 'common-lisp-indent-function)))
;; Additional definitions by Pierpaolo Bernardi.
(defun cl-indent (sym indent)
(put sym 'common-lisp-indent-function
(if (symbolp indent)
(get indent 'common-lisp-indent-function)
indent)))
(cl-indent 'if '1)
(cl-indent 'generic-flet 'flet)
(cl-indent 'generic-labels 'labels)
(cl-indent 'with-accessors 'multiple-value-bind)
(cl-indent 'with-added-methods '((1 4 ((&whole 1))) (2 &body)))
(cl-indent 'with-condition-restarts '((1 4 ((&whole 1))) (2 &body)))
(cl-indent 'with-simple-restart '((1 4 ((&whole 1))) (2 &body)))

;;;HyperSpec
(require 'hyperspec)
(setq common-lisp-hyperspec-root
(concat "file://"
(expand-file-name "~/emacslib/HyperSpec/"))
common-lisp-hyperspec-symbol-table
(expand-file-name "~/emacslib/HyperSpec/Data/MapSym.txt"))
;; HyperSpecをw3mで見る
(defadvice common-lisp-hyperspec
(around hyperspec-lookup-w3m () activate)
(let* ((window-configuration (current-window-configuration))
(browse-url-browser-function
`(lambda (url new-window)
(w3m-browse-url url nil)
(let ((hs-map (copy-keymap w3m-mode-map)))
(define-key hs-map (kbd "q")
(lambda ()
(interactive)
(kill-buffer nil)
(set-window-configuration ,window-configuration)))
(use-local-map hs-map)))))
ad-do-it))

(add-hook 'inferior-lisp-mode-hook (lambda () (inferior-slime-mode t)))

色々な場所で調べたもののコピペばかりなはずだが、参考にしたものがどこにあるのかまでは覚えていない。

ただ、CommonLispの設定あたりが消え去ったらやる気が著しく削がれるのは間違いないのでメモメモ。

0 件のコメント:

コメントを投稿