emacsの設定

ホームフォルダ.emacsというファイルを作成します。

;; Anthy
(set-input-method "japanese-anthy")

;; toggle japanese key
(global-set-key "\C-o" 'toggle-input-method)

;; jump line number
(define-key esc-map "g" 'goto-line)

;; no back up
(setq make-backup-files nil)

;; compile
(global-set-key "\C-ck" 'compile)

;; setting tab
(setq-default tab-width 4)
(setq tab-stop-list
  '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80))

;; setting japanese (utfで)
(require 'un-define)
(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)
(auto-compression-mode t)

;; display buffer menu current buffer
(global-set-key "\C-x\C-b" 'buffer-menu)

;; display time
(setq display-time-string-forms
      '(month "/" day " " 24-hours ":" minutes ) )
(setq display-time-day-and-date t)
(display-time)

;; setting dired
(setq ls-lisp-dirs-first t)

;; hide password in shell mode
(add-hook 'comint-output-filter-functions
          'comint-watch-for-password-prompt)

;; language in shell mode
(add-hook 'shell-mode-hook (function
    (lambda () (set-buffer-process-coding-system 'utf-8 'utf-8))))

;; insert template file
(add-hook 'find-file-hooks 'auto-insert)
(setq auto-insert-directory "~/.emacs.d/insert-file/")
(load "autoinsert")
(setq auto-insert-alist
      (append (list
                '("\\.tex" . "template.tex")
                '("\\.cpp" . "template.cpp")
                ) auto-insert-alist)
      )

;; develop setting
;; to distinguish file extention
(setq auto-mode-alist
      (append (list
               '("\\.cpp$" . c++-mode)
               '("\\.c$" . c-mode)
               '("\\.h$" . c++-mode)
               '("\\.el$" . lisp-mode)
               '("\\.tex$" . yatex-mode)
               auto-mode-alist)))

;; color setting
(global-font-lock-mode t)

;; change beep bell flush
(setq visible-bell t)

;; font setting
(add-hook 'c-mode-hook
          '(lambda () (font-lock-mode 1)))
(add-hook 'c++-mode-hook '(lambda () (font-lock-mode 1)))
(add-hook 'objc-mode-hook '(lambda () (font-lock-mode 1)))
(add-hook 'html-helper-mode-hook '(lambda () (font-lock-mode 1)))
(add-hook 'tex-mode-hook '(lambda () (font-lock-mode 1)))
(add-hook 'latex-mode-hook '(lambda () (font-lock-mode 1)))
(add-hook 'java-mode-hook '       (lambda () (font-lock-mode 1)))
(add-hook 'lisp-mode-hook '       (lambda () (font-lock-mode 1)))
(add-hook 'font-lock-mode-hook
          '(lambda ()
             (my-font-lock-set-face)))

(defun my-font-lock-set-face ()
  ;; if & while etc...
  (make-face 'my-keyword-face)
  (set-face-bold-p 'my-keyword-face t)
  (set-face-foreground 'my-keyword-face "blue")
  (setq font-lock-keyword-face
        'my-keyword-face)
  ;; comment
  (make-face 'my-comment-face)
  (set-face-foreground 'my-comment-face "darkgreen")
  (setq font-lock-comment-face 'my-comment-face)
 
  ;; string table
  (make-face 'my-string-face)
  (set-face-foreground 'my-string-face "orange")
  (setq font-lock-string-face
        'my-string-face)

  ;; function name
  (make-face 'my-function-face)
  (set-face-foreground
   'my-function-face "red")
  (setq font-lock-function-name-face 'my-function-face)
 
  ;; typedef & class etc...
  (make-face 'my-type-face)
  ;;(make-face-bold 'my-type-face)
  (set-face-bold-p 'my-type-face t)
  (set-face-foreground 'my-type-face "blue")
  (setq font-lock-type-face 'my-type-face)

  ;; c-mode, c++-mode
  (add-hook 'c-mode-hook
            '(lambda ()
               (font-lock-mode
                1)
               (setq font-lock-keywords c-font-lock-keywords-2)
               ))
  (add-hook
   'c++-mode-hook
   '(lambda ()
      (font-lock-mode 1)
     
      (setq font-lock-keywords c++-font-lock-keywords-2)
      ))
  )



;; insert stereotype text
(defun my-insert-comment()
  (interactive "*" )

  ( progn

    ( setq temp-val (decode-time (current-time)))

    ( insert  (concat
               "/**\n *\n * \\note\n *\n *\n * @author name\n * @date "
               (format "%d-%d-%d"
                       (nth 5 temp-val)
                       (nth 4 temp-val)
                       (nth 3 temp-val))
               )
              "\n * @version 1.0\n */\n"
              )
    )
)

;; for make
(add-hook 'compilation-mode-hook
          (lambda ()
            (setq default-process-coding-system '(utf-8 . utf-8))
            )
)

以上です。