.emacs for Emacs 22.0.50,
Mac OS X Tiger

since May 3 2005

 
本文「Mac OS X Tiger, X11-Emacs 22.0.50」に戻る

;; -*- coding: iso-2022-jp; mode: emacs-lisp -*-
;;
;; Emacs 22 initialization on Margarita, Mac OS X Tiger, isao yasuda
;;
;;   Mac OS X 事前準備・注意事項
;;  (Requirements for Mac OS X in use of X11-Emacs)
;;
;;   1.Commandキーを Metaキーに割り当てるためには X11 Preferences - Input で
;;       Follow system keyboard layout
;;       Enable key equivalents under X11
;;     のチェックボックスをオフにしておく.
;;  (1.In order to assign Command key to Meta key of Emacs setup in menu
;;     "X11 Preferences - Input":
;;       Follow system keyboard layout    -> checkbox off
;;       Enable key equivalents under X11 -> checkbox off )
;;
;;   2.xmodmap で以下を定義しておく.(Command, OptionキーをMetaキーとする)
;;  (2.By xmodmap define like as the next lines:)
;;
;;       clear mod1
;;       keycode 66 = Meta_L  -> Option key to Meta
;;       keycode 63 = Meta_R  -> Command key to Meta
;;       add mod1 = Meta_L Meta_R
;;
;;   3.Tiger では C-SPC が Spotlight にトラップされるので,ショートカットキー
;;     定義を変更しておく.
;;  (3.On Tiger "C-SPC" must to be trapped by Spotlight, so redefine
;;     short-cut keys assign for Spotlight to use Emacs comfortably.)
;;
;;   4.Unicode 漢字は /efont/ を使用するよう,.Xdefaults に以下定義しておく.
;;  (4.So that /efont/ will be used as Unicode Kanji fonts, define
;;     in your .Xdefaults:)
;;
;;     Emacs*fontSetList: 0,1,2
;;     Emacs.Fontset-0:-*-fixed-medium-r-normal-*-14-*-*-*-*-*-fontset-14,\
;;         mule-unicode-e000-ffff:-efont-biwidth-medium-r-normal-*-14→
;;             -*-*-*-*-*-iso10646-1,\
;;         mule-unicode-2500-33ff:-efont-biwidth-medium-r-normal-*-14→
;;             -*-*-*-*-*-iso10646-1
;;     Emacs.Fontset-1:-*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-16,\
;;         mule-unicode-e000-ffff:-efont-biwidth-medium-r-normal-*-16→
;;             -*-*-*-*-*-iso10646-1,\
;;         mule-unicode-2500-33ff:-efont-biwidth-medium-r-normal-*-16→
;;             -*-*-*-*-*-iso10646-1
;;     Emacs.Fontset-2:-*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24,\
;;         mule-unicode-e000-ffff:-efont-biwidth-medium-r-normal-*-24→
;;             -*-*-*-*-*-iso10646-1,\
;;         mule-unicode-2500-33ff:-efont-biwidth-medium-r-normal-*-24→
;;             -*-*-*-*-*-iso10646-1
;;     Emacs.Font: fontset-16
;;
;;   5.インド系文字(Hindi, Kannada, Malayalam, etc.)の表示は intlfonts 以外に
;;     cdacfonts もインストールしておく.
;;  (5.For display of Indian character sets: Hindi, Kanada, Malayalam, etc.
;;     it is desirable to install "cdacfonts" besides "intlfonts".)
;;

