2010年3月6日土曜日

【emacs】Carbon Emacsからのシステムパスの設定

システム非標準の領域にインストールしたコマンドをemacsのshellで実行するには,下記のように設定をする

(setq exec-path (cons "設定したいパス" exec-path))
(setenv "PATH"
(concat '"設定したいパス:" (getenv "PATH")))

これで,emacs上にシステムのパスが通る.
ちなみに,emacs上でcompile機能を使ってnvccを利用するにも
上記のようにパスを通す必要がある.

参考
http://journal.mycom.co.jp/column/osx/079/index.html

【emacs】設定

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;; 一般的な設定 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;PATHの設定
(setq exec-path (cons "/usr/local/cuda/bin:/usr/local/bin/:/Applications/yuta_app/pTeX.app/teTex/bin:/Applications/gnuplot.app:/Applications/gnuplot.app/bin:" exec-path))
(setenv "PATH"
(concat '"/usr/local/cuda/bin:/usr/local/bin/:/Applications/yuta_app/pTeX.app/teTex/bin:/Applications/gnuplot.app:/Applications/gnuplot.app/bin:" (getenv "PATH")))

;;loadを読み込ます
(load "~/.emacs.d/auto-complete.el")

;;auto-completeの設定
(require 'auto-complete)
(global-auto-complete-mode t)

;; スタートアップページを表示しない
;;(setq inhibit-startup-message t)
;;バックアップファイルを作成しない
;;(setq backup-inhibited t)

;; Macのキーバインドを使う。optionをメタキーにする。
(mac-key-mode 1)
(setq mac-option-modifier 'meta)
;; タブキー
(setq default-tab-width 4)
(setq indent-line-function 'indent-relative-maybe)

;;shift+矢印で領域確保
(setq pc-select-selection-keys-only t)
(pc-selection-mode 1)

;;画像ファイルを表示
(auto-image-file-mode t)
;;分割ウィンドウの移動
;;(windmove-default-keybindings)
;;(global-set-key [?\C-x up] (quote windmove-up))
;;(global-set-key [?\C-x down] (quote windmove-down))
;;(global-set-key [?\C-x right] (quote windmove-right))
;;(global-set-key [?\C-x left] (quote windmove-left))
(global-set-key "\C-xp" (lambda () (interactive)(other-window -1)))
;; ウィンドウ設定
(if window-system (progn
;;(setq initial-frame-alist '((width . 80) (height . 30) (top . 20)))
(set-background-color "Black")
(set-foreground-color "White")
(set-cursor-color "Gray")
))
;; ウィンドウを透明化
(add-to-list 'default-frame-alist '(alpha . (0.85 0.85)))
;; メニューバーを隠す
(tool-bar-mode -1)
(put 'set-goal-column 'disabled nil)
;; ツールバーを消す
;;(menu-bar-mode 0)

;;全画面にしたり戻したり
(defun my-mac-toggle-max-window()
(interactive)
(if (frame-parameter nil 'fullscreen)
(set-frame-parameter nil 'fullscreen nil)
(set-frame-parameter nil 'fullscreen 'fullboth)))
(global-set-key "\C-cm" 'my-mac-toggle-max-window)

;; C-c s で shell コマンドをよびだす
(define-key mode-specific-map "s" 'shell)
;; C-c b で buffer-menu コマンドを呼び出す
(define-key mode-specific-map "b" 'buffer-menu)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;; C言語,CUDAの設定 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; C-c c で compile コマンドを呼び出す
(define-key mode-specific-map "c" 'compile)
;; C-c v で recompile コマンドを呼び出す
(define-key mode-specific-map "v" 'recompile)

;; for CUDA Program
(setq auto-mode-alist
(cons (cons "\\.cu$" 'c++-mode) auto-mode-alist))
(setq auto-mode-alist
(cons (cons "\\.cuh$" 'c++-mode) auto-mode-alist))

;;自動インデント設定
(add-hook 'c-mode-common-hook
'(lambda ()
;; センテンスの終了である ';' を入力したら、自動改行+インデント
;;(c-toggle-auto-hungry-state 1)
;; RET キーで自動改行+インデント
;;(define-key c-mode-base-map "\C-m" 'newline-and-indent)
))




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;; タグジャンプの設定の設定 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;(load "~/.emacs.d/gtags.el")
(define-key mode-specific-map "f" 'find-tag)
)
;;タグジャンプの設定(M-x find-tag(etags)コマンドによるタグジャンプ)
;;自動でTAGSファイルを生成してくれる
(defadvice find-tag (before c-tag-file activate)
"Automatically create tags file."
(let ((tag-file (concat default-directory "TAGS")))
(unless (file-exists-p tag-file)
(shell-command "etags *.[ch] *.el .*.el -o TAGS 2>/dev/null"))
(visit-tags-table tag-file)))

;;Gtagsによるタグジャンプ
;;(autoload 'gtags-mode "gtags" "" t)
;;(setq gtags-mode-hook
;; '(lambda ()
;; (local-set-key "\M-t" 'gtags-find-tag);;関数の定義元へ移動
;; (local-set-key "\M-r" 'gtags-find-rtag);;関数を参照元の一覧を表示 enterでジャンプ 
;; (local-set-key "\M-s" 'gtags-find-symbol);;変数の定義元と参照元の一覧を表示 enterでジャンプ
;; (local-set-key "\C-t" 'gtags-pop-stack);;前のバッファへ戻る
;; ))