MacOSX WorkShop/dot emacs el
MacOSX_WorkShop の「OSX-Preferences」と「emacs-lisps」で提供されている Emacs の設定ファイルを議論します。
目次
基本方針
- VineLinux の設定を基準にする。
OSXWS は大学や研究機関の計算機管理者が導入し、管理者権限を持たない学生さんやユーザーが利用する事を念頭に置いて下さい。
- 変更事項はその理由を明記する。
複数人の趣味に偏るのを避ける為にも必要です。
- 修正案の作り方
このWiki上で修正案を作る方法として、取り除くほうが良いと考えている物を「(取り除いた項目)」に移し、追加したいと考えているものを実際に追加し「(追加した項目)」に記入するようにしています。それにコメント、指摘を書き込んで頂けたら助かります。
- inline-patch や transparency patch 等 upstream で仕様が今後も変更される確率が高く、且つ、OSXWS としてのデフォルトなど基本的な設定は、site-start.d 内で行う。
OSXWS-10.5-x の emacs 設定ファイル
グローバル共通
OSXWSのEmacs は起動時に/private/etc/emacs-[EMACSVER]/site-start.d/を読みに行きます。 ここでは、upstream で今後も改変が予想される設定と、OSXWS のデフォルト設定を行います。これは、distribution 全体としての整合性や体裁(つまり、「街」としての機能を保つこと)を目的とします。ユーザーが自分の ~/.*.el を書き損じても、それら全てを無効にすれば OSXWS としての CarbonEmacs の機能が一通り利用できる事を目指します。
$ cat /usr/osxws/etc/emacs-[EMACSVER]/site-start.d/99osxws.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; osxws.el for MacOS X WorkShop ;; KOBAYASHI Taizo <xxxxxxx@xxxxxxx> ;; Time-stamp: <2008-07-03 16:14:10 tkoba> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; setting the MacOS X WorkShop flag (defconst osxws-emacs-flag t "This is Emacs of MacOS X WorkShop.") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Local Variables: ;; mode: emacs-lisp ;; buffer-file-coding-system: junet-unix ;; End:
$ cat /usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec0.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Section 0 fundamental configurations ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; save the position before you editing. (require 'saveplace) (setq-default save-place t) (setq save-place-file "~/Library/Application Support/OSXWS/emacs-places.txt") ;; copy foo to foo~ as a backup file (setq backup-by-copying t) ;;; start emacsclient server (server-start)
$ cat /usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec1.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Section 1 language configurations ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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 'utf-8) (set-keyboard-coding-system (if window-system 'sjis-mac 'utf-8)) (load "menu-tree")))
$ cat /usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec2.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Section 2 appearance setting ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; hide tool-bar (tool-bar-mode nil) ;;; show the corresponding paren (require 'paren) (show-paren-mode) ;;; colorizing mark region (setq transient-mark-mode t) ;;; do not font scaling (setq scalable-fonts-allowed nil) ;;; show line number (line-number-mode t) ;;; show the present time on status bar (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) ;;; Time Stamp ;;; If you put 'Time-stamp: <>' or 'Time-stamp: ""' on ;;; top 8 lines of the file, the '<>' or '""' are filled with the date ;;; at saving the file. (require 'time-stamp) (if (not (memq 'time-stamp write-file-functions)) (setq write-file-functions (cons 'time-stamp write-file-functions)))
$ cat /usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec3.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Section 3 keyboard/keybindig ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; use "command", "control", "option" keys as ;;; alt, control, hyper, meta, super keys (setq mac-command-modifier 'alt) (setq mac-control-modifier 'control) (setq mac-option-modifier 'meta) (cua-selection-mode t) ;;; revert [Home] Key and [End] Key (define-key global-map [home] 'beginning-of-buffer) (define-key global-map [end] 'end-of-buffer) ;;; mac-key-mode ;; (short cut of OSX applications) (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) ; Greek (#x400 . #x4ff) ; Cyrillic (#x2000 . #x206f) ; punctuation mark (#x2103 . #x2103) ; centigrade degree (#x212b . #x212b) ; angstrom (#x2190 . #x21ff) ; Arrow (#x2200 . #x22ff) ; mathematical symbol (#x2300 . #x23ff) ; engineering symbol (#x2460 . #x2473) ; number in circle (#x2500 . #x257f) ; ruled line (#x25a0 . #x25ff) ; mosaic fragment (#x2600 . #x26ff) ; other symbol )) ;; 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-\\])
$ cat /usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec4.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Section 4 shell-command ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; hide 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)
$ cat /usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec5.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Section 5 inline-patch by Hashimoto-san ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (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")) ;; start up by Command-Space (global-set-key [(alt \ )] 'toggle-input-method) ;; start up by Shift-Space (global-set-key [?\S-\ ] 'toggle-input-method)
$ cat /usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec6.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Section 6 CarbonEmacs window mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (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 ;; You can change the color theme by 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) ;; anti alias (drag and drop) (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>"))))) ;;---------------------------------------------------------- )
$ cat /usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec7.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Section 7 anything else ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Yatex (if (file-exists-p "~/.yatex.el") (load-file "~/.yatex.el")) ;; Mew 6.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")) (setq next-line-add-newlines nil) (setq scroll-step 1)
ローカル共通
.emacsでは条件分岐のみを行います。他のEmacsに別の初期設定を行いたい場合もここから読み込むように設定します。
$ cat ~/.emacs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; loading init files ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (cond ((boundp 'osxws-emacs-flag) ; for Mac OS X WorkShop (load-file "~/.emacs_osxws.el") (load-file "~/.custom_osxws.el")) (t ; for others (if (file-exists-p "~/.emacs.el") (load-file "~/.emacs.el")) (if (file-exists-p "~/.custom.el") (load-file "~/.custom.el"))) )
OSXWSのEmacs専用custom 用ファイル
M-x customize による設定が書き込まれるファイルです。
$ cat ~/.custom_osxws.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; .custom for MacOS X [[WorkShop]] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq custom-file "~/.custom_osxws.el")
OSXWSのEmacs専用 .emacs
OSXWS 固有の設定をここで読み込みます。従って、ユーザーは殆ど全ての設定をここで選択できます。
$ cat ~/.emacs_osxws.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ~/.emacs_osxws.el ;; .emacs for MacOS X WorkShop ;; Time-stamp: <2008-07-03 18:24:55 tkoba> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq user-init-file "~/.emacs_osxws.el") ;; Section 0 fundamental configurations (load-file "/usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec0.el") ;; Section 1 language setting (load-file "/usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec1.el") ;; Section 2 appearance setting (load-file "/usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec2.el") ;; Section 3 keyboard/keybindig setting (load-file "/usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec3.el") ;; Section 4 shell-command setting (load-file "/usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec4.el") ;; Section 5 inline-patch setting (load-file "/usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec5.el") ;; Section 6 CarbonEmacs window mode setting (load-file "/usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec6.el") ;; Section 7 anything else setting (load-file "/usr/osxws/share/emacs/site-lisp/emacs-lisps/osxws-sec7.el") ;; End:
YaTeXの設定ファイル
.emacs_osxws.elから読み込まれます。
$ cat .yatex.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ~/.yatex.el for MacOS X WorkShop ;; KOBAYASHI Taizo <xxxxxxxxx@xxxxxx.com> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; yatex の設定 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) ;; platex と Skim (setq tex-command "platex2pdf-utf8" dvi2-command "open -a Skim") ;; platex と Mxdvi ;(setq tex-command "platex --src-special" ; dvi2-command "mxdvi") ;; platex と TeXShop ;(setq tex-command "~/Library/TeXShop/bin/platex2pdf-euc" ; dvi2-command "open -a TeXShop") ;; pdflatex と TeXShop ;(setq tex-command "pdflatex" ; dvi2-command "open -a TeXShop") (setq dviprint-command-format "dvips %s | lpr" YaTeX-kanji-code 4 ; (1 JIS, 2 SJIS, 3 EUC, 4 UTF-8) YaTeX-use-AMS-LaTeX t ; AMS-LaTeX section-name "documentclass" makeindex-command "mendex -U" bibtex-command "jbibtex -kanji=utf8" YaTeX-skip-default-reader t YaTeX-latex-message-code 'utf-8 YaTeX-use-font-lock t ) (add-hook 'skk-mode-hook (lambda () (if (eq major-mode 'yatex-mode) (progn (define-key skk-j-mode-map "\\" 'self-insert-command) (define-key skk-j-mode-map "$" 'YaTeX-insert-dollar) )) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; yahtml の設定 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq auto-mode-alist (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) (add-to-list 'auto-mode-alist '("\\.htm\\'" . yahtml-mode)) (setq yahtml-www-browser "open" yahtml-lint-program "htmllint" yahtml-kanji-code 4) (add-hook 'yahtml-mode-hook '(lambda () (auto-fill-mode -1) )) ;;;; 常に<p>をいれたら</p> (setq yahtml-always-/p t) ;;;; 常に<li>をいれたら</li> (setq yahtml-always-/li t) ;; End:
- 変更箇所
変更点
(追加した項目)
(削除した項目)
10.4 Tiger 版に関する議論
http://www.bach-phys.ritsumei.ac.jp/OSXWS/node60.html
コメント
- インラインパッチは先週のを使って下さい。透明パッチは Emacs 23 互換の transparency4 をお薦めします。 --ぜ 2008年7月5日 (土) 23:59 (UTC)
- utf-8 で問題なければ、そちらの方が良いと思います。(瀬戸さんのを真似て、ずっと sjis-mac にしていました) --ぜ 2008年7月5日 (土) 23:54 (UTC)
- 133.5.165.65 です.OSX-Preferences が update されていて,/usr/osxws/share/OSXWS/jp/.emacs_osxws.el が修正されていることを確認しました.対応していただきありがとうございました. --218.41.210.88 2008年7月5日 (土) 12:25 (UTC)
- set-keyboard-coding-system は、windowモードのときにsjis-macにする必要があるでしょうか?(utf-8 にして試してみたら問題なく入力できるようでしたので。) --Seto 2008年7月5日 (土) 09:02 (UTC)
- .emacs_osxws.elなどは、/usr/osxws/share/OSXWS/jp/ or en/ 以下にあります。 --Seto 2008年7月5日 (土) 07:48 (UTC)
- 上の.yatex.elが古かったので、新しい方を貼付けました。 --193.52.24.125 2008年7月5日 (土) 07:42 (UTC)
- 先ほどOSXWS10.5をクリーンインストールしましたが,現状では ~/.emacs_osxws.el に osxws-sec?.el などをロードする設定が書かれていないようです. --133.5.165.65 2008年7月4日 (金) 08:28 (UTC)
- 改善提案はもちろん、英語の間違いもドンドンたたいてやってください。 --Tkoba 2008年7月3日 (木) 10:00 (UTC)