夏だからCarbon Emacs の設定をごにょごにょしたよ!


先々月にHDDの交換をして以降、最初から環境を作り直したのですが、今日はしばらく手を付けてなかったCarbon Emacs環境を作り直していました。
ここらで成果報告しときます。

環境

Mac OSX Snow Leopard
Carbon Emacs 2009夏

導入プラグイン

■elscreen
GNU Screenのような複数タブに

howm
一人wikiライクなEmacs環境

■tramp
リモートファイルをそのまま編集

simple-hatena-mode
はてなダイアリー編集モード

■auto-complete.el
IDEライクな補完

anything.el
正直どう使うのかわかってない

navi2ch
2chブラウザ

■session.el
最後のバッファの状態を復元

■magit.el
emacsでgitを扱えるようにする拡張らしいが、今からgit勉強する

あとでやる

Mew
ecb
w3m

参考:
テキスト入力中に補完候補を自動的に表示してくれる auto-complete.el をリリースしました ― ありえるえりあ
Tricorn Labs » TRAMP で楽々リモート開発
ZaurusSL-C3000/初期設定/ドットemacs - ドットemacsの内容について
Simple-hatena-modeの導入&実行テスト - mizchi log
session.el の設定を変更 - gan2 の Ruby 勉強日記
emacsでtwitter,twittering-modeを使い始めた - Unix的なアレ


「続きを読む」以下に.emacs.el置いておきますね

;;PATH
(setq load-path (cons (expand-file-name "~/.emacs.d/elisp") load-path))

