Created
February 6, 2010 03:12
-
-
Save handlename/296500 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(add-to-list 'load-path "~/.emacs.d/site-lisp/") | |
(add-to-list 'load-path "~/.emacs.d/site-lisp/yatex/") | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; general settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; | |
;; meta key | |
;;__________________________________________________________ | |
(setq ns-command-modifier (quote meta)) | |
(setq ns-alternate-modifier (quote super)) | |
;; | |
;; for carbon emacs | |
;;__________________________________________________________ | |
(if window-system (progn | |
(set-background-color "Black") | |
(set-foreground-color "LightGray") | |
(set-cursor-color "Red") | |
(set-frame-parameter nil 'alpha 80) | |
(set-face-attribute 'default nil | |
:family "M+2VM-IPAG circle" | |
:height 110) | |
(tool-bar-mode nil) | |
(setq initial-frame-alist | |
(append | |
'((top . 0) ; フレームの Y 位置(ピクセル数) | |
(left . 1) ; フレームの X 位置(ピクセル数) | |
(width . 180) ; フレーム幅(文字数) | |
(height . 50) ; フレーム高(文字数) | |
) initial-frame-alist)) | |
; (ns-toggle-fullscreen) | |
)) | |
;; | |
;; for cocoa emacs | |
;;__________________________________________________________ | |
(if (>= emacs-major-version 23) | |
(progn | |
(tool-bar-mode nil) | |
(set-default-font "Liberation Mono-12") | |
(set-fontset-font (frame-parameter nil 'font) | |
'japanese-jisx0208 | |
'("M+1P+IPAG" . "unicode-bmp")))) | |
;; | |
;; window setting | |
;;__________________________________________________________ | |
(setq scroll-step 1) | |
(setq truncate-partial-width-windows nil) | |
(set-scroll-bar-mode nil) | |
;(setq wb-line-number-scroll-bar t) | |
;; | |
;; silent | |
;;__________________________________________________________ | |
(setq visible-bell t) | |
;; | |
;; encoding | |
;;__________________________________________________________ | |
(set-language-environment "Japanese") | |
(prefer-coding-system 'utf-8-unix) | |
(setq default-buffer-file-coding-system 'utf-8) | |
(set-buffer-file-coding-system 'utf-8) | |
(set-terminal-coding-system 'utf-8) | |
(set-keyboard-coding-system 'utf-8) | |
(set-clipboard-coding-system 'utf-8) | |
;; | |
;; key bind | |
;;__________________________________________________________ | |
(global-set-key (kbd "C-h") 'backward-delete-char) | |
(global-set-key (kbd "C-/") 'undo) | |
(global-set-key (kbd "C-t") 'next-multiframe-window) | |
(global-set-key (kbd "C-M-t") 'previous-multiframe-window) | |
(global-set-key (kbd "M-r") 'replace-string) | |
(global-set-key (kbd "M-g") 'goto-line) | |
(global-set-key (kbd "C-m") 'newline-and-indent) | |
(global-set-key (kbd "M-<RET>") 'ns-toggle-fullscreen) | |
(global-set-key (kbd "C-c C-a") 'align) | |
(global-set-key (kbd "C-c a") 'align-regexp) | |
(global-set-key (kbd "C-c C-e" 'eval-last-sexp) | |
(global-set-key (kbd "C-c e") 'eval-region) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; additional functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; | |
;; iswitchb | |
;;__________________________________________________________ | |
(iswitchb-mode 1) | |
(add-hook 'iswitchb-define-mode-map-hook | |
(function (lambda () | |
(define-key iswitchb-mode-map (kbd "C-f") 'iswitchb-next-match) | |
(define-key iswitchb-mode-map (kbd "C-b") 'iswitchb-prev-match)))) | |
;; 切り替え中にバッファの内容を表示 | |
;; http://www.bookshelf.jp/soft/meadow_28.html#SEC369 | |
(defadvice iswitchb-exhibit | |
(after | |
iswitchb-exhibit-with-display-buffer | |
activate) | |
"選択している buffer を window に表示してみる。" | |
(when (and | |
(eq iswitchb-method iswitchb-default-method) | |
iswitchb-matches) | |
(select-window | |
(get-buffer-window (cadr (buffer-list)))) | |
(let ((iswitchb-method 'samewindow)) | |
(iswitchb-visit-buffer | |
(get-buffer (car iswitchb-matches)))) | |
(select-window (minibuffer-window)))) | |
;; バッファが存在しなければ find-file | |
;; http://www.bookshelf.jp/soft/meadow_28.html#SEC368 | |
(defun iswitchb-possible-new-buffer (buf) | |
"Possibly create and visit a new buffer called BUF." | |
(interactive) | |
(message (format | |
"No buffer matching `%s', " | |
buf)) | |
(sit-for 1) | |
(call-interactively 'find-file buf)) | |
(defun iswitchb-buffer (arg) | |
"Switch to another buffer. | |
The buffer name is selected interactively by typing a substring. The | |
buffer is displayed according to `iswitchb-default-method' -- the | |
default is to show it in the same window, unless it is already visible | |
in another frame. | |
For details of keybindings, do `\\[describe-function] iswitchb'." | |
(interactive "P") | |
(if arg | |
(call-interactively 'switch-to-buffer) | |
(setq iswitchb-method iswitchb-default-method) | |
(iswitchb))) | |
;; | |
;; highlight | |
;;__________________________________________________________ | |
;; highlight current line | |
(require 'highlight-current-line) | |
(highlight-current-line-on t) | |
(set-face-background 'highlight-current-line-face "#101015") | |
;; hilight paren | |
(show-paren-mode 1) | |
;; highlight reagion | |
(setq transient-mark-mode t) | |
;; highlight branks | |
(defface my-face-b-1 '((t (:background "bisque"))) nil) | |
(defvar my-face-b-1 'my-face-b-1) | |
(defadvice font-lock-mode (before my-font-lock-mode ()) | |
(font-lock-add-keywords | |
major-mode | |
'((" " 0 my-face-b-1 append) | |
))) | |
(ad-enable-advice 'font-lock-mode 'before 'my-font-lock-mode) | |
(ad-activate 'font-lock-mode) | |
;; | |
;; indent | |
;;__________________________________________________________ | |
(setq-default tab-width 4 indent-tabs-mode t) | |
;; | |
;; align | |
;;__________________________________________________________ | |
;; php-mode でも align | |
;; http://d.hatena.ne.jp/Tetsujin/20070614/1181757931 | |
(require 'align) | |
(add-to-list 'align-rules-list | |
'(php-assignment | |
(regexp . "[^-=!^&*+<>/.| \t\n]\\(\\s-*[.-=!^&*+<>/|]*\\)=>?\\(\\s-*\\)\\([^= \t\n]\\|$\\)") | |
(justify . t) | |
(tab-stop . nil) | |
(modes . '(php-mode)))) | |
(add-to-list 'align-dq-string-modes 'php-mode) | |
(add-to-list 'align-sq-string-modes 'php-mode) | |
(add-to-list 'align-open-comment-modes 'php-mode) | |
(setq align-region-separate (concat "\\(^\\s-*$\\)\\|" | |
"\\([({}\\(/\*\\)]$\\)\\|" | |
"\\(^\\s-*[)}\\(\*/\\)][,;]?$\\)\\|" | |
"\\(^\\s-*\\(}\\|for\\|while\\|if\\|else\\|" | |
"switch\\|case\\|break\\|continue\\|do\\)[ ;]\\)" | |
)) | |
;; | |
;; backup file | |
;;__________________________________________________________ | |
(defun make-backup-file-name (filename) | |
(expand-file-name | |
(concat "~/.backup/" (file-name-nondirectory filename) "~") | |
(file-name-directory filename))) | |
;; | |
;; kill-all-buffers | |
;;__________________________________________________________ | |
(require 'cl) | |
(defun kill-all-buffers () | |
(interactive) | |
(loop for buffer being the buffers | |
do (kill-buffer buffer))) | |
;; | |
;; miscellaneous | |
;;__________________________________________________________ | |
(column-number-mode t) | |
(global-linum-mode) | |
;; (setq truncate-lines t) | |
;; (setq truncate-partial-width-windows t) | |
;; インデント | |
(setq-default c-basic-offset 4) | |
(setq-default tab-width 4) | |
(setq cua-auto-tabify-rectangles nil) | |
(defadvice align (around smart-tabs activate) | |
(let ((indent-tabs-mode nil)) ad-do-it)) | |
(defadvice align-regexp (around smart-tabs activate) | |
(let ((indent-tabs-mode nil)) ad-do-it)) | |
(defadvice indent-relative (around smart-tabs activate) | |
(let ((indent-tabs-mode nil)) ad-do-it)) | |
(defadvice indent-according-to-mode (around smart-tabs activate) | |
(let ((indent-tabs-mode indent-tabs-mode)) | |
(if (memq indent-line-function | |
'(indent-relative | |
indent-relative-maybe)) | |
(setq indent-tabs-mode nil)) | |
ad-do-it)) | |
(defmacro smart-tabs-advice (function offset) | |
(defvaralias offset 'tab-width) | |
`(defadvice ,function (around smart-tabs activate) | |
(cond | |
(indent-tabs-mode | |
(save-excursion | |
(beginning-of-line) | |
(while (looking-at "\t*\\( +\\)\t+") | |
(replace-match "" nil nil nil 1))) | |
(setq tab-width tab-width) | |
(let ((tab-width fill-column) | |
(,offset fill-column)) | |
ad-do-it)) | |
(t | |
ad-do-it)))) | |
(smart-tabs-advice c-indent-line c-basic-offset) | |
(smart-tabs-advice c-indent-region c-basic-offset) | |
;; | |
;; speedbar | |
;;__________________________________________________________ | |
(defun my-speedbar-expand-line () | |
(interactive) | |
(if (= (point-max) (progn (speedbar-expand-line) (point-max))) | |
(save-current-buffer | |
(speedbar-edit-line)))) | |
(when (locate-library "speedbar") | |
(require 'speedbar) | |
;; "a" で無視ファイル表示/非表示のトグル | |
(define-key speedbar-file-key-map "a" 'speedbar-toggle-show-all-files) | |
;; ← や → でもディレクトリを開閉 ;;デフォルト: "=" "+", "-" | |
(define-key speedbar-file-key-map [right] 'my-speedbar-expand-line) | |
(define-key speedbar-file-key-map "\C-f" 'my-speedbar-expand-line) | |
(define-key speedbar-file-key-map [left] 'speedbar-contract-line) | |
(define-key speedbar-file-key-map "\C-b" 'speedbar-contract-line) | |
;; BS でも上位ディレクトリへ ;;デフォルト: "U" | |
(define-key speedbar-file-key-map [backspace] 'speedbar-up-directory) | |
(define-key speedbar-file-key-map "\C-h" 'speedbar-up-directory) | |
;; 起動位置を直接指定する | |
(setq speedbar-frame-parameters | |
(append (list '(top . 0) | |
'(left . 0) | |
'(width . 25)) | |
speedbar-frame-parameters)) | |
;; Speedbar で表示するファイルタイプ | |
(setq speedbar-supported-extension-expressions | |
(append '(".el" ".[ch]\\(pp\\|\\+\\+\\)?" ".java" ".tex\\(i\\(nfo\\)?\\)?" | |
".s?html?" ".xml" ".dtd" ".css" ".js" ".txt" | |
".gif" ".jpe?g" ".png"))) | |
) ;; end of speedbar | |
;; F5 で Speedbar | |
(global-set-key [f5] 'speedbar-get-focus) | |
;; | |
;; wb-line-number | |
;;__________________________________________________________ | |
;; (require 'wb-line-number) | |
;; (wb-line-number-toggle) | |
;; (setq wb-line-number-scroll-bar t) | |
;; ;; for use with yatex | |
;; (eval-after-load "yatexlib" | |
;; '(progn | |
;; (defadvice YaTeX-window-list | |
;; (after wb-line-number-adv-aft-YaTeX-window-list) | |
;; (let ((l ad-return-value)) | |
;; (while l | |
;; (and (window-dedicated-p (car l)) | |
;; (setq ad-return-value (delete (car l) ad-return-value))) | |
;; (setq l (cdr l))))) | |
;; (ad-enable-regexp "^wb-line-number-adv-aft-YaTeX-window-list") | |
;; (ad-activate-regexp "^wb-line-number-adv-aft-YaTeX-window-list"))) | |
;; | |
;; tabber | |
;;__________________________________________________________ | |
;; (when (require 'tabbar nil t) | |
;; (setq tabbar-buffer-groups-function | |
;; (lambda (b) (list "All Buffers"))) | |
;; (setq tabbar-buffer-list-function | |
;; (lambda () | |
;; (remove-if | |
;; (lambda(buffer) | |
;; (find (aref (buffer-name buffer) 0) " *")) | |
;; (buffer-list)))) | |
;; (tabbar-mode)) | |
;; ;; Ctrl-Tab, Ctrl-Shift-Tab でタブを切り替える | |
;; (dolist (func '(tabbar-mode tabbar-forward-tab tabbar-forward-group tabbar-backward-tab tabbar-backward-group)) | |
;; (autoload func "tabbar" "Tabs at the top of buffers and easy control-tab navigation")) | |
;; (defmacro defun-prefix-alt (name on-no-prefix on-prefix &optional do-always) | |
;; `(defun ,name (arg) | |
;; (interactive "P") | |
;; ,do-always | |
;; (if (equal nil arg) | |
;; ,on-no-prefix | |
;; ,on-prefix))) | |
;; (defun-prefix-alt shk-tabbar-next (tabbar-forward-tab) (tabbar-forward-group) (tabbar-mode 1)) | |
;; (defun-prefix-alt shk-tabbar-prev (tabbar-backward-tab) (tabbar-backward-group) (tabbar-mode 1)) | |
;; (global-set-key [(control tab)] 'shk-tabbar-next) | |
;; (global-set-key [(control shift tab)] 'shk-tabbar-prev) | |
;; ;; 外観変更 | |
;; (set-face-attribute | |
;; 'tabbar-default-face nil | |
;; :background "gray60") | |
;; (set-face-attribute | |
;; 'tabbar-unselected-face nil | |
;; :background "gray85" | |
;; :foreground "gray30" | |
;; :box nil) | |
;; (set-face-attribute | |
;; 'tabbar-selected-face nil | |
;; :background "#f2f2f6" | |
;; :foreground "black" | |
;; :box nil) | |
;; (set-face-attribute | |
;; 'tabbar-button-face nil | |
;; :box '(:line-width 1 :color "gray72" :style released-button)) | |
;; (set-face-attribute | |
;; 'tabbar-separator-face nil | |
;; :height 0.7) | |
;; ;; F4 で tabbar-mode | |
;; (global-set-key [f4] 'tabbar-mode) | |
;; | |
;; revive | |
;;__________________________________________________________ | |
(autoload 'save-current-configuration "revive" "Save status" t) | |
(autoload 'resume "revive" "Resume Emacs" t) | |
(autoload 'wipe "revive" "Wipe emacs" t) | |
(define-key ctl-x-map "S" 'save-current-configuration) ; C-x S で状態保存 | |
(define-key ctl-x-map "F" 'resume) ; C-x F で復元 | |
(add-hook 'kill-emacs-hook 'save-current-configuration) ; 終了時に状態保存 | |
;; | |
;; lispxmp | |
;;__________________________________________________________ | |
(require 'lispxmp) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; major mode settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; | |
;; shell-mode | |
;;__________________________________________________________ | |
(autoload 'ansi-color-for-comint-mode-on "ansi-color" | |
"Set `ansi-color-for-comint-mode' to t." t) | |
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on) | |
(add-hook 'shell-mode-hook | |
(function (lambda () | |
(define-key shell-mode-map [up] 'comint-previous-input) | |
(define-key shell-mode-map [down] 'comint-next-input)))) | |
;; | |
;; gdb | |
;;__________________________________________________________ | |
(add-hook 'gdb-mode-hook '(lambda () (gud-tooltip-mode t))) | |
;; | |
;; c++-mode | |
;;__________________________________________________________ | |
(setenv "CPLUS_INCLUDE_PATH" "/opt/local/include") | |
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)) | |
(add-hook 'c++-mode-hook | |
'(lambda () | |
(define-key mode-specific-map "c" 'compile) | |
(c-set-style "cc-mode"))) | |
;; | |
;; php-mode | |
;;__________________________________________________________ | |
(autoload 'php-mode "php-mode") | |
(setq auto-mode-alist | |
(cons '("\\.php\\'" . php-mode) auto-mode-alist)) | |
(setq php-mode-force-pear) | |
(add-hook 'php-mode-hook | |
'(lambda () | |
(setq php-manual-path "/usr/share/doc/php/html") | |
(setq php-search-url "http://www.phppro.jp/") | |
(setq php-manual-url "http://www.phppro.jp/phpmanual"))) | |
(add-hook 'php-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
(setq c-basic-offset 4))) | |
;; | |
;; Js2-mode | |
;;__________________________________________________________ | |
(autoload 'js2-mode "js2" nil t) | |
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode)) | |
;; (add-hook 'js2-mode-hook | |
;; '(lambda () | |
;; (setq tab-width 4) | |
;; (setq js2-basic-offset 4))) | |
;; (when (load "js2" t) | |
;; (defun indent-and-back-to-indentation () | |
;; (interactive) | |
;; (indent-for-tab-command) | |
;; (let ((point-of-indentation | |
;; (save-excursion | |
;; (back-to-indentation) | |
;; (point)))) | |
;; (skip-chars-forward "\s " point-of-indentation))) | |
;; (define-key js2-mode-map "\C-i" 'indent-and-back-to-indentation) | |
;; (define-key js2-mode-map "\C-m" nil)) | |
;; | |
;; objc-mode | |
;;__________________________________________________________ | |
(add-hook 'objc-mode-hook | |
'(lambda () | |
(setq tab-width 4) | |
(setq c-basic-offset 4))) | |
;; | |
;; lisp-mode | |
;;__________________________________________________________ | |
(add-hook 'lisp-mode | |
'(lambda () | |
(setq indent-tabs-mode nil))) | |
;; | |
;; emacs-lisp-mode | |
;;__________________________________________________________ | |
(add-hook 'emacs-lisp-mode | |
'(lambda () | |
(setq indent-tabs-mode nil))) | |
;; | |
;; smarty-mode | |
;;__________________________________________________________ | |
;; (setq load-path (append (list "/usr/local/share/lisp/") load-path)) | |
;; (autoload 'smarty-mode "smarty-mode" "Smarty Mode" t) | |
;; | |
;; yaml-mode | |
;;__________________________________________________________ | |
;; (require 'yaml-mode) | |
;; (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) | |
;; | |
;; yatex-mode | |
;;__________________________________________________________ | |
(setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) | |
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) | |
(setq tex-command "/opt/local/bin/platex") | |
(setq dvi2-command "/opt/local/bin/xdvi") | |
(setq YaTeX-kanji-code 4) ;; utf-8 | |
(add-hook 'yatex-mode-hook'(lambda ()(setq auto-fill-function nil))) | |
;; | |
;; yahtml-mode | |
;;__________________________________________________________ | |
(setq auto-mode-alist | |
(cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) | |
(autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) | |
(add-hook 'yahtml-mode-hook #'(lambda () (auto-fill-mode -1))) ; no indent | |
;; | |
;; org-mode | |
;;__________________________________________________________ | |
(require 'org-install) | |
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) | |
(define-key global-map "\C-cl" 'org-store-link) | |
(define-key global-map "\C-ca" 'org-agenda) | |
(add-hook 'org-mode-hook 'turn-on-font-lock) | |
;; | |
;; dsvn-mode | |
;;__________________________________________________________ | |
(autoload 'svn-status "dsvn" "Run `svn status'." t) | |
(autoload 'svn-update "dsvn" "Run `svn update'." t) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; minor mode settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; | |
;; auto complete | |
;;__________________________________________________________ | |
(require 'auto-complete) | |
(append '(yahtml-mode) ac-modes) | |
(global-auto-complete-mode t) | |
(define-key ac-complete-mode-map "\M-n" 'ac-next) | |
(define-key ac-complete-mode-map "\M-p" 'ac-previous) | |
;; ac-my-completion for auto-complete | |
(defun ac-my-completion-list-in-files (files &optional keywords-variable) | |
"create completion list for auto-complete" | |
(let ((ksymbol keywords-variable) keywords) | |
(cond | |
((stringp files) | |
(setq files (list files))) | |
((stringp keywords-variable) | |
(setq ksymbol (intern keywords-variable)))) | |
(if (not (boundp ksymbol)) | |
(progn | |
(dolist (file files) | |
(let ((buffer (find-file-noselect file)) filename) | |
(setq filename (file-name-nondirectory file)) | |
(with-current-buffer buffer | |
(rename-buffer | |
(concat " *" filename "*") t) | |
(if (< (buffer-size) 131072) ; 128Kb | |
(save-excursion | |
(goto-char (point-min)) | |
(while (re-search-forward "^[^;]\\(\\s_\\|\\sw\\)+\\b$" nil t) | |
(let ((candidate (match-string-no-properties 0))) | |
(if (not (member candidate keywords)) | |
(push candidate keywords)))) | |
(setq keywords (nreverse keywords))))))) | |
;; (sort keywords #'(lambda (a b) (> (length a) (length b)))) | |
(if ksymbol | |
(set-default ksymbol keywords)) | |
(message (concat "Building ac-source keywords(" (symbol-name ksymbol) ")...done.")) | |
keywords)))) | |
(defun ac-my-completion-files (files mode-name &optional set-hook) | |
"set completion list to mode-variable for auto-complete" | |
(lexical-let | |
((--ac-source (intern (concat "ac-source-" mode-name))) | |
(--ac-source-keywords (intern (concat "ac-source-" mode-name "-keywords"))) | |
(--mode-hook (intern (concat mode-name "-mode-hook"))) | |
(--files files)) | |
(set-default --ac-source | |
(list (cons 'candidates | |
(lambda () | |
(all-completions ac-prefix (symbol-value --ac-source-keywords)))))) | |
(if set-hook | |
(add-hook --mode-hook | |
(lambda() | |
(ac-my-completion-list-in-files --files --ac-source-keywords) | |
(make-local-variable 'ac-sources) | |
(setq ac-sources (append ac-sources (list --ac-source))))) | |
(ac-my-completion-list-in-files --files --ac-source-keywords)))) | |
;; 以下をモード毎に設定 | |
(ac-my-completion-files "~/.emacs.d/completions/javascript+DOM" "javascript" t) | |
(ac-my-completion-files "~/.emacs.d/completions/C" "c" t) | |
(ac-my-completion-files "~/.emacs.d/completions/C++" "c++" t) | |
(ac-my-completion-files "~/.emacs.d/completions/PHP" "php" t) | |
(ac-my-completion-files "~/.emacs.d/completions/TeX" "yatex" t) | |
(ac-my-completion-files "~/.emacs.d/completions/HTML" "yahtml" t) | |
(ac-my-completion-files "~/.emacs.d/completions/elisp" "emacs-lisp" t) | |
;; auto-complete-etags | |
(require 'auto-complete-etags) | |
;; | |
;; mmm-mode | |
;;_________________________________________________________ | |
(require 'mmm-mode) | |
(setq mmm-global-mode 'maybe) | |
(set-face-background 'mmm-default-submode-face "navy") | |
;; html + css | |
(mmm-add-classes | |
'((embedded-css | |
:submode css-mode | |
:front "<style[^>]*>" | |
:back "</style>"))) | |
(mmm-add-mode-ext-class nil "\\.html?\\'" 'embedded-css) | |
;; html + php | |
(mmm-add-classes | |
'((html-php | |
:submode php-mode | |
:front "<\\?\\(php\\)?" | |
:back "\\?>"))) | |
(mmm-add-mode-ext-class nil "\\.php?\\'" 'html-php) | |
;; | |
;; hs-minor-mode | |
;;__________________________________________________________ | |
;; http://www.emacswiki.org/emacs/HideShow | |
(defun toggle-selective-display (column) | |
(interactive "P") | |
(set-selective-display | |
(or column | |
(unless selective-display | |
(1+ (current-column)))))) | |
(defun toggle-hiding (column) | |
(interactive "P") | |
(if hs-minor-mode | |
(if (condition-case nil | |
(hs-toggle-hiding) | |
(error t)) | |
(hs-show-all)) | |
(toggle-selective-display column))) | |
(global-set-key (kbd "C-=") 'toggle-hiding) | |
(global-set-key (kbd "C-\\") 'toggle-selective-display) | |
(add-hook 'c-mode-common-hook 'hs-minor-mode) | |
(add-hook 'emacs-lisp-mode-hook 'hs-minor-mode) | |
(add-hook 'java-mode-hook 'hs-minor-mode) | |
(add-hook 'lisp-mode-hook 'hs-minor-mode) | |
(add-hook 'perl-mode-hook 'hs-minor-mode) | |
(add-hook 'sh-mode-hook 'hs-minor-mode) | |
;; | |
;; outline-miner-mode | |
;;__________________________________________________________ | |
(make-variable-buffer-local 'outline-level) | |
(setq-default outline-level 'outline-level) | |
(setq outline-minor-mode-prefix "\C-c\C-o") | |
;; for yatex-mode | |
(defun latex-outline-level () | |
(save-excursion | |
(looking-at outline-regexp) | |
(let ((title (buffer-substring (match-beginning 1) (match-end 1)))) | |
(cond ((equal (substring title 0 4) "docu") 15) | |
((equal (substring title 0 4) "chap") 0) | |
((equal (substring title 0 4) "appe") 0) | |
(t (length title)))))) | |
(add-hook 'yatex-mode-hook | |
(function | |
(lambda () | |
(progn | |
(setq outline-level 'latex-outline-level) | |
(setq outline-regexp | |
(concat "[ \t]*\\\\\\(documentstyle\\|documentclass\\|" | |
"chapter\\|section\\|subsection\\|subsubsection\\)" | |
"\\*?[ \t]*[[{]")))))) | |
;; | |
;; Flymake | |
;;__________________________________________________________ | |
(require 'flymake) | |
;; set-perl5lib | |
;; 開いたスクリプトのパスに応じて、@INCにlibを追加してくれる | |
;; 以下からダウンロードする必要あり | |
;; http://svn.coderepos.org/share/lang/elisp/set-perl5lib/set-perl5lib.el | |
(require 'set-perl5lib) | |
;; エラー、ワーニング時のフェイス | |
(set-face-background 'flymake-errline "red4") | |
(set-face-foreground 'flymake-errline "white") | |
(set-face-background 'flymake-warnline "yellow") | |
(set-face-foreground 'flymake-warnline "black") | |
;; エラーをミニバッファに表示 | |
;; http://d.hatena.ne.jp/xcezx/20080314/1205475020 | |
(defun flymake-display-err-minibuf () | |
"Displays the error/warning for the current line in the minibuffer" | |
(interactive) | |
(let* ((line-no (flymake-current-line-no)) | |
(line-err-info-list (nth 0 (flymake-find-err-info | |
flymake-err-info line-no))) | |
(count (length line-err-info-list))) | |
(while (> count 0) | |
(when line-err-info-list | |
(let* ((file (flymake-ler-file | |
(nth (1- count) line-err-info-list))) | |
(full-file (flymake-ler-full-file | |
(nth (1- count) line-err-info-list))) | |
(text (flymake-ler-text | |
(nth (1- count) line-err-info-list))) | |
(line (flymake-ler-line | |
(nth (1- count) line-err-info-list)))) | |
(message "[%s] %s" line text))) | |
(setq count (1- count))))) | |
(global-set-key "\C-cd" 'flymake-display-err-minibuf) | |
;; C++用設定 | |
;; http://d.hatena.ne.jp/suztomo/20080905/1220633281 | |
(defun flymake-cc-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list "g++" (list "-Wall" "-Wextra" "-fsyntax-only" local-file)))) | |
(defun flymake-cch-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list "g++" | |
(list "-Wall" "-Wextra" "-fsyntax-only" "-x c++-header" local-file)))) | |
(push '("\\.h$" flymake-cc-init) flymake-allowed-file-name-masks) | |
(push '("\\.cpp$" flymake-cc-init) flymake-allowed-file-name-masks) | |
(push '("\\.hpp$" flymake-cch-init) flymake-allowed-file-name-masks) | |
(add-hook 'c++-mode-hook | |
'(lambda () | |
(flymake-mode t))) | |
;; C用設定 | |
(defun flymake-c-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list "gcc" | |
(list "-Wall" "-Wextra" "-fsyntax-only" local-file)))) | |
(push '("\\.h$" flymake-cc-init) flymake-allowed-file-name-masks) | |
(push '("\\.c$" flymake-cc-init) flymake-allowed-file-name-masks) | |
(add-hook 'c-mode-hook | |
'(lambda () | |
(flymake-mode t))) | |
;; Perl用設定 | |
;; http://unknownplace.org/memo/2007/12/21#e001 | |
(defvar flymake-perl-err-line-patterns | |
'(("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1))) | |
(defconst flymake-allowed-perl-file-name-masks | |
'(("\\.pl$" flymake-perl-init) | |
("\\.pm$" flymake-perl-init) | |
("\\.t$" flymake-perl-init))) | |
(defun flymake-perl-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list "perl" (list "-wc" local-file)))) | |
(defun flymake-perl-load () | |
(interactive) | |
(defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted) | |
(setq flymake-check-was-interrupted t)) | |
(ad-activate 'flymake-post-syntax-check) | |
(setq flymake-allowed-file-name-masks | |
(append flymake-allowed-file-name-masks flymake-allowed-perl-file-name-masks)) | |
(setq flymake-err-line-patterns flymake-perl-err-line-patterns) | |
(set-perl5lib) | |
(flymake-mode t)) | |
(add-hook 'cperl-mode-hook 'flymake-perl-load) | |
;; PHP用設定 | |
;; http://openlab.dino.co.jp/2008/08/05/223548324.html | |
(when (require 'flymake nil t) | |
(when (not (fboundp 'flymake-php-init)) | |
;; flymake-php-initが未定義のバージョンだったら、自分で定義する | |
(defun flymake-php-init () | |
(let* | |
((temp-file | |
(flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) | |
(local-file | |
(file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list "php" (list "-f" local-file "-l")))) | |
(setq flymake-allowed-file-name-masks | |
(append | |
flymake-allowed-file-name-masks | |
'(("\\.php[345]?$" flymake-php-init)))) | |
(setq flymake-err-line-patterns | |
(cons | |
'("\\(\\(?:Parse error\\|Fatal error\\|Warning\\): .*\\) in \\(.*\\) on line \\([0-9]+\\)" 2 3 nil 1) | |
flymake-err-line-patterns)))) | |
;; | |
;; outputz-mode | |
;;__________________________________________________________ | |
;; (require 'outputz) | |
;; (setq outputz-key "GPOnHFYzkzJs") ;; 復活の呪文 | |
;; (setq outputz-uri "http://handlename.net/%s") ;; 適当なURL。%sにmajor-modeの名前が入るので、major-modeごとのURLで投稿できます。 | |
;; (global-outputz-mode t) | |
;; | |
;; hatenahelper-mode | |
;;__________________________________________________________ | |
(require 'hatenahelper-mode) | |
;(add-hook 'hatena-mode-hook 'hatenahelper-mode) ; 本当はこう | |
(add-hook 'hatena-mode-hook | |
'(lambda () | |
; other hooks must be wrote here! | |
(hatenahelper-mode 1))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment