暮らしの技術

暮らしを豊かにする技術や、特に暮らしを豊かにしない技術があります

Emacs23の設定

24でpackage.elでの運用にするといろいろ修正がいる.

;;---------------------------------------------------
;;
;; Emacs全般の設定
;;---------------------------------------------------

;; 起動時に出てくるメッセージを消す
(setq inhibit-startup-message t)

;; 行、列の表示
(line-number-mode t)
(column-number-mode t)

;; C-h to Backspace
(global-set-key "\C-h" 'delete-backward-char)

;; C-c C-c to comment-or-uncomment-region
(global-set-key "\C-c\C-c" 'comment-or-uncomment-region)

;; C-kで行全体を削除
(setq kill-whole-line t)


;; ツールバー・メニューバーの非表示
;; (menu-bar-mode -1)
;; (tool-bar-mode -1)

;; タブ幅を設定
(setq-default tab-width 4 indent-tabs-mode nil)

;; ビジュアルベルを使う
;; (setq visible-bell t)

;; ビープを無効に
(setq ring-bell-function 'ignore)

;; 折り返し
(setq truncate-partial-width-windows nil)

;; シンボリックリンクのリンク先を直接開く
(setq vc-follow-symlinks t)

;; ファイルの自動リロードです
(global-auto-revert-mode 1)

;;----------------------------------------------------
;;
;; Text and Font
;;----------------------------------------------------

;; 背景色と文字色
(setq default-frame-alist
      (append
       '((foreground-color . "ivory")
         (background-color . "black")
         (cursor-color . "deep pink")
         (alpha . (75 55 nil nil)))
       default-frame-alist))

;; フォントを指定
(set-face-attribute 'default nil
                   :family "Ricty"
                   :height 160)
(set-fontset-font
 nil 'japanese-jisx0208
 (font-spec :family "Ricty"))

;;---------------------------------------------------
;;
;; 機能拡張
;;---------------------------------------------------


;;画面を 2 分割したときの 上下を入れ替える swap screen
(defun swap-screen()
  "Swap two screen,leaving cursor at current window."
  (interactive)
  (let ((thiswin (selected-window))
        (nextbuf (window-buffer (next-window))))
    (set-window-buffer (next-window) (window-buffer))
    (set-window-buffer thiswin nextbuf)))
(defun swap-screen-with-cursor()
  "Swap two screen,with cursor in same buffer."
  (interactive)
  (let ((thiswin (selected-window))
        (thisbuf (window-buffer)))
    (other-window 1)
    (set-window-buffer thiswin (window-buffer))
    (set-window-buffer (selected-window) thisbuf)))
(global-set-key [f2] 'swap-screen)
(global-set-key [S-f2] 'swap-screen-with-cursor)

;; 対応する括弧をハイライト
(show-paren-mode t)
(setq show-paren-style 'expression)
(set-face-background 'show-paren-match-face "gray15")
(set-face-foreground 'show-paren-match-face "white")


;;---------------------------------------------------
;;
;; coffee-mode.el
;;---------------------------------------------------

(require 'coffee-mode)

(defun coffee-custom ()
  "coffee-mode-hook"

  ;; CoffeeScript uses two spaces.
  (set (make-local-variable 'tab-width) 2)

  ;; If you don't have js2-mode
  (setq coffee-js-mode 'javascript-mode)

  ;; If you don't want your compiled files to be wrapped
  (setq coffee-args-compile '("-c" "--bare"))

  ;; *Messages* spam
  (setq coffee-debug-mode t)

  ;; Emacs key binding
  (define-key coffee-mode-map [(meta r)] 'coffee-compile-buffer)

  ;; Riding edge.
  (setq coffee-command "/opt/local/bin/coffee")

  ;; Compile '.coffee' files on every save
  (and (file-exists-p (buffer-file-name))
       (file-exists-p (coffee-compiled-file-name))
       (coffee-cos-mode t)))

(add-hook 'coffee-mode-hook 'coffee-custom)
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(column-number-mode t)
 '(show-paren-mode t)
 '(tool-bar-mode nil))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )


;;---------------------------------------------------
;;
;; auto-install.el
;;---------------------------------------------------
(require 'auto-install)
(setq auto-install-directory "~/.emacs.d/auto-install/")
(auto-install-update-emacswiki-package-name t)
;; (setq url-proxy-service '(("http". "localhost:8339")))
(auto-install-compatibility-setup)

;;---------------------------------------------------
;;
;; anything
;;---------------------------------------------------

(require 'anything-startup)
;; open anything by C-l
(global-set-key "\C-l" 'anything)
(require 'anything-config)
(setq anything-sources (list anything-c-source-buffers
                    anything-c-source-bookmarks
                    anything-c-source-recentf
                    anything-c-source-file-name-history
;                    anything-c-source-locate
                    anything-c-source-mac-spotlight
                    anything-c-source-complex-command-history))



;;---------------------------------------------------
;;
;; auto-complete
;;---------------------------------------------------

(add-to-list 'load-path (expand-file-name "~/.gem/ruby/1.9.1/gems/rcodetools-0.8.5.0/"))
(when (require 'auto-complete nil t)
  (require 'auto-complete-config)
;;  (require 'auto-complete-ruby)

  (global-auto-complete-mode t)
  (set-face-background 'ac-candidate-face "lightgray")
  (set-face-underline 'ac-candidate-face "darkgray")
  (set-face-background 'ac-selection-face "steelblue")

  (define-key ac-complete-mode-map "\M-/" 'ac-start)
  (define-key ac-complete-mode-map "\t" 'ac-expand)
  (define-key ac-complete-mode-map "\r" 'ac-complete)
  (define-key ac-complete-mode-map "\M-n" 'ac-next)
  (define-key ac-complete-mode-map "\M-p" 'ac-previous)
  (define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
  (ac-set-trigger-key "TAB")

  (setq ac-auto-start 3)
  (setq ac-dwim t)
  (set-default 'ac-sources '(ac-source-yasnippet ac-source-abbrev ac-source-words-in-buffer))
  
  (add-hook 'auto-complete-mode-hook
            (lambda ()
              (add-to-list 'ac-sources 'ac-source-filename)
              (add-to-list 'ac-sources 'ac-source-words-in-buffer)))

  (add-hook 'c-mode-hook
            (lambda ()
              (setq ac-sources '(ac-source-gtags ac-source-yasnippet))))

  (setq ac-modes
        (append ac-modes
                '(eshell-mode
                                        ;org-mode
                  )))
                                        ;(add-to-list 'ac-trigger-commands 'org-self-insert-command)

  (add-hook 'emacs-lisp-mode-hook
            (lambda ()
              (setq ac-sources '(ac-source-yasnippet ac-source-abbrev ac-source-words-in-buffer ac-source-symbols))))

  (add-hook 'eshell-mode-hook
            (lambda ()
              (setq ac-sources '(ac-source-yasnippet ac-source-abbrev ac-source-files-in-current-dir ac-source-words-in-buffer))))

;;  (add-hook 'ruby-mode-hook
;;            (lambda ()
;;              (setq ac-omni-completion-sources '(("\\.\\=" ac-source-rcodetools)))))
  )


;;---------------------------------------------------
;;
;; howm-mode
;;---------------------------------------------------

;; ;; home-modeとorg-modeの共存
;; (require 'org)
;; (add-hook 'org-mode-hook 'howm-mode)
;; (add-to-list 'auto-mode-alist '("\\.howm$" . org-mode))
;; (setq howm-view-title-header "*") ;; ← howm のロードより前に書くこと

;; ;; キー割当の重複を避ける (お好みで)
;; (setq howm-prefix "\C-c ") ;; howm のキーを「C-c , □」から「C-z □」に変更

;; howmの読み込み
(push "~/.emacs.d/site-lisp/howm" load-path)
(setq howm-menu-lang 'ja)
(require 'howm-mode)
(setq howm-file-name-format "%Y/%m/%Y_%m_%d.howm")

;; howmディレクトリの指定
(setq howm-directory "~/Dropbox/howm/")


;;---------------------------------------------------
;;
;; org-mode
;;---------------------------------------------------

;; (setq org-export-latex-coding-system 'euc-jp-unix)
;; (setq org-export-latex-date-format "%Y-%m-%d")
;; (setq org-export-latex-classes nil)
;; (add-to-list 'org-export-latex-classes
;;   '("jarticle"
;;     "\\documentclass[a4j,10pt,twocolumn]{jarticle}"
;; ;;    "\\documentclass[a4j]{jarticle}"
;;     ("\\section{%s}" . "\\section*{%s}")
;;     ("\\subsection{%s}" . "\\subsection*{%s}")
;;     ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
;;     ("\\paragraph{%s}" . "\\paragraph*{%s}")
;;     ("\\subparagraph{%s}" . "\\subparagraph*{%s}")
;; ))

;

;;---------------------------------------------------
;;
;; ruby-mode
;;---------------------------------------------------

;; 括弧の後のインデントが深くなるのを防ぐ
(setq ruby-deep-indent-paren-style nil)