tool editor: emacs(5) - ~/.emacs

October 12, 2007 10:58 PM
トラックバック (0)   コメント (0)

Emacsのインストールは完了した。起動するためのショートカットやファイルの関連付けもおわった。あとは~/.emacsを用意するだけだ :)

Emacsの設定ファイルである~/.emacsは好みがでるところなので他人のコードをまねる必要はないけれども、とりあえずコピペして終わりたい方のためにここに曝しておく。もっていけばいいじゃないかっ

; users generic .emacs file for Emacs 21.x/22.x

; Copyright (c) 1997-2007 Daichi GOTO 
; Copyright (c) 2006 ONGS Inc. 
; All rights reserved.

; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions
; are met:

; 1. Redistributions of source code must retain the above copyright 
;    notice, this list of conditions and the following disclaimer. 
; 2. Redistributions in binary form must reproduce the above copyright 
;    notice, this list of conditions and the following disclaimer in the 
;    documentation and/or other materials provided with the distribution.

; THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
; BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
; IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
; THE POSSIBILITY OF SUCH DAMAGE.

; author: Daichi GOTO (daichi@ongs.co.jp)
; first edition: Mon May 13 06:46:22 JST 2002
; last modified: $Date: 2007/07/10 06:19:26 $
; version: $Revision: 1.53 $


; ---------------------- base configuration ----------------------
;
;; spell check on
;(add-hook 'lisp-interaction-mode-hook 'flyspell-mode)
;(add-hook 'text-mode-hook 'flyspell-mode)
;(add-hook 'xml-mode-hook 'flyspell-mode)

;; color customization
(global-font-lock-mode t)

;; beep sound silence
(setq ring-bell-function (lambda ()))

;; delete whole line
(setq kill-whole-line t)

;; inhibit startup message
(setq inhibit-startup-message t)

;; no backup files
(setq make-backup-files nil)
(setq vc-make-backup-files nil)

;; title name
(setq frame-title-format "%b: %f")


; ---------------------- lang configuration ----------------------
;
;; base language
(if (string-match "21" emacs-version)
    (set-language-environment "Japanese"))

