$ cat /private/etc/emacs-[EMACSVER]/site-start.d/99osxws.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; osxws.el for MacOS X [[WorkShop]]
;; KOBAYASHI Taizo <xxxxxxx@xxxxxx.com>
;; Time-stamp: <07/03/07 15:17:49 tkoba>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Section 0 fundamental configurations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; setting the MacOS X [[WorkShop]] flag
(defconst osxws-emacs-flag t
"This is Emacs of MacOS X WorkShop.")
;; japanese settings for Carbon Emacs Package
(if
(equal
(substring
(concat
(shell-command-to-string "defaults read -g AppleLocale") "__") 0 2) "ja")
(save-excursion
(require 'utf-8m)
(set-clipboard-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8) ; 'euc-jp-unix)
(set-file-name-coding-system 'utf-8m)
(set-language-environment 'Japanese)
(set-default-coding-systems 'euc-jp-unix)
(set-keyboard-coding-system (if window-system 'sjis-mac 'utf-8))
(load "menu-tree")))
;;; 前回の編集箇所を記録
(require 'saveplace)
(setq-default save-place t)
(setq save-place-file "~/Library/Application Support/OSXWS/emacs-places.txt")
;; 編集ファイル foo のバックアップファイル foo~ をコピーで作る
(setq backup-by-copying t)
;;; emacsclient サーバを起動
(server-start)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Section 1 appearance setting
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; tool-bar を消す
(tool-bar-mode nil)
;;; 括弧の対応表示
(require 'paren)
(show-paren-mode)
;;; mark 領域に色付け
(setq transient-mark-mode t)
;;; フォントのスケールをしない
(setq scalable-fonts-allowed nil)
;;; 行番号を表示する
(line-number-mode t)
;;; ステータスラインに時間を表示する
(if (equal (substring (concat
(shell-command-to-string "defaults read -g AppleLocale") "__") 0 2) "ja")
(progn
(setq dayname-j-alist
'(("Sun" . "日") ("Mon" . "月") ("Tue" . "火") ("Wed" . "水")
("Thu" . "木") ("Fri" . "金") ("Sat" . "土")))
(setq display-time-string-forms
'((format "%s年%s月%s日(%s) %s:%s %s"
year month day
(cdr (assoc dayname dayname-j-alist))
24-hours minutes
load)))))
(display-time)
;;; 最終更新日の自動挿入
;;; ファイルの先頭から 8 行以内に Time-stamp: <> または
;;; Time-stamp: " " と書いてあれば、セーブ時に自動的に日付が挿入されます
(require 'time-stamp)
(if (not (memq 'time-stamp write-file-functions))
(setq write-file-functions
(cons 'time-stamp write-file-functions)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Section 2 keyboard/keybindig
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; コマンド、コントロール、オプションの各キーを
;;; alt, control, hyper, meta, super
;;; の各キーとして利用
(setq mac-command-modifier 'alt)
(setq mac-control-modifier 'control)
(setq mac-option-modifier 'meta)
(cua-selection-mode t)
;;; [Home] Key と [End] Key を従来の動作に戻す
(define-key global-map [home] 'beginning-of-buffer)
(define-key global-map [end] 'end-of-buffer)
;;; mac-key-mode
;; (OSXアプリケーションのショートカット)
(when (eq window-system 'mac)
(require 'mac-key-mode)
(mac-key-mode 1))
;; C. fix: Unicode => Japanese mapping
;; Thanks to saiki-san (see [macemacsjp-users 870])
;; register circle around digits to cjk table (by Ando-san)
(defadvice utf-translate-cjk-load-tables
(after my-ad-circled-digit activate)
(dotimes (i 20)
(let ((unicode (+ #x2460 i))
(char (+ 54433 i)))
(if (utf-translate-cjk-substitutable-p unicode)
(puthash unicode char ucs-unicode-to-mule-cjk))
(puthash char unicode ucs-mule-cjk-to-unicode))))
;; prevent to use half-width marks (by Nanba-san)
(utf-translate-cjk-set-unicode-range
'((#x2e80 . #xd7a3)
(#xff00 . #xffef)
(#xa7 . #xa7) ;
(#xb0 . #xb1) ;
(#xb4 . #xb4) ;
(#xb6 . #xb6) ;
(#xd7 . #xd7) ;
(#xf7 . #xf7) ;
(#x370 . #x3ff) ; ギリシャ
(#x400 . #x4ff) ; キリル
(#x2000 . #x206f) ; 一般句読点
(#x2103 . #x2103) ; ℃
(#x212b . #x212b) ; Å
(#x2190 . #x21ff) ; 矢印
(#x2200 . #x22ff) ; 数学記号
(#x2300 . #x23ff) ; 技術記号
(#x2460 . #x2473) ; 円囲み数字
(#x2500 . #x257f) ; 罫線
(#x25a0 . #x25ff) ; 幾何学模様
(#x2600 . #x26ff) ; その他の記号
))
;; C. end
;; D. fix yen key problem on JIS keyboard
;; Ando-san's code (see [Macemacsjp-users 1126])
(define-key global-map [2213] nil)
(define-key global-map [67111077] nil)
(define-key function-key-map [2213] [?\\])
(define-key function-key-map [67111077] [?\C-\\])
(define-key global-map [3420] nil)
(define-key global-map [67112284] nil)
(define-key function-key-map [3420] [?\\])
(define-key function-key-map [67112284] [?\C-\\])
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Section 3 shell-command の設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; password の入力を隠す
(add-hook 'comint-output-filter-functions
'comint-watch-for-password-prompt)
;;; escape sequence
(autoload 'ansi-color-for-comint-mode-on "ansi-color"
"Set `ansi-color-for-comint-mode' to t." t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Section 4 橋本さんの inline-patch 設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(when (eq window-system 'mac)
(add-hook 'minibuffer-setup-hook 'mac-change-language-to-us)
(mac-add-ignore-shortcut '(control))
(mac-set-input-method-parameter 'japanese 'cursor-color "red"))
;; Command-Space で起動します。
(global-set-key [(alt \ )] 'toggle-input-method)
;; Shift-Space で起動します。
(global-set-key [?\S-\ ] 'toggle-input-method)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Section 5 [[CarbonEmacs]]ウィンドウモードの設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(when (eq window-system 'mac)
;; fixed-width-fontset (carbon-font)
(require 'carbon-font)
;; if display-height is less than 900, set font size 12pt.
(if (< (display-pixel-height) 900)
(setq fontsize 12)
(setq fontsize 14))
(fixed-width-set-fontset "hiramaru" fontsize)
;; color-theme
;; M-x color-theme-?によってカラーテーマを変更できます。
(require 'color-theme)
(color-theme-dark-blue2)
;; 透過ウィンドウ Transparency3
(add-to-list
'default-frame-alist
'(alpha . (90 40))) ;; (alpha . (<active frame> <non active frame>))
(setq frame-alpha-lower-limit 20)
;; アンチエイリアス
(setq mac-allow-anti-aliasing t)
;;----------------------------------------------------------
;; smart-dnd (ドラッグ&ドロップ)
(require 'smart-dnd)
;; yahtml-mode:
(add-hook
'yahtml-mode-hook
'(lambda ()
(smart-dnd-setup
'(
("\\.gif\\'" . "<img src=\"%R\">\n")
("\\.jpg\\'" . "<img src=\"%R\">\n")
("\\.png\\'" . "<img src=\"%R\">\n")
("\\.css\\'" . "<link rel=\"stylesheet\" type=\"text/css\" href=\"%R\">\n" )
("\\.js\\'" . "<script type=\"text/javascript\" src=\"%R\"></script>\n" )
(".*" . "<a href=\"%R\">%f</a>\n")))))
;; yatex-mode:
(add-hook
'yatex-mode-hook
'(lambda ()
(smart-dnd-setup
'(
("\\.tex\\'" . "\\input{%r}\n")
("\\.cls\\'" . "\\documentclass{%f}\n")
("\\.sty\\'" . "\\usepackage{%f}\n")
("\\.eps\\'" . "\\includegraphics[clip]{%r}\n")
("\\.ps\\'" . "\\includegraphics[clip]{%r}\n")
("\\.pdf\\'" . "\\includegraphics[clip]{%r}\n")
("\\.jpg\\'" . "\\includegraphics[clip]{%r}\n")
("\\.png\\'" . "\\includegraphics[clip]{%r}\n")
("\\.bst\\'" . "\\bibliographystyle{%n}\n")
("\\.bib\\'" . "\\bibliography{%n}\n")))))
;; C/C++ mode:
(add-hook
'c-mode-common-hook
'(lambda () (smart-dnd-setup '(("\\.h\\'" . "#include <%f>")))))
;;----------------------------------------------------------
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Section 6 その他の設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Yatex
(if (file-exists-p "~/.yatex.el")
(load-file "~/.yatex.el"))
;; Mew 5.2 - Messaging in the Emacs World
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)
(if (file-exists-p "~/.mew.el")
(load-file "~/.mew.el"))
;;; バッファの最後でnewlineで新規行を追加するのを禁止する
(setq next-line-add-newlines nil)
;;; 画面最下行で[↓]を押したときのスクロール数
(setq scroll-step 1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Local Variables:
;; mode: emacs-lisp
;; buffer-file-coding-system: junet-unix
;; End:
.emacsでは条件分岐のみを行います。他のEmacsに別の初期設定を行いたい場合 もここから読み込むように設定します。
$ cat ~/.emacs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 初期設定ファイルの読み込み
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(cond ((boundp 'osxws-emacs-flag)
; Mac OS X WorkShop用初期化ファイル
(load-file "~/.emacs_osxws.el")
(load-file "~/.custom_osxws.el"))
(t
; その他のEmacs用初期化ファイル
(if (file-exists-p "~/.emacs.el")
(load-file "~/.emacs.el"))
(if (file-exists-p "~/.custom.el")
(load-file "~/.custom.el")))
)
$ cat ~/.custom_osxws.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; .custom for MacOS X [[WorkShop]] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq custom-file "~/.custom_osxws.el")
ユーザーは設定をここで行います。ユーザーが弄りそうな設定をサンプルの形で 提供します。
$ cat ~/.emacs_osxws.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ~/.emacs_osxws.el ;; .emacs for MacOS X [[WorkShop]] ;; Time-stamp: <07/03/07 16:41:26 tkoba> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; 初期設定ファイルの指定 (setq user-init-file "~/.emacs_osxws.el") ;;; C-h と Backspace の入れ替え ;;; 前一文字削除が Ctrl + h に割当てられます ;(keyboard-translate ?\C-h ?\C-?) ;(global-set-key "\C-h" nil) ;;; コマンド、コントロール、オプションの各キーを ;;; alt, control, hyper, meta, super ;;; の各キーとして利用 ;(setq mac-command-modifier 'alt) ;(setq mac-control-modifier 'control) ;(setq mac-option-modifier 'meta) ;;; gzファイルも編集できるように ;(auto-compression-mode t) ;;; 一行が 80 字以上になった時には自動改行する ;(setq fill-column 80) ;(setq text-mode-hook 'turn-on-auto-fill) ;(setq default-major-mode 'text-mode) ;;; 起動時に message を表示しない ;(setq inhibit-startup-message t) ;;; visible-bell ;(setq visible-bell t) ;;; 行番号を表示する ;(line-number-mode t) ;;; mule/emacs -nw で起動した時にメニューバーを消す ;(if window-system (menu-bar-mode 1) (menu-bar-mode -1)) ;;; バッファの最後でnewlineで新規行を追加するのを禁止する ;(setq next-line-add-newlines nil) ;;; 画面最下行で[↓]を押したときのスクロール数 ;(setq scroll-step 1) ;;; mark 領域に色付け ;(setq transient-mark-mode t) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; [[CarbonEmacs]]ウィンドウモードの設定 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;(when (eq window-system 'mac) ;; fixed-width-fontset (carbon-font) ;(require 'carbon-font) ;(fixed-width-set-fontset "hiramaru" 14) ;; color-theme ;; M-x color-theme-?によってカラーテーマを変更できます。 ;(require 'color-theme) ;(color-theme-dark-blue2) ;(color-theme-ld-dark) ;(color-theme-gnome2) ;(color-theme-wheat) ;; 透過ウィンドウ Transparency3 ;(add-to-list ; 'default-frame-alist ; '(alpha . (90 40))) ;; (alpha . (<active frame> <non active frame>)) ;(setq frame-alpha-lower-limit 20) ;; アンチエイリアス ;(setq mac-allow-anti-aliasing t) ;) ;; End:
(add-to-list 'global-mode-string '("" default-directory "-"))
(setq scalable-fonts-allowed nil)
(when (eq window-system 'mac) (require 'mac-key-mode) (mac-key-mode 1))
(setq visible-bell t)
(add-hook
'yatex-mode-hook
'(lambda ()
(smart-dnd-setup
'(
("\\.tex\\'" . "\\input{%r}\n")
("\\.cls\\'" . "\\documentclass{%f}\n")
("\\.sty\\'" . "\\usepackage{%f}\n")
("\\.eps\\'" . "\\includegraphics[clip]{%r}\n")
("\\.ps\\'" . "\\includegraphics[clip]{%r}\n")
("\\.pdf\\'" . "\\includegraphics[clip]{%r}\n")
("\\.jpg\\'" . "\\includegraphics[clip]{%r}\n")
("\\.png\\'" . "\\includegraphics[clip]{%r}\n")
("\\.bst\\'" . "\\bibliographystyle{%n}\n")
("\\.bib\\'" . "\\bibliography{%n}\n")))))
(auto-compression-mode t)
(put 'eval-expression 'disabled nil)
(setq load-path (append '("~/lib/emacs") load-path))
(setq cursor-in-non-selected-windows nil)
(keyboard-translate ?\C-h ?\C-?)
(global-set-key "\C-h" nil)
;;; Command-? を help にする
;(global-set-key [(alt \?)] 'help)
(defun load-file (file) "Load the Lisp file named FILE." ;; This is a case where .elc makes a lot of sense. (interactive (list (let ((completion-ignored-extensions (remove ".elc" completion-ignored-extensions))) (read-file-name "Load file: ")))) (load (expand-file-name file) nil nil t))