Created
November 26, 2009 00:28
-
-
Save handlename/243121 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/") | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; general settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; | |
;; for carbon emacs | |
;; | |
(if window-system (progn | |
(set-background-color "Black") | |
(set-foreground-color "LightGray") | |
(set-cursor-color "Red") | |
(set-frame-parameter nil 'alpha 70) | |
(set-face-attribute 'default nil | |
:family "M+2VM-IPAG circle" | |
:height 100) | |
(tool-bar-mode nil) | |
(setq initial-frame-alist | |
(append | |
'((top . 0) ; フレームの Y 位置(ピクセル数) | |
(left . 1) ; フレームの X 位置(ピクセル数) | |
(width . 210) ; フレーム幅(文字数) | |
(height . 58) ; フレーム高(文字数) | |
) initial-frame-alist)) | |
)) | |
;; | |
;; window setting | |
;; | |
(setq scroll-step 1) | |
(setq truncate-partial-width-windows nil) | |
(set-scroll-bar-mode nil) | |
(setq wb-line-number-scroll-bar 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; make C-h as Backspace | |
(global-set-key "\C-h" 'backward-delete-char) | |
;; make Ctrl-\ as undo | |
(global-set-key "\C-\\" 'undo) | |
;; make C-x p as previous-multiframe-window | |
(global-set-key "\C-xp" 'previous-multiframe-window) | |
;; make C-c c as comment-region | |
(global-set-key "\C-c\C-c" 'comment-or-uncomment-region) | |
;; show column number | |
(column-number-mode t) | |
;; make Alt-r as replace-string | |
(global-set-key "\M-r" 'replace-string) | |
;; make Alt-g as goto-line | |
(global-set-key "\M-g" 'goto-line) | |
;; 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) | |
;; | |
;; Use spaces instead of tabs | |
;; | |
(setq-default tab-width 4) | |
;; | |
;; Use C-m as newline-and-indent | |
;; | |
(global-set-key "\C-m" 'newline-and-indent) | |
;; | |
;; backup file | |
;; | |
(defun make-backup-file-name (filename) | |
(expand-file-name | |
(concat "~/.backup/" (file-name-nondirectory filename) "~") | |
(file-name-directory filename))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; additional functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; | |
;; 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) ; 終了時に状態保存 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; major mode settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; | |
;; c-mode | |
;; | |
(define-key mode-specific-map "c" 'compile) | |
;; | |
;; 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 "platex") | |
(setq dvi2-command "mxdvi") | |
(setq YaTeX-kanji-code 4) ;; utf-8 | |
;; | |
;; 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 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; minor mode settings ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; | |
;; auto complete | |
;; | |
(require 'auto-complete) | |
(global-auto-complete-mode t) | |
(define-key ac-complete-mode-map "\C-n" 'ac-next) | |
(define-key ac-complete-mode-map "\C-p" 'ac-previous) | |
;; | |
;; 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) | |
;; 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) | |
;; (require 'flymake) | |
;; (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)))) | |
;; (push '("\\.cc$" flymake-cc-init) flymake-allowed-file-name-masks) | |
;; (add-hook 'c++-mode-hook | |
;; '(lambda () | |
;; (flymake-mode t))) | |
;; (when (require 'flymake nil t) | |
;; (global-set-key "\C-cd" 'flymake-display-err-menu-for-current-line) | |
;; ;; PHP用設定 | |
;; (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))) | |
;; ;; JavaScript用設定 | |
;; (when (not (fboundp 'flymake-javascript-init)) | |
;; ;; flymake-javascript-initが未定義のバージョンだったら、自分で定義する | |
;; (defun flymake-javascript-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 "js" (list "-s" local-file)) | |
;; (list "jsl" (list "-process" local-file)) | |
;; )) | |
;; (setq flymake-allowed-file-name-masks | |
;; (append | |
;; flymake-allowed-file-name-masks | |
;; '(("\\.json$" flymake-javascript-init) | |
;; ("\\.js$" flymake-javascript-init)))) | |
;; (setq flymake-err-line-patterns | |
;; (cons | |
;; '("\\(.+\\)(\\([0-9]+\\)): \\(?:lint \\)?\\(\\(?:warning\\|SyntaxError\\):.+\\)" 1 2 nil 3) | |
;; flymake-err-line-patterns))) | |
;; (add-hook 'php-mode-hook | |
;; '(lambda() (flymake-mode t))) | |
;; (add-hook 'javascript-mode-hook | |
;; '(lambda() (flymake-mode t)))) | |
;; ;; エラーメッセージをミニバッファで | |
;; (defun credmp/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))))) | |
;; | |
;; outputz-mode | |
;; | |
(require 'outputz) | |
(setq outputz-key "##########") ;; 復活の呪文 | |
(setq outputz-uri "http://handlename.net/%s") ;; 適当なURL。%sにmajor-modeの名前が入るので、major-modeごとのURLで投稿できます。 | |
(global-outputz-mode t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment