Created
January 11, 2012 08:48
-
-
Save shishi/1593775 to your computer and use it in GitHub Desktop.
init.el basic part
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
;; basic settings | |
;; =============================================================================== | |
;; 日本語設定 (UTF-8) | |
(set-language-environment "Japanese") | |
(prefer-coding-system 'utf-8-unix) | |
(set-default-coding-systems 'utf-8-unix) | |
(set-terminal-coding-system 'utf-8-unix) | |
(set-keyboard-coding-system 'utf-8-unix) | |
(set-clipboard-coding-system 'utf-8-unix) | |
;; (setq default-file-name-coding-system 'utf-8-unix) | |
;; (setq default-buffer-file-coding-system 'utf-8-unix) | |
(set-buffer-file-coding-system 'utf-8-unix) | |
;; 一時マークモードの自動有効化 | |
(setq-default transient-mark-mode t) | |
;; emacs-server起動 | |
;; (if window-system (server-start)) | |
;; 行番号表示 | |
(global-linum-mode t) | |
;; 行、カラム番号をモードラインに表示 | |
(line-number-mode t); | |
(column-number-mode t); | |
;; tabの代わりにスペースでインデント | |
(setq-default indent-tabs-mode nil) | |
(setq indent-tabs-mode nil) | |
;; tab幅4 | |
(setq-default tab-width 4) | |
(setq tab-width 4) | |
;; 改行コードを表示 | |
;; (setq eol-mnemonic-dos "(CRLF)") | |
;; (setq eol-mnemonic-mac "(CR)") | |
;; (setq eol-mnemonic-unix "(LF)") | |
;; フォントロックモード (強調表示等) を有効にする | |
(global-font-lock-mode t) | |
;; 括弧の対応をハイライト. | |
(show-paren-mode t) | |
(setq show-paren-style 'mixed) | |
(set-face-background 'show-paren-match-face "purple") | |
(set-face-foreground 'show-paren-match-face nil) | |
;; 現在行を目立たせる | |
(global-hl-line-mode t) | |
(setq hl-line-face 'underline) | |
;; 行末の空白を強調させる | |
(setq-default show-trailing-whitespace t) | |
;; 見た目を変える | |
;;(set-face-background 'trailing-whitespace "blue") | |
;;(set-face-underline 'trailing-whitespace t) | |
;; 行末の空白を削除 | |
(add-hook 'before-save-hook 'delete-trailing-whitespace) | |
;; find-file で大文字小文字を区別しない | |
(setq completion-ignore-case t) | |
(setq read-file-name-completion-ignore-case t) | |
;; 部分一致の補完機能を使う | |
;; p-bでprint-bufferとか | |
(partial-completion-mode t) | |
;; mini buffer の履歴を保存する | |
(savehist-mode t) | |
;; mini buffer の履歴数 | |
(setq history-length 100) | |
;; 最近開いたファイルを保存する数 | |
(setq recentf-max-saved-items 500) | |
;; C-kで行全体を削除 | |
(setq kill-whole-line t) | |
;; BSで選択範囲を消す | |
(delete-selection-mode t) | |
;; imenu rescan | |
(setq imenu-auto-rescan t) | |
;; The local variables list in .emacs と言われるのを抑止 | |
(add-to-list 'ignored-local-variables 'syntax) | |
;; gzファイルも編集できるようにする | |
(auto-compression-mode t) | |
;; D&Dでファイルオープン | |
(define-key global-map [ns-drag-file] 'ns-find-file) | |
;; ウィンドウ透過度 | |
;;(set-frame-parameter (selected-frame) 'alpha '(95 95)) | |
;; メニューバーを消す | |
;; (menu-bar-mode -1) | |
;; 時間を表示 | |
;; (display-time) | |
;; skelton-pair | |
(global-set-key (kbd "(") 'skeleton-pair-insert-maybe) | |
(global-set-key (kbd "{") 'skeleton-pair-insert-maybe) | |
(global-set-key (kbd "[") 'skeleton-pair-insert-maybe) | |
(global-set-key (kbd "\"") 'skeleton-pair-insert-maybe) | |
(global-set-key (kbd "\'") 'skeleton-pair-insert-maybe) | |
(setq skeleton-pair t) | |
;; abbrev-mode | |
(setq-default abbrev-mode t) | |
(read-abbrev-file "~/.emacs.d/abbrev_defs") | |
(setq save-abbrevs t) | |
;; cua mode | |
;; (cua-mode t) | |
;; (setq cua-enable-cua-keys nil) | |
;; (setq cua-mode-normal-cursor-color "white") | |
;; (setq cua-mode-overwrite-cursor-color "red") | |
;; (setq cua-mode-read-only-cursor-color "green") | |
;; 削除ファイルをゴミ箱へ | |
(setq trash-directory "~/.emacs.d/.trash") | |
(setq delete-by-moving-to-trash t) | |
;; バックアップファイルの保存場所を変更 | |
(setq backup-directory "~/.emacs.d/.bak") | |
(if (and (boundp 'backup-directory) | |
(not (fboundp 'make-backup-file-name-original))) | |
(progn | |
(fset 'make-backup-file-name-original | |
(symbol-function 'make-backup-file-name)) | |
(defun make-backup-file-name (filename) | |
(if (file-directory-p backup-directory) | |
(concat backup-directory "/" (file-name-nondirectory filename)) | |
(make-backup-file-name-original filename))))) | |
;; 自分以外の所有のファイルを sudo で開き直す | |
(defun file-root-p (filename) | |
"Return t if file FILENAME created by root." | |
(eq 0 (nth 2 (file-attributes filename)))) | |
(defun th-rename-tramp-buffer () | |
(when (file-remote-p (buffer-file-name)) | |
(rename-buffer | |
(format "%s:%s" | |
(file-remote-p (buffer-file-name) 'method) | |
(buffer-name))))) | |
(add-hook 'find-file-hook | |
'th-rename-tramp-buffer) | |
(defadvice find-file (around th-find-file activate) | |
"Open FILENAME using tramp's sudo method if it's read-only." | |
(if (and (file-root-p (ad-get-arg 0)) | |
(not (file-writable-p (ad-get-arg 0))) | |
(y-or-n-p (concat "File " | |
(ad-get-arg 0) | |
" is read-only. Open it as root? "))) | |
(th-find-file-sudo (ad-get-arg 0)) | |
ad-do-it)) | |
(defun th-find-file-sudo (file) | |
"Opens FILE with root privileges." | |
(interactive "F") | |
(set-buffer (find-file (concat "/sudo::" file)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment