Emacs の初期設定
init.elのとりまとめ.
今はダッシュのメモ書きなので,このスペースはinit.elのための落書き帳としてます.
参考にしたサイトは以下のとおり.
- Youhei SASAKI's official site: Emacsの設定 - 主に org ファイルの読み込み集 uwabamiさんの公式サイトより
- うわっ...私のEmacs、使いにくすぎ?だったら...カスタマイズシヤッセー!!ダァダァシエリイェッスッシェーショーヘイヘイ!!! - 三等兵
両者共にわかりやすいですが,uwabamiさんのサイトは特にわかりやすい.
今度時間があるときにでも,もっとよく読んで理解をしていきます.
ひとまず,私は以下のとおりに設定している.
; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*- ;; ------------------------------------------------------------------------ ;; @ load-path ;; load-pathの追加関数 (defun add-to-load-path (&rest paths) (let (path) (dolist (path paths paths) (let ((default-directory (expand-file-name (concat user-emacs-directory path)))) (add-to-list 'load-path default-directory) (if (fboundp 'normal-top-level-add-subdirs-to-load-path) (normal-top-level-add-subdirs-to-load-path)))))) ;; load-pathに追加するフォルダ ;; 2つ以上フォルダを指定する場合の引数 => (add-to-load-path "elisp" "xxx" "xxx") ;;(add-to-load-path "elisp" "C:\MySystem\MySystem\emacs\lisp") (add-to-load-path "C:/MySystem/MySystem/emacs/elisp") (add-to-load-path "elisp") (add-to-load-path "elpa") (add-to-load-path "lisp") (add-to-load-path "site-lisp") (add-to-load-path ".emacs") ;; ------------------------------------------------------------------------ ;; @ general ;; common lisp (require 'cl) ;; 文字コード (set-language-environment "Japanese") (let ((ws window-system)) (cond ((eq ws 'w32) (prefer-coding-system 'utf-8-unix) (set-default-coding-systems 'utf-8-unix) (setq file-name-coding-system 'sjis) (setq locale-coding-system 'utf-8)) ((eq ws 'ns) (require 'ucs-normalize) (prefer-coding-system 'utf-8-hfs) (setq file-name-coding-system 'utf-8-hfs) (setq locale-coding-system 'utf-8-hfs)))) ;; Windowsで英数と日本語にMeiryoを指定 ;; Macで英数と日本語にRictyを指定 (let ((ws window-system)) (cond ((eq ws 'w32) (set-face-attribute 'default nil :family "Meiryo" ;; 英数 :height 100) (set-fontset-font nil 'japanese-jisx0208 (font-spec :family "Meiryo"))) ;; 日本語 ((eq ws 'ns) (set-face-attribute 'default nil :family "Ricty" ;; 英数 :height 140) (set-fontset-font nil 'japanese-jisx0208 (font-spec :family "Ricty"))))) ;; 日本語 ;======================================================================= ;フレームサイズ・位置・色など ;======================================================================= (setq default-frame-alist (append (list '(foreground-color . "black") '(background-color . "LemonChiffon") '(background-color . "gray") '(border-color . "black") '(alpha . (85 40)) '(mouse-color . "white") '(cursor-color . "black") '(font . "fontset-メイリオ") '(width . 100) ;文字数 '(height . 100) ;文字数 '(top . 100) ;pixel値 表示位置 '(left . 100)) default-frame-alist)) ;; スタートアップ非表示 (setq inhibit-startup-screen t) ;; scratchの初期メッセージ消去 (setq initial-scratch-message "") ;; ツールバー非表示 (tool-bar-mode -1) ;; メニューバーを非表示 ;;(menu-bar-mode -1) ;; スクロールバー非表示 (set-scroll-bar-mode nil) ;; タイトルバーにファイルのフルパス表示 (setq frame-title-format (format "%%f - Emacs@%s" (system-name))) ;; 行番号表示 (global-linum-mode t) (set-face-attribute 'linum nil :foreground "#800" :height 0.9) ;; 行番号フォーマット (setq linum-format "%4d") ;;; 対応する括弧を光らせる。 (show-paren-mode 1) ;;; ウィンドウ内に収まらないときだけ括弧内も光らせる。 (setq show-paren-style 'mixed) ;;; 現在行を目立たせる (global-hl-line-mode) ;;; カーソルの位置が何文字目かを表示する (column-number-mode t) ;;; カーソルの位置が何行目かを表示する (line-number-mode t) ;; 行末の空白を強調表示 (setq-default show-trailing-whitespace t) (set-face-background 'trailing-whitespace "#b14770") ;; タブをスペースで扱う (setq-default indent-tabs-mode nil) ;; タブ幅 (custom-set-variables '(tab-width 4)) ;; yes or noをy or n (fset 'yes-or-no-p 'y-or-n-p) ;; ミニバッファの履歴を保存する (savehist-mode 1) ;; ミニバッファの履歴の保存数を増やす (setq history-length 3000) ;; 行間 ;(setq-default line-spacing 0 ;; 1行ずつスクロール (setq scroll-conservatively 35 scroll-margin 0 scroll-step 1) (setq comint-scroll-show-maximum-output t) ;; shell-mode ;; フレームの透明度 (set-frame-parameter (selected-frame) 'alpha '(0.85)) ;; http://www.gentei.org/~yuuji/software/euc/instamp.el ;; 現在時刻挿入 (setq display-time-string-forms '(year "/" month "/" day " " dayname " " 24-hours ":" minutes " " (if mail " Mail" ""))) (display-time) ;; M-wやC-kでコピーしたものを、他のアプルケーションで貼り付け可能にする (cond (window-system (setq x-select-enable-clipboard t) )) ;;自動スペルチェック (add-to-list 'exec-path "C:/MySystem/MySystem/emacs/Aspell/bin") (setq-default ispell-program-name "aspell") ;;プログラムが起動したら,自動でスペルチェックを起動 (eval-after-load "ispell" '(add-to-list 'ispell-skip-region-alist '("[^\000-\377]+"))) ; flyspell-mode (mapc (lambda (hook) (add-hook hook 'flyspell-prog-mode)) ;;ここではコメントの領域におけるスペルチェック '( c-mode-common-hook emacs-lisp-mode-hook )) (defun my-flyspell-mode-enable () (flyspell-mode 1)) (mapc (lambda (hook) (add-hook hook 'my-flyspell-mode-enable)) ;;ここではファイル全体そのものにスペルチェック '( changelog-mode-hook debian-control-mode-hook tex-mode-hoo yatex-mode-hook text-mode-hook )) ;;auto-complete ;(add-to-list 'load-path "~/.emacs.d/site-lisp") ;(require 'auto-complete-config) ;(add-to-list 'ac-dictionary-directories "~/.emacs.d/site-lisp/ac-dict") ;(ac-config-default) ;; ;; ;; ------------------------------------------------------------------------ ;; @ modeline ;; モードラインの割合表示を総行数表示 (defvar my-lines-page-mode t) (defvar my-mode-line-format) (when my-lines-page-mode (setq my-mode-line-format "%d") (if size-indication-mode (setq my-mode-line-format (concat my-mode-line-format " of %%I"))) (cond ((and (eq line-number-mode t) (eq column-number-mode t)) (setq my-mode-line-format (concat my-mode-line-format " (%%l,%%c)"))) ((eq line-number-mode t) (setq my-mode-line-format (concat my-mode-line-format " L%%l"))) ((eq column-number-mode t) (setq my-mode-line-format (concat my-mode-line-format " C%%c")))) (setq mode-line-position '(:eval (format my-mode-line-format (count-lines (point-max) (point-min)))))) ;; モードラインに行番号表示 ;(line-number-mode t) ;; モードラインに列番号表示 ;(column-number-mode t) ;;;;;;;;;;;;;;;;;Lispの設定;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;auto-install (add-to-list 'load-path (expand-file-name "~/.emacs.d/auto-install/")) (require 'auto-install) (auto-install-update-emacswiki-package-name t) (auto-install-compatibility-setup) ;; ------------------------------------------------------------------------ ;; @ menu-tree.el ;; メニューバー日本語化 ;; http://www11.atwiki.jp/s-irie/pages/13.html (if (and (= emacs-major-version 22) (eq window-system 'x)) (setq menu-tree-coding-system 'utf-8)) (require 'menu-tree nil t) ;;;;;;;;;;;;;;;;;;;;;;;; ;;====================================================================== ;; TeX ;;====================================================================== ; YaTeX-mode (setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) (setq load-path (cons "~/.emacs.d/yatex" load-path)) ;;ココにyatexのパス書く (setq tex-command "platex") (setq dvi2-command "C:/MySystem/MySystem/w32tex/dviout/dviout.exe" ) ;;ココdvioutのパス書く (setq dviprint-command-format "dvipdfmx %s ") ; BibTex (add-hook 'yatex-mode-hook 'turn-on-reftex)