Ubuntu dot emacs

まだまだだけど、そこそこ使えるようになったので、保存。

;;========================================================================
;; base
;; https://wiki.ubuntulinux.jp/UbuntuTips/Application/EmacsJapaneseSetup
;;========================================================================
(cond (window-system
       (set-default-font
        "-*-fixed-medium-r-normal--12-*-*-*-*-*-*-*")
       (progn
         (set-face-font 'default
                        "-shinonome-gothic-medium-r-normal--12-*-*-*-*-*-*-*")
         (set-face-font 'bold
                        "-shinonome-gothic-bold-r-normal--12-*-*-*-*-*-*-*")
         (set-face-font 'italic
                        "-shinonome-gothic-medium-i-normal--12-*-*-*-*-*-*-*")
         (set-face-font 'bold-italic
                        "-shinonome-gothic-bold-i-normal--12-*-*-*-*-*-*-*")
       )))

;;=======================================================================
;; tdiary 
;;=======================================================================
(setq load-path
      (append
       (list
       (expand-file-name "~/elisp/")
       )
       load-path))

(setq psgml-html-build-new-buffer nil)
(setq tdiary-diary-list '(("SISY" "http://sisyphus.s3.xrea.com/tnikki/")))
(require 'tdiary-mode)
(setq tdiary-index-rb "index.cgi")
(setq tdiary-update-rb "update.cgi")

;;=======================================================================
;;日本語変換
;;=======================================================================
(set-language-environment "Japanese")
(load-library "anthy")
(setq default-input-method "japanese-anthy")

;;=======================================================================
;; Misc
;;=======================================================================
;;(mouse-wheel-mode)                                              ;;ホイールマウス
(setq-default transient-mark-mode t)                            ;;選択行を反転させる
(global-font-lock-mode t)                                       ;;文字の色つけ
(setq line-number-mode t)                                       ;;カーソルのある行番号を表示
(auto-compression-mode t)                                       ;;日本語infoの文字化け防止
(set-scroll-bar-mode 'right)                                    ;;スクロールバーを右に表示
(global-set-key "\C-z" 'undo)                                   ;;UNDO
(setq frame-title-format                                        ;;フレームのタイトル指定
        (concat "%b - emacs@" system-name))

(display-time)                                                 ;;時計を表示
(global-set-key "\C-h" 'backward-delete-char)                  ;;Ctrl-Hでバックスペース
;(setq make-backup-files nil)                                   ;;バックアップファイルを作成しない
;(setq visible-bell t)                                          ;;警告音を消す
;(setq kill-whole-line t)                                       ;;カーソルが行頭にある場合も行全体を削除


;;=======================================================================
;; Frame
;;=======================================================================
;;-----------------------------------------------------------------------
;; 初期フレームの設定
;;-----------------------------------------------------------------------
(setq default-frame-alist
      (append (list '(foreground-color . "LemonChiffon")
		    '(background-color . "black")
		    '(background-color . "gray")
		    '(border-color . "black")
		    '(mouse-color . "white")
		    '(cursor-color . "black")
		    )
	      default-frame-alist))
;; ---------------------------------------------------------------------
;; 終了時のフレームサイズを記憶する
;; http://www.bookshelf.jp/cgi-bin/goto.cgi?file=meadow&node=save%20framesize
;; ---------------------------------------------------------------------
(defun my-window-size-save ()
  (let* ((rlist (frame-parameters (selected-frame)))
         (ilist initial-frame-alist)
         (nCHeight (frame-height))
         (nCWidth (frame-width))
         (tMargin (if (integerp (cdr (assoc 'top rlist)))
                      (cdr (assoc 'top rlist)) 0))
         (lMargin (if (integerp (cdr (assoc 'left rlist)))
                      (cdr (assoc 'left rlist)) 0))
         buf
         (file "~/.framesize.el"))
    (if (get-file-buffer (expand-file-name file))
        (setq buf (get-file-buffer (expand-file-name file)))
      (setq buf (find-file-noselect file)))
    (set-buffer buf)
    (erase-buffer)
    (insert (concat
             ;; 初期値をいじるよりも modify-frame-parameters
             ;; で変えるだけの方がいい?
             "(delete 'width initial-frame-alist)\n"
             "(delete 'height initial-frame-alist)\n"
             "(delete 'top initial-frame-alist)\n"
             "(delete 'left initial-frame-alist)\n"
             "(setq initial-frame-alist (append (list\n"
             "'(width . " (int-to-string nCWidth) ")\n"
             "'(height . " (int-to-string nCHeight) ")\n"
             "'(top . " (int-to-string tMargin) ")\n"
             "'(left . " (int-to-string lMargin) "))\n"
             "initial-frame-alist))\n"
             ;;"(setq default-frame-alist initial-frame-alist)"
             ))
    (save-buffer)
    ))

(defun my-window-size-load ()
  (let* ((file "~/.framesize.el"))
    (if (file-exists-p file)
        (load file))))

(my-window-size-load)

;; Call the function above at C-x C-c.
(defadvice save-buffers-kill-emacs
  (before save-frame-size activate)
  (my-window-size-save))
;;=======================================================================
;; End
;;=======================================================================