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

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
 

企画特集

オンラインマーケティングの最重要課題オンラインマーケティングの最重要課題
ウェブ解析ツールを自社の味方につけるノウハウとは
内部統制対策を実現するIT運用管理ツール内部統制対策を実現するIT運用管理ツール
IT運用管理手法として注目が高まる、ITILによる運用管理を紹介
-Simplify IT- ITをシンプルに 連載第2回-Simplify IT- ITをシンプルに 連載第2回
PowerEdgeサーバ〜Windows Server 2008モデル登場
マイクロソフト、「XP SP3」の提供を延期--未対応の問題発見で
マイクロソフトは米国時間4月29日、未対応な問題が新たに発見されたことを理由に「Windows XP Service Pack 3(SP3)」のリリースを延期したことを発表した。
次世代DVD戦争は終結も…、進まぬBlu-rayプレーヤーの普及
HD DVDとBlu-rayを巡る次世代DVDの規格争いは終結したものの、その後も、勝ち残ったBlu-rayプレーヤーの販売台数が大幅に伸びるといった状況にはなっていない。高い販売価格がネックとなり、依然として一般的な消費者からは敬遠されている。
ニコニコ動画とAR(現実拡張)技術が可能にする「ニコニコ現実」という未来
ニコニコ動画の大きな特徴の1つが、他のユーザーと一緒に動画を見ているかのように感じられる擬似同期性だ。この手法は、ほかのサービスでも応用できるのだろうか。