s

会社 PC の .emacs 設定

会社 PC の .emacs 設定

wb-line-number http://homepage1.nifty.com/blankspace/emacs/wb-line-number.html

kill-summary.el http://mibai.tec.u-ryukyu.ac.jp/~oshiro/Programs/elisp/kill-summary.el

kill-summary.el の234行目を修正して、truncate-string を truncate-string-to-width に変更

mac で利用する時は、"C-xC-h" を "C-xC-h" のように変更する必要がある


;;;; -*- mode: lisp-interaction; syntax: elisp; coding: utf-8-unix -*-
;; ~/elisp をライブラリパスに追加
(setq load-path
      (append
       (list
    (expand-file-name "~/elisp/")
    )
       load-path))

;; 日本語設定 (UTF-8)
(set-language-environment "Japanese")
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)

;; ChangeLog の設定
(setq user-full-name "Xxx Xxx")
(setq user-mail-address "xxx@xxx.com")
(defun memo ()
  (interactive)
    (add-change-log-entry
     nil
     (expand-file-name "~/memo/diary.txt")))
(define-key ctl-x-map "M" 'memo)

;; タブの基本設定
(setq tab-width 4)
(setq c-basic-offset 4)

;; フォントロックモード (強調表示等) を有効にする
(global-font-lock-mode t)

;; 一時マークモードの自動有効化
(setq-default transient-mark-mode t)

;; C-x C-u が何もしないように変更する (undo の typo 時誤動作防止)
(global-unset-key "C-xC-u")

;; 括弧の対応をハイライト.
(show-paren-mode 1)

;; バッファ末尾に余計な改行コードを防ぐための設定
(setq next-line-add-newlines nil)

;; C-x l で goto-line を実行
(define-key ctl-x-map "l" 'goto-line)

;; 時間を表示
(display-time)

;; 列数表示
(column-number-mode 1)

;; メニューバーを消す
(menu-bar-mode -1)

;; バックアップファイルを作成しない
(setq make-backup-files nil)

;; grep-find の結果に .svn ディレクトリを含まないようにする(mac だとこの方法ではうまくいかない)
(setq grep-find-command "find . -type f -path '*.svn*' -prune -o -print0 | xargs -0 -e grep -nH -e ")

;; C-h でカーソルの左にある文字を消す
(define-key global-map "C-h" 'delete-backward-char)

;; C-h に割り当てられている関数 help-command を C-x C-h に割り当てる
(define-key global-map "C-xC-h" 'help-command)

;; C-z のキーバインドを開放
(global-unset-key "C-z")

;; toggle-truncate-lines を "C-z l" に定義する
(define-key global-map "C-zl" 'toggle-truncate-lines)

;; 画面の左端に行番号を表示できるように
(require 'wb-line-number)
;; "C-z n" に定義する
(define-key global-map "C-zn" 'wb-line-number-toggle)

;; C-o に動的略語展開機能を割り当てる
;;(define-key global-map "C-o" 'dabbrev-expand)
;;(setq dabbrev-case-fold-search nil) ; 大文字小文字を区別

;; 日本語・英語混じり文での区切判定
;; http://www.alles.or.jp/~torutk/oojava/meadow/Meadow210Install.html
(defadvice dabbrev-expand
  (around modify-regexp-for-japanese activate compile)
  "Modify `dabbrev-abbrev-char-regexp' dynamically for Japanese words."
  (if (bobp)
      ad-do-it
    (let ((dabbrev-abbrev-char-regexp
           (let ((c (char-category-set (char-before))))
             (cond
              ((aref c ?a) "[-_A-Za-z0-9]") ; ASCII
              ((aref c ?j) ; Japanese
               (cond
                ((aref c ?K) "cK") ; katakana
                ((aref c ?A) "cA") ; 2byte alphanumeric
                ((aref c ?H) "cH") ; hiragana
                ((aref c ?C) "cC") ; kanji
                (t "cj")))
              ((aref c ?k) "ck") ; hankaku-kana
              ((aref c ?r) "cr") ; Japanese roman ?
              (t dabbrev-abbrev-char-regexp)))))
      ad-do-it)))

;; BS で選択範囲を消す
(delete-selection-mode 1)

;; The local variables list in .emacs と言われるのを抑止
(add-to-list 'ignored-local-variables 'syntax)

;; ミニバッファ中での補完機構を補強
(iswitchb-mode t)

;; kill リングバッファの内容を表示しながらヤンクできるようにする
(autoload 'kill-summary "kill-summary" nil t)
(define-key global-map "ey" 'kill-summary)

;; php-mode
(autoload 'php-mode "php-mode")
(setq auto-mode-alist
      (cons '(".php'" . php-mode) auto-mode-alist))
(setq php-mode-force-pear t)
(add-hook 'php-mode-user-hook
  '(lambda ()
     (setq tab-width 4)
     (setq c-basic-offset 4)
     (setq indent-tabs-mode nil)
     (setq php-manual-path "/usr/local/share/php/doc/html")
     (setq php-manual-url "http://www.phppro.jp/phpmanual/")))

;;;; ruby-mode (要 ruby-mode.el)
(autoload 'ruby-mode "ruby-mode"
  "Mode for editing ruby source files" t)
(setq auto-mode-alist
      (append '((".rb$" . ruby-mode)) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
                                     interpreter-mode-alist))
(autoload 'run-ruby "inf-ruby"
  "Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby"
  "Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook
          '(lambda ()
            (inf-ruby-keys)))

;; cperl-mode の設定。インデントをいい感じに、他。
(autoload 'perl-mode "cperl-mode" "alternate mode for editing Perl programs" t)
(setq cperl-auto-newline t)
(setq cperl-indent-parens-as-block t)
(setq cperl-close-paren-offset -4)
(setq cperl-indent-level 4)
(setq cperl-label-offset -4)
(setq cperl-continued-statement-offset 4)
(setq cperl-highlight-variables-indiscriminately t)
(add-hook 'cperl-mode-hook
          (lambda ()
            (set-face-italic-p 'cperl-hash-face nil)))
(add-hook 'cperl-mode-hook
      '(lambda ()
         (define-key cperl-mode-map "C-cc" 'cperl-check-syntax)
         (setq indent-tabs-mode nil)))

;; リセットされた場合に UTF-8 に戻す
;; http://0xcc.net/blog/archives/000041.html
(set-default-coding-systems 'utf-8)