;; ロードパスの追加 (for addition load-paths)
(setq load-path
      (append load-path 
              '("/Users/isao/elisp") load-path))

;; その場で式を評価する (for evaluation at the place)
(put 'eval-expression 'disabled nil)
;; モードラインに行番号表示 (for display line number at mode-line)
(line-number-mode t)
;; モードラインに桁番号表示 (for display point in line at mode-line)
(column-number-mode t)
;; モードラインに日付・時刻表示 (for display date and time)
(setq display-time-day-and-date t
      display-time-24hr-format t)
(setq display-time-format "%m/%d(%a) %H:%M")
(display-time)
;; tab 4
(setq default-tab-width 4)
;; 強調 (for standing out the environment keywords)
(global-font-lock-mode t)
;; 対の括弧を明示 (for remark of the other paren)
(show-paren-mode t)
;; リージョンをハイライト (for hilighting regions)
(transient-mark-mode t)
;; カーソルの点滅を止める (not let cursor blink)
(blink-cursor-mode 0)
;; オープニングメッセージ表示しない (No opening messages)
(setq inhibit-startup-message t)
;; ツールバー表示しない (not display tool-bar)
(tool-bar-mode 0)

;; define keys
;; home キーでバッファ先頭に (go to the top of buffer by "HOME" key)
(global-set-key [home] 'beginning-of-buffer)
;; end キーでバッファ末尾に (go to the bottum of buffer by "END" key)
(global-set-key [end]  'end-of-buffer)
;; delete キーで後文字削除 (delete the char pointed on cursor by "delete" key)
(global-unset-key [delete])
(global-set-key [delete] 'delete-char)
;; カーソル位置のURLに対しブラウザ起動
;;(execut Web browser and visit URL pointed on cursor)
(global-set-key "\C-c\C-b" 'browse-url-at-point)

;; ! で対応する括弧に移動 (move to the other paren by "!" key)
(global-set-key "!" 'match-paren)
(defun match-paren (arg)
  "Go to the matching paren if on a paren; otherwise insert !."
  (interactive "p")
  (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
        ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
        (t (self-insert-command (or arg 1)))))

;; ファイル先頭 #! のとき自動的に chmod +x
;;(automaticaly chmod +x when the file has "#!" in it's first line)
(add-hook 'after-save-hook
          'executable-make-buffer-file-executable-if-script-p)

;; バックアップファイルは ~/tmp/edback に取得
;;(backup file before editing into ~/tmp/edback directory)
(fset 'make-backup-file-name
      '(lambda (file)
         (concat (expand-file-name "~/tmp/edback/")
                 (file-name-nondirectory file))
         ))
(if (file-exists-p "~/tmp/edback/")
    (setq auto-save-list-file-prefix "~/tmp/edback/"))
;; .save.. ファイルを作らない (not make .save..files)
(setq auto-save-list-file-name nil)
(setq auto-save-list-file-prefix nil)

;;
;; フレーム設定
;; Definitions for Frame of Emacs Window
;;
(setq default-frame-alist
      (append (list '(foreground-color . "#330000")
                    '(background-color . "snow")
                    '(border-color . "#CC0033")
                    '(width . 80)
                    '(height . 40)
                    '(font . "fontset-16")
              default-frame-alist)))

(set-cursor-color "#990033")
(set-mouse-color "#990033")

;;
;; carbon-font (Carbon-Emacs の場合のみ)
;;(Definitions for Carbon-font -- only for Carbon-Emacs
;;
(if (eq window-system 'mac)
    (progn
      (require 'carbon-font)
      (set-default-font "fontset-hiraginomaru12")
      (setq default-frame-alist (append '(font . "fontset-hiraginomaru12")))
      ))

;;
;; 言語設定,デフォルト UTF-8
;;(Language setup, default: UTF-8)
;;
(set-language-environment "Japanese")
;; Coding system UTF-8
(set-terminal-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(set-buffer-file-coding-system 'utf-8-unix)
;; code page CP-1251
;;   Mew で CP-1251 のメールをみたいときは C-u C-c C-l cp1251 RET とする
;;(for encoding CP-1251 Russian code page.
;; Type "C-u C-c C-l cp1251 RET" to view CP-1251 encoded E-mails by Mew)
(codepage-setup 1251)
(define-coding-system-alias 'windows-1251 'cp1251)

;;
;; Tamago-4.0.6 (jserverを起動しておく)
;;(Tamago-4.0.6 for input Japanese. "jserver" must be started before.)
;;
;; 句読点は .,
;;(usually use as Japanese puctuations "." and ",")
(setq its-hira-period ".")
(setq its-hira-comma ",")
;; post-command-hook error 対策
;; see: http://lowlife.jp/mft/stories/7.html
(defun egg-activate-keymap-after-command ()
  (while egg-change-major-mode-buffer
    (save-excursion
      (if (buffer-live-p (car egg-change-major-mode-buffer))
          (progn
            (set-buffer (car egg-change-major-mode-buffer))
            (egg-activate-keymap))))
    (setq egg-change-major-mode-buffer (cdr egg-change-major-mode-buffer)))
  (remove-hook 'post-command-hook 'egg-activate-keymap-after-command))

;;
;; インプットメソッド関数定義
;; Definitions for quail input methods
;;
(defun set-slavonic-input ()
 "Slavonic general for Russian, Ukrainian, Old Slavonic, etc."
 (interactive)
 (set-input-method "slavonic")
 )

(defun set-japanese-input ()
 "Japanese egg wnn7."
 (interactive)
 (set-input-method "japanese-egg-wnn7")
 )

(defun set-latin-input ()
 "Latin postfix for European languages."
 (interactive)
 (set-input-method "latin-postfix")
 )

(defun set-greek-input ()
 "Greek-polytonic for Classic and Modern Greek."
 (interactive)
 (set-input-method "greek-polytonic")
 )

;; ファンクションキーでインプットメソッド選択
;;(change input methods by function keys)
(global-set-key [f5] 'set-slavonic-input)
(global-set-key [f6] 'set-japanese-input)
(global-set-key [f7] 'set-latin-input)
(global-set-key [f8] 'set-greek-input)

;;
;; Register Modes for programming
;; 
;; 設定した auto-mode-alist を活かす
;;(activate "auto-mode-alist" definitions)
(setq magic-mode-alist nil)
;; mode 設定
;;(definitions for editing modes for programming)
(setq auto-mode-alist 
      (append '(
                ("\\.C$"    . c++-mode)
                ("\\.cc$"   . c++-mode)
                ("\\.cpp$"  . c++-mode)
                ("\\.hh$"   . c++-mode)
                ("\\.c$"    . c-mode)
                ("\\.h$"    . c-mode)
                ("\\.m$"    . objc-mode)
                ("\\.java$" . java-mode)
                ("\\.pl$"   . cperl-mode)
                ("\\.perl$" . cperl-mode)
                ("\\.tex$"  . yatex-mode)
                ("\\.sty$"  . yatex-mode)
                ("\\.cls$"  . yatex-mode)
                ("\\.clo$"  . yatex-mode)
                ("\\.dtx$"  . yatex-mode)
                ("\\.fdd$"  . yatex-mode)
                ("\\.ins$"  . yatex-mode)
                ("\\.s?html?$" . html-helper-mode)
                ("\\.php$" . html-helper-mode)
                ("\\.jsp$" . html-helper-mode)
                ("\\.css$"  . css-mode)
                ("\\.js$"   . java-mode)
                ("\\.el$"   . emacs-lisp-mode)
                ) auto-mode-alist))

;; c/c++, java mode
(autoload 'c++-mode  "cc-mode" "C++ Editing Mode" t)
(autoload 'c-mode    "cc-mode" "C Editing Mode" t)
(autoload 'java-mode "cc-mode" "Java Editing Mode" t)
(setq c-tab-always-indent nil)
(setq c-default-style "bsd")
(setq c-block-comments-indent-p 3)
(setq c-basic-offset  4)

;; HTML mode
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(autoload 'asp-html-helper-mode "html-helper-mode" "Yay HTML" t)
(autoload 'jsp-html-helper-mode "html-helper-mode" "Yay HTML" t)
(add-to-list 'auto-mode-alist '("\\.s?html?$" . html-helper-mode))

;; PHP mode
(require 'php-mode)
(autoload 'php-mode "php-mode" "PHP editing mode" t)
(add-to-list 'auto-mode-alist '("\\.php$" . html-helper-mode))

;; CSS mode
(autoload 'css-mode "css-mode" "Cascading Style Sheet editing mode" t)
(setq auto-mode-alist
      (cons '("\\.css$" . css-mode) auto-mode-alist))

;; perl mode
(autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl programs" t)
(setq cperl-indent-level 4)
(setq cperl-continued-statement-offset 4)
(setq cperl-comment-column 40)

;; YaTeX, TeX mode
(autoload 'yatex-mode "yatex" "Yet Another LaTeX Mode" t)
;;; EUC 漢字コード (default Kanji encoding is EUC-Japan)
(setq YaTeX-kanji-code 3)
(setq tex-command "platex")
(setq dvi2-command "xdvi")
(setq section-name "documentclass")
(setq mode-name "YaTeX")
(setq YaTeX-fill-column nil)
;;; bold, italic にしない (not use bold and italic font faces)
(setq YaTeX-font-lock-bold-face 'bold
      YaTeX-font-lock-italic-face 'italic
      YaTeX-use-italic-bold nil)
;;; font-face の設定 (font faces)
(defface YaTeX-font-lock-bold-face
  '((((class color) (background dark)) (:foreground "lightgoldenrod"))
    (((class color) (background light)) (:foreground "DarkGoldenrod"))
    (t (:bold nil)))
  "Font Lock mode face used to express bold itself."
  :group 'font-lock-faces)
(defvar YaTeX-font-lock-bold-face 'YaTeX-font-lock-bold-face)
(defface YaTeX-font-lock-italic-face
  '((((class color) (background dark)) (:foreground "Plum1"))
    (((class color) (background light)) (:foreground "purple"))
    (t (:italic t)))
  "Font Lock mode face used to express italic itself."
  :group 'font-lock-faces)
(defvar YaTeX-font-lock-italic-face 'YaTeX-font-lock-italic-face)

;; Multi mode -- mmm-mode
(require 'mmm-mode)
(require 'mmm-auto)
(require 'mmm-vars)
(require 'mmm-compat)
(setq mmm-global-mode 'maybe)

;; Multi mode definitions
(setq mmm-submode-decoration-level 2)
;;(set-face-background 'mmm-default-submode-face "wheat")

;; HTML + JavaScript
(mmm-add-classes
 '((html-js
    :submode java-mode
    :front "<script [^>]*>?"
    :back "</script>?")))
(mmm-add-mode-ext-class 'html-helper-mode "\\.s?html?\\'" 'html-js)

;; HTML + CSS
(mmm-add-classes
 '((html-css
    :submode css-mode
    :front "<style [^>]*>?"
    :back "</style>?")))
(mmm-add-mode-ext-class 'html-helper-mode "\\.s?html?\\'" 'html-css)

;; HTML + PHP
(mmm-add-classes
 '((html-php
    :submode php-mode
    :front "<\\?\\(php\\)?"
    :back "\\?>")))
(mmm-add-mode-ext-class 'html-helper-mode "\\.php?\\'" 'html-php)

;; HTML + JSP
(mmm-add-classes
 '((html-jsp
    :submode java-mode
    :front "<%"
    :back "\\%>")))
(mmm-add-mode-ext-class 'html-helper-mode "\\.jsp?\\'" 'html-jsp)

;;
;; Mew の設定 (アカウントその他は .mew.el に記述)
;;(Mew: MUA for Emacs)
;;
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)
(setq mew-icon-directory "/usr/local/share/emacs/22.0.50/etc/Mew")

;;
;; Ispell -- ispell.el 3.7 patched for aspell UTF-8
;;
;;; 個人辞書
;;;(personal dictionary)
(setq ispell-personal-dictionary "~/.ispell-dict-personal")

;;; aspell 附属の ispell を使う
;;;(for spelling check use ispell module bundled on aspell)
(setq ispell-program-name "/usr/local/lib/aspell-0.60/ispell")

;;; 各国語用設定
;;; Definitions of spell checking for variable languages
;;;; ロシア語 (Russian)
(defun ru-ispell ()
 "Russian aspell for UTF-8"
 (interactive)
 (setenv "LANG" "ru_RU")
 (ispell-buffer)
 )

;;;; 英語 (English)
(defun en-ispell ()
 "English aspell for UTF-8"
 (interactive)
 (setenv "LANG" "en_EN")
 (ispell-buffer)
 )

;;;; 仏語 (French)
(defun fr-ispell ()
 "French aspell for UTF-8"
 (interactive)
 (setenv "LANG" "fr_FR")
 (ispell-buffer)
 )

;;;; 独語 (German)
(defun de-ispell ()
 "German aspell for UTF-8"
 (interactive)
 (setenv "LANG" "de_DE")
 (ispell-buffer)
 )

;;
;; UCS character utility
;;
;;; UCS コードポイントで文字を挿入
;;;(insert Unicode characters by typing their UCS2 codepoints
(global-set-key "\C-c\C-i" 'ucs-insert)
;;; カーソルの文字の情報を表示
;;;(describe the information of character on the cursor)
(global-set-key "\C-c\C-d" 'describe-char)

;;
;; Utf82Tex: UTF-8 - TeXコード変換支援 (by isao yasuda)
;;(Utf82TeX: utility to convert UTF-8 characters to TeX handles)
;; http://yasuda.homeip.net/archives/im-textools-0608.tar.gz
(require 'utf82tex)
(setq utf82tex-path "/usr/local/bin/utf82tex")
(setq utf82tex-rc   "/usr/local/etc/utf82tex/utf82texrc")
(setq utf82tex-out-encoding 'utf-8)

;;
;; misima: 旧仮名遣い・旧字変換支援 (by isao yasuda)
;;(misima: utility to convert contemporary Japanese orthography to
;;         old Japanese for Emacs use)
;; http://yasuda.homeip.net/archives/misima-2.3b.tar.gz
(require 'misima)
(setq misima-path "/usr/local/bin/misima")
(setq misima-rc   "/Users/isao/etc/misima/misimarc")

;;
;; misima: 旧仮名遣い・旧字変換支援 SOAP WebService (by isao yasuda)
;;(misima: utility to convert contemporary Japanese orthography to
;;         old Japanese for Emacs use, SOAP WebService version)
;; http://yasuda.homeip.net/archives/misimaSoapService-0.1.zip
;;
(require 'misimasoap)
(setq misimasoap-path "/Users/isao/src/misima/soap/test/misima.sh")

;;
;; staslova: 多言語単語統計支援 (by isao yasuda)
;;(staslova: tool for statistics of words in multi-lingual texts
;;           and analysis for Emacs use)
;; http://yasuda.homeip.net/archives/staslova-1.1.tar.gz
;;
(require 'staslova)
(setq staslova-path "/usr/local/bin/staslova")
(setq staslova-opt  "-d/Users/isao/etc/staslova.def")
(setq staslova-out-encoding 'utf-8)

;;
;; Japanese utility (by isao yasuda)
;;
(require 'japanese-util)
;;; Key binding 
;;; 全角スペース,"、","。","・","『』"の挿入
;;;(short-cuts for variable Japanese characters)
(global-set-key "\C-cjs" 'jutil-insert-zenkaku-space)
(global-set-key "\C-cjt" 'jutil-insert-zenkaku-toten)
(global-set-key "\C-cjk" 'jutil-insert-zenkaku-kuten)
(global-set-key "\C-cjc" 'jutil-insert-zenkaku-chuten)
(global-set-key "\C-cjn" 'jutil-insert-zenkaku-nijukagi)
;;; リージョンの"、"と"。"をそれぞれ","と"."に変換
;;;(replace punctuation style in the region: "、" & "。" to "," and ".")
(global-set-key [f13] 'jutil-trans-kutoten-ronbun-region)
;;; リージョンの","と"."をそれぞれ"、"と"。"に変換
;;;(replace punctuation style in the region: "," and "." to "、" & "。")
(global-set-key [C-f13] 'jutil-trans-kutoten-ippan-region)

;; end of file

本文「Mac OS X Tiger, X11-Emacs 22.0.50」に戻る