;; Mule-UCS(converters/mule-ucs) is needed for Emacs 21.x UTF-8/UTF-16
(if (string-match "21" emacs-version)
    (if (file-directory-p "/usr/local/share/doc/mule-ucs/")
        (require 'un-define)))


; -------------------- printout configuration --------------------
;
;; configurations for Postscript printout (ps-print-buffer etc)
(setq ps-lpr-command "lpr")
(setq ps-printer-name "lp")
(setq ps-paper-type 'a4)
(setq ps-multibyte-buffer 'non-latin-printer)

;; configurations for non-Postscript printout (lpr-buffer, print-buffer etc)
(setq lpr-command "lpr")
(setq printer-name "lp")


; ---------------------- key configuration -----------------------
;
;; goto-line: Esc-g
(global-set-key [(meta g)] 'goto-line)

;; insert date
(global-set-key [(control x)(t)] 'insert-date)
(defun insert-date()
       (interactive)
       (insert (current-time-string)))


; --------------------- window configuration ---------------------
;
;; wheel mouse
(mwheel-install)

;; scroll bar
(set-scroll-bar-mode  'right)

;; menu bar
(tool-bar-mode 1)

;; tool bar
(tool-bar-mode 0)

;; line spacing
(setq-default line-spacing 3)


; --------------------- fontset configuration ---------------------
;
(defvar freebsd_ipa_helvetica-fontset-spec
  (purecopy
   "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-freebsd_ipa_helvetica,
    ascii:-adobe-helvetica-medium-r-normal--17-*-*-*-*-*-*-*,
    latin-iso8859-1:-*-helvetica-medium-r-normal--17-*-*-*-*-*-iso8859-1,
    latin-iso8859-2:-*-helvetica-medium-r-normal--17-*-*-*-*-*-iso8859-2,
    latin-iso8859-3:-*-helvetica-medium-r-normal--17-*-*-*-*-*-iso8859-3,
    latin-iso8859-4:-*-helvetica-medium-r-normal--17-*-*-*-*-*-iso8859-4,
    latin-iso8859-9:-*-helvetica-medium-r-normal--17-*-*-*-*-*-iso8859-9,
    latin-iso8859-14:-*-helvetica-medium-r-normal--17-*-*-*-*-*-iso8859-14,
    latin-iso8859-15:-*-helvetica-medium-r-normal--17-*-*-*-*-*-iso8859-15,
    latin-jisx0201:-*-helvetica-medium-r-normal--17-*-*-*-*-*-iso8859-1,
    katakana-jisx0201:-ipa-ipagothic-medium-r-normal--16-*-*-*-*-*-jisx0201.1976-0,
    japanese-jisx0208:-ipa-ipagothic-medium-r-normal--16-*-*-*-*-*-jisx0208.1990-0,
    japanese-jisx0208-1978:-ipa-ipagothic-medium-r-normal--16-*-*-*-*-*-jisx0208.1990-0,
    chinese-gb2312:-*-medium-r-normal-*-16-*-gb2312*-*,
    korean-ksc5601:-*-medium-r-normal-*-16-*-ksc5601*-*,
    chinese-cns11643-1:-*-medium-r-normal-*-16-*-cns11643*-1,
    chinese-cns11643-2:-*-medium-r-normal-*-16-*-cns11643*-2,
    chinese-cns11643-3:-*-medium-r-normal-*-16-*-cns11643*-3,
    chinese-cns11643-4:-*-medium-r-normal-*-16-*-cns11643*-4,
    chinese-cns11643-5:-*-medium-r-normal-*-16-*-cns11643*-5,
    chinese-cns11643-6:-*-medium-r-normal-*-16-*-cns11643*-6,
    chinese-cns11643-7:-*-medium-r-normal-*-16-*-cns11643*-7")
  "IPA+Helvetica fontset on FreeBSD")

(defvar freebsd_ipa_fixed-fontset-spec
  (purecopy
   "-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-freebsd_ipa_fixed,
    latin-jisx0201:-*-helvetica-medium-r-normal--17-*-*-*-*-*-iso8859-1,
    katakana-jisx0201:-ipa-ipagothic-medium-r-normal--16-*-*-*-*-*-jisx0201.1976-0,
    japanese-jisx0208:-ipa-ipagothic-medium-r-normal--16-*-*-*-*-*-jisx0208.1990-0,
    japanese-jisx0208-1978:-ipa-ipagothic-medium-r-normal--16-*-*-*-*-*-jisx0208.1990-0,
    chinese-gb2312:-*-medium-r-normal-*-16-*-gb2312*-*,
    korean-ksc5601:-*-medium-r-normal-*-16-*-ksc5601*-*,
    chinese-cns11643-1:-*-medium-r-normal-*-16-*-cns11643*-1,
    chinese-cns11643-2:-*-medium-r-normal-*-16-*-cns11643*-2,
    chinese-cns11643-3:-*-medium-r-normal-*-16-*-cns11643*-3,
    chinese-cns11643-4:-*-medium-r-normal-*-16-*-cns11643*-4,
    chinese-cns11643-5:-*-medium-r-normal-*-16-*-cns11643*-5,
    chinese-cns11643-6:-*-medium-r-normal-*-16-*-cns11643*-6,
    chinese-cns11643-7:-*-medium-r-normal-*-16-*-cns11643*-7")
  "IPA+fixed fontset on FreeBSD")

(cond
 ((file-readable-p "/usr/local/share/ipa-ttfonts/fonts/ipag.ttf")
  (create-fontset-from-fontset-spec freebsd_ipa_helvetica-fontset-spec t)
  (set-default-font "fontset-freebsd_ipa_helvetica")
  (setq default-frame-alist '((width . 90) (height . 30)))
  ;; if you wish with fixed width fonts then uncomment follow
  ;(create-fontset-from-fontset-spec freebsd_ipa_fixed-fontset-spec t)
  ;(set-default-font "fontset-freebsd_ipa_fixed")
  ;(setq default-frame-alist '((width . 80) (height . 30)))
  )
 (t
  ;; default frame size
  (setq default-frame-alist '((width . 80) (height . 30))))
 )


; ------------------ input method configuration ------------------
;
;; select input method
(cond

  ;; Tamago for Wnn7
  ((and
     (file-directory-p "/usr/local/share/emacs/21.3/site-lisp/egg/")
     (or (file-directory-p "/usr/local/lib/wnn7/elisp/")
         (file-directory-p "/usr/share/wnn7/elisp/")))
   (setq default-input-method "japanese-egg-wnn"))

  ;; Tamago for Anthy
  ((and
     (file-directory-p "/usr/local/share/emacs/21.3/site-lisp/egg/")
     (file-directory-p "/usr/local/share/anthy/"))
   (setq default-input-method "japanese-egg-anthy"))

  ;; Tamago for FreeWnn
  ((and
     (file-directory-p "/usr/local/share/emacs/21.3/site-lisp/egg/")
     (file-directory-p "/usr/local/bin/Wnn4/"))
   (setq default-input-method "japanese-egg-wnn"))

  ;; Tamago for Canna
  ((and
     (file-directory-p "/usr/local/share/emacs/21.3/site-lisp/egg/")
     (file-directory-p "/usr/local/share/canna/"))
   (setq default-input-method "japanese-egg-canna"))

  ;; Wnn7 egg-leim
  ((or (file-directory-p "/usr/local/lib/wnn7/elisp/")
       (file-directory-p "/usr/share/wnn7/elisp/"))
   (setq default-input-method "japanese-egg-wnn7"))

  ;; Anthy
  ((file-directory-p "/usr/local/share/emacs/site-lisp/anthy/")
   (setq default-input-method "japanese-anthy"))
 )

;; input method configuration
(cond

  ;; Tamago for Canna
  ((string-equal "japanese-egg-canna" default-input-method)
   (setq canna-hostname "localhost")
   (setq egg-conversion-auto-candidate-menu 1))

  ;; Wnn7 egg-leim
  ;    egg-use-input-predict is needed to use predict input
  ;    enable-double-n-syntax is needed to input 'ん' by 'nn'
  ((string-equal "japanese-egg-wnn7" default-input-method)
   (push "/usr/local/lib/wnn7/elisp/emacs20/" load-path)
   (load "wnn7egg-leim")
   (set-input-method "japanese-egg-wnn7")
   (egg-use-input-predict) 
   (setq enable-double-n-syntax t))

  ;; Anthy
  ((string-equal "japanese-anthy" default-input-method)
   (push "/usr/local/share/emacs/site-lisp/anthy/" load-path)
   (load-file "/usr/local/share/emacs/site-lisp/anthy/leim-list.el")
   (setq anthy-wide-space " "))
 )

;; toggle input method key configuration
(cond

  ;; Wnn7, FreeWnn, Canna, Anthy
  ((or 
     (string-equal "japanese-egg-wnn" default-input-method)
     (string-equal "japanese-egg-anthy" default-input-method)
     (string-equal "japanese-egg-wnn" default-input-method)
     (string-equal "japanese-egg-canna" default-input-method)
     (string-equal "japanese-egg-wnn7" default-input-method)
     (string-equal "japanese-anthy" default-input-method)
   )
   (global-set-key [(control backslash)] 'toggle-input-method)
   (global-set-key [(meta zenkaku-hankaku)] 'toggle-input-method)
   (global-set-key [(zenkaku-hankaku)] 'toggle-input-method)
   (global-set-key [(henkan)] 'toggle-input-method))
  )


; --------------------- user configuration ---------------------
;
;; load user configuration
(if (file-readable-p "~/.emacs.mine")
    (load-file "~/.emacs.mine"))

これはMacOS X、FreeBSD、Linuxでそれほど問題なく無難に使えるように調整したものだ。OS Xには不要な部分もおおいんだが、コピーするだけで使い回せるので無問題。ただ、PCごとに設定を微妙に変えたいことが多いんで、PCごとの個別の設定は~/.emacs.mineファイルに書いておけば反映されるようにしてある。

よし、Emacsはこんなもんだな〜

最新エントリー
カテゴリ
月別のアーカイブ
プロフィール
後藤大地(Daichi Goto)
オングス代表取締役。FreeBSD committer。ネットワーク構築やデータベースシステム構築、各種専用システムソフトウェアの開発、教育事業、執筆業務などを手がける。
Powered by
 
プレスリリース Feed

企画特集

サーバ仮想化・グリーン化の利点を最大化!サーバ仮想化・グリーン化の利点を最大化!
そ多機能・高価値なNetAppストレージの秘密とは
APC SOLUTIONS FORUM 2008をレポートAPC SOLUTIONS FORUM 2008をレポート
電源、冷却の効率化によるエネルギー削減とは?
ZDNet Japan Green ITZDNet Japan Green IT
サミットだけでは終わらせない!エンタープライズの取り組みはこれからだ!
ZDNet Japan ホスティング特集ZDNet Japan ホスティング特集
2008年夏のホスティングサービスのトレンドは何?
ログ管理ソリューション特集ログ管理ソリューション特集
セキュリティ、コンプライアンス対策で注目度アップ!
「シンプル」&「低コスト」な運用管理「シンプル」&「低コスト」な運用管理
IT運用管理に関するアンケート実施中!
セキュリティ対策レベルテスト公開!セキュリティ対策レベルテスト公開!
自社のセキュリティのウイークポイントはドコ?
Webセキュリティ特集Webセキュリティ特集
Web2.0時代の脅威へ対抗するためのソリューションとは?
Techno ExchangeTechno Exchange
RackableとCTCの地球にやさしい関係
フォトレポート:注目の「iPhone 3G」アプリトップ10
「iPhone 3G」発売から時間がたち、App Storeが充実してきた。ここでは、注目のアプリケーション10種を紹介する。
フォトレポート:コスプレーヤー、コミックの祭典に集合--Comic-Con 2008
Comic-Con 2008が7月にサンディエゴで開催された。このコミックの祭典とも言えるイベントで見つけたコスプレーヤーたちを画像で紹介する。
フォトレポート:絵で見る「Internet Explorer 8」ベータ2
マイクロソフトがこのほど、「Internet Explorer 8(IE8)」のベータ2をリリースした。このリリースにおける特長はユーザー志向の機能だ。