;;elscreen
(require 'elscreen)
(setq elscreen-prefix-key "\C-z")

;simple-hatena-mode
(require 'simple-hatena-mode)

;twittering-mode
(require 'twittering-mode)


;;session.el
(when (require 'session nil t)
  (setq session-initialize '(de-saveplace session keys menus places)
        session-globals-include '*1



;;auto-complete
(require 'auto-complete)
(global-auto-complete-mode t)

;; Tramp
(require 'tramp)
(setq tramp-default-method "sshx")
(add-to-list
  'tramp-multi-connection-function-alist
  '("sshx" tramp-multi-connect-rlogin "ssh -t %h -l %u /bin/sh%n"))
(add-to-list
  'tramp-multi-connection-function-alist
  '("sshp10022" tramp-multi-connect-rlogin "ssh -t %h -l %u -p 10022 /bin/sh%n"))

;;anything.el
(require 'anything-config)

;; Navi2ch
(autoload 'navi2ch "navi2ch" "Navigator for 2ch for Emacs" t)
(setq navi2ch-icon-directory
      (cond
       *2
;; (set-frame-font "fontset-default")

(set-face-attribute 'default nil
                    :family "Verdana"
                    :height 140)
(set-fontset-font "fontset-default"
                  'japanese-jisx0208
                  '("ヒラギノ角ゴ pro w3*" . "jisx0208.*"))
(set-fontset-font "fontset-default"
                  'katakana-jisx0201
                  '("ヒラギノ角ゴ pro w3*" . "jisx0201.*"))
(add-to-list 'face-font-rescale-alist
             `(,(encode-coding-string ".*ヒラギノ角ゴ pro w3.*" 'emacs-mule) . 1.2))

;(server-start)

(setq c-tab-always-indent t)
(setq default-tab-width 4)
(setq indent-line-function 'indent-relative-maybe) ; 前と同じ行の幅にインデント

(setq backup-inhibited t)
(setq delete-auto-save-files t)

;;Mac用の設定
(setq mac-allow-anti-aliasing nil)
(setq mac-option-modifier 'meta)
(mac-key-mode 1)

;;キーアサイン
(global-set-key "\C-x\C-i" 'indent-region) ; 選択範囲をインデント
(global-set-key "\C-m" 'newline-and-indent) ; リターンで改行とインデント
;(global-set-key "\C-j" 'newline)            ; 改行
(global-set-key "\C-cc" 'comment-region)    ; C-c c を範囲指定コメントに
(global-set-key "\C-cu" 'uncomment-region)  ; C-c u を範囲指定コメント解除に
(global-set-key "\C-cu" 'uncomment-region)


(show-paren-mode t) ; 対応する括弧を光らせる。
(transient-mark-mode t) ; 選択部分のハイライト

(setq require-final-newline t)          ; always terminate last line in file
(setq default-major-mode 'text-mode)    ; default mode is text mode

(setq completion-ignore-case t) ; file名の補完で大文字小文字を区別しない
(setq partial-completion-mode 1) ; 補完機能を使う

;; スタートアップメッセージを非表示
(setq inhibit-startup-message t)
(if window-system (progn
                   
; ツールバーの非表示
(tool-bar-mode 1)))

(mac-add-ignore-shortcut '(control))
(put 'downcase-region 'disabled nil)


;;参考:http://d.hatena.ne.jp/suztomo/20080923/1222149517
(setq compilation-window-height 10)

(when (eq window-system 'mac)
  (add-hook 'window-setup-hook
            (lambda ()
;;              (setq mac-autohide-menubar-on-maximize t)
              (set-frame-parameter nil 'fullscreen 'fullboth)
              )))

(defun mac-toggle-max-window ()
  (interactive)
  (if (frame-parameter nil 'fullscreen)
      (set-frame-parameter nil 'fullscreen nil)
    (set-frame-parameter nil 'fullscreen 'fullboth)))


;; Carbon Emacsの設定で入れられた. メニューを隠したり.
(custom-set-variables
 '(display-time-mode t)
 '(tool-bar-mode nil)
 '(transient-mark-mode t))
(custom-set-faces
 )

(if window-system (progn
                   
   (add-to-list 'default-frame-alist '(foreground-color . "CadetBlue1"))
   (set-background-color "Black")
   (set-foreground-color "LightGray")
   (set-cursor-color "Gray")
   (set-frame-parameter nil 'alpha 90)
   (set-face-foreground 'mode-line-inactive "gray30");; モードライン(アクティブでないバッファ)の文字色を設定します
   (set-face-background 'mode-line-inactive "gray80");; モードライン(アクティブでないバッファ)の背景色を設定します。
))

(add-to-list 'default-frame-alist '(foreground-color . "White"))

;;スクロールバーを隠す
(setq default-frame-alist
      (append (list '(menu-bar . nil)
                    '(vertical-scroll-bars . nil))
               default-frame-alist))

;;インデント
(setq indent-line-function
      'indent-relative-maybe)

;;ビープ音を消す
(setq ring-bell-function 'ignore)


;;org-mode
(global-set-key "\M-ot" 'change-width-return)
(defun change-width-return()
 (interactive)
  (setq truncate-lines nil)
  (setq truncate-partial-width-windows nil)
 )

;;howm-menu
(setq howm-menu-lang 'ja)
(require 'howm)

;; リンクを TAB で辿る
(eval-after-load "howm-mode"
 '(progn
    (define-key howm-mode-map [tab] 'action-lock-goto-next-link)
    (define-key howm-mode-map [(meta tab)] 'action-lock-goto-previous-link)))

;; 「最近のメモ」一覧時にタイトル表示
(setq howm-list-recent-title t)
;; 全メモ一覧時にタイトル表示
(setq howm-list-all-title t)

;(add-hook 'howm-mode-on-hook 'auto-fill-mode)

;; RET でファイルを開く際, 一覧バッファを消す
;; C-u RET なら残る
(setq howm-view-summary-persistent nil)

(if (not (memq 'delete-file-if-no-contents after-save-hook))
(setq after-save-hook
   (cons 'delete-file-if-no-contents after-save-hook)))

(defun delete-file-if-no-contents ()
  (when (and
     (buffer-file-name (current-buffer))
        (string-match "\\.howm" (buffer-file-name (current-buffer)))
        (= (point-min) (point-max)))
   (delete-file
    (buffer-file-name (current-buffer)))))

;; C-cC-c で保存してバッファをキルする
(defun my-save-and-kill-buffer ()
 (interactive)
 (when (and
        (buffer-file-name)
        (string-match "\\.howm"
              (buffer-file-name)))
   (save-buffer)
   (kill-buffer nil)))
(eval-after-load "howm-mode"
 '(progn
    (define-key howm-mode-map
      "\C-c\C-c" 'my-save-and-kill-buffer)))

(defadvice howm-mode
 (before outline-minor activate)
 (outline-minor-mode t))

(require 'outline)
(defun my-outline-flip-subtree (&optional dummy)
 (interactive)
 (if (save-excursion
       (forward-line 1)
       (let *3
         (while (and p (not ol))
           (setq ol (overlay-get (car p) 'invisible))
           (setq p (cdr p)))
         ol))
     (show-subtree)
   (hide-subtree)))

(defun add-my-action-lock-rule ()
 (let *4
             "^ *\\(\\*\\**\\)"
           (concat "\\(" outline-regexp "\\)"))
         1 1)))
   (if (not (member rule action-lock-default-rules))
       (progn (setq action-lock-default-rules
                    (cons rule action-lock-default-rules))
              (action-lock-set-rules action-lock-default-rules)))))
(add-hook 'action-lock-mode-on-hook 'add-my-action-lock-rule)


<|

*1:kill-ring 50) (session-file-alist 500 t) (file-name-history 10000))) ;; これがないと file-name-history に500個保存する前に max-string に達する (setq session-globals-max-string 100000000) ;; デフォルトでは30! (setq history-length t) (add-hook 'after-init-hook 'session-initialize

*2:featurep 'mac-carbon) "/Applications/Emacs.app/Contents/Resource/etc/navi2ch") ((featurep 'dos-w32) "d:/cygwin/usr/local/emacs/etc/navi2ch"))) ;; 偶に、url が変わる事がある。 ;; (setq navi2ch-list-bbstable-url "http://menu.2ch.net/bbsmenu.html") ;;文字 (set-language-environment 'Japanese) (set-default-coding-systems 'utf-8-unix) (set-terminal-coding-system 'utf-8-unix) (set-keyboard-coding-system 'sjis-mac) (set-clipboard-coding-system 'sjis-mac) (setq-default buffer-file-coding-system 'utf-8) (prefer-coding-system 'utf-8) (add-to-list 'default-frame-alist '(font . "fontset-default"

*3:p (overlays-at (line-beginning-position))) (ol nil

*4:rule (action-lock-general 'my-outline-flip-subtree (if (and buffer-file-name (string-match "\\.howm$" buffer-file-name