Skip to content

Instantly share code, notes, and snippets.

@shtaxxx
Created November 13, 2012 09:28
Show Gist options
  • Save shtaxxx/4064852 to your computer and use it in GitHub Desktop.
Save shtaxxx/4064852 to your computer and use it in GitHub Desktop.
My emacs init.el
;; Environment dependent settings
;;use (eq window-system `name) and (eq emacs-major-version num)
(cond
((eq window-system nil)
(load-file "~/.emacs.d/terminal.el"))
((eq window-system `ns)
(load-file "~/.emacs.d/cocoa.el"))
((eq window-system `mac)
(load-file "~/.emacs.d/carbon.el"))
((eq window-system `x)
(load-file "~/.emacs.d/x11.el"))
((eq window-system `w32)
(load-file "~/.emacs.d/w32.el"))
)
;; Font-Lock mode
(global-font-lock-mode t)
;; shift_jis, euc-jp, 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)
(setq mac-option-modifier 'meta)
(define-key global-map "\C-h" 'delete-backward-char)
(global-set-key "\C-o" 'goto-line)
(global-set-key "\C-xt" 'query-replace-regexp)
(setq inhibit-startup-message t)
(setq make-backup-files nil)
(setq initial-scratch-message "")
(display-time)
(line-number-mode t)
(column-number-mode t)
(setq next-line-add-newlines nil)
(defun prepend-path ( my-path )
(setq load-path (cons (expand-file-name my-path) load-path)))
(defun append-path ( my-path )
(setq load-path (append load-path (list (expand-file-name my-path)))))
(prepend-path "~/elisp")
(load "autoinsert")
(add-hook 'find-file-hooks 'auto-insert)
(setq auto-insert-directory "~/elisp/template/")
(setq auto-insert-alist
(append
'(
("\\.v" . "insert.v")
("\\.c" . "insert.c")
("\\.rb" . "insert.rb")
("\\.py" . "insert.py")
)
auto-insert-alist))
(setq-default transient-mark-mode t)
(setq-default c-basic-offset 2
tab-width 2
indent-tabs-mode nil)
(setq make-backup-files nil)
(setq require-final-newline t)
;; c-mode
(add-hook 'c-mode-common-hook
'(lambda ()
;(c-set-style "k&r")
))
;; C++
(setq auto-mode-alist
(append '(("\\.h$" . c++-mode))
auto-mode-alist))
(add-hook 'c++-mode-hook
'(lambda()
;(c-set-style "stroustrup")
(show-paren-mode t)
(c-set-offset 'innamespace 0)
(c-set-offset 'arglist-close 0)
))
;;; verilog-mode
(setq auto-mode-alist (cons '("\\.v\\'" . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.vh\\'" . verilog-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.tb\\'" . verilog-mode) auto-mode-alist))
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
(add-hook 'verilog-mode-hook '(lambda () (font-lock-mode 1)))
(setq verilog-indent-level 2 ;;indent level 4
verilog-indent-level-module 2
verilog-indent-level-declaration 2
verilog-indent-level-behavioral 2
verilog-indent-level-directive 2
verilog-case-indent 2
verilog-auto-newline nil
verilog-auto-indent-on-newline t
verilog-tab-always-indent t
verilog-auto-endcomments t
verilog-minimum-comment-distance 40
verilog-indent-begin-after-if t
verilog-auto-lineup '())
;; flymake-mode
(autoload 'flymake-mode "flymake" "flymake-mode for automatic syntax check" t)
;; flymake-mode for Verilog HDL
(add-hook 'verilog-mode-hook (lambda () (flymake-mode 1)))
;; flymake settings
(eval-after-load "flymake"
'(progn
(defadvice flymake-post-syntax-check
(before flymake-force-check-was-interrupted)
(setq flymake-check-was-interrupted t))
(ad-activate 'flymake-post-syntax-check)
;; Verilog HDL
(defun flymake-verilog-init ()
(let* ((temp (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))
(local (file-relative-name temp (file-name-directory buffer-file-name))))
(list "iverilog" (list "-tnull" local))))
(add-to-list 'flymake-err-line-patterns
'("\\(.*?\\):\\([0-9]+\\): \\(.*\\)$" 1 2 nil 3))
(add-to-list 'flymake-err-line-patterns
'("\\(^No top level modules\\)$" nil nil nil 0))
(add-to-list 'flymake-err-line-patterns
'("\\(Unknown module type\\)" nil nil nil 0))
(push '("\\.[v]\\'" flymake-verilog-init) flymake-allowed-file-name-masks)))
;;YaTeX
(setq YaTeX-kanji-code 3) ;;1:Shift-JIS 2:ISO-2022-JP 3:EUC-JP
(setq auto-mode-alist
(cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
(setq load-path (cons "~/elisp/yatex" load-path))
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
;(setq tex-command "platex --kanji=euc"
(setq tex-command "dotexshop-euc"
bibtex-command "jbibtex --kanji=euc"
dvi2-command "open -a Preview")
(setq YaTeX-use-AMS-LaTeX t)
(add-hook 'yatex-mode-load-hook
(function
(lambda ()
(YaTeX-define-begend-key "ba" "align")
)))
(add-hook 'yatex-mode-hook'(lambda ()(setq auto-fill-function nil)))
;; Ruby mode
(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)))
;; Haskell mode
(load "~/elisp/haskell-mode/haskell-site-file")
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)
(setq haskell-program-name "ghci")
;; ispell, aspell
(global-set-key "\C-c" 'ispell-word)
(setq hostname (system-name))
(setq ispell-program-name "/usr/local/bin/aspell")
(autoload 'ispell-word "ispell" "Check the spelling of word in buffer." t)
(autoload 'ispell-region "ispell" "Check the spelling of region." t)
(autoload 'ispell-buffer "ispell" "Check the spelling of buffer." t)
(autoload 'ispell-complete-word "ispell" "Look up current word in dictionary and try to complete it." t)
(autoload 'ispell-change-dictionary "ispell" "Change ispell dictionary." t)
(autoload 'ispell-message "ispell" "Check spelling of mail message or newsx post.")
;(defun ispell-tex-buffer-p ()
; (memq major-mode '(plain-tex-mode latex-mode slitex-mode yatex-mode)))
;(setq ispell-enable-tex-parser t)
;; Use Japanese
(eval-after-load "ispell"
'(add-to-list 'ispell-skip-region-alist '("[^\000-\377]+")))
;; Use latex file
(setq ispell-filter-hook-args '("-w"))
(setq TeX-mode-hook
(function
(lambda ()
(setq ispell-filter-hook "detex"))))
;; GNU Global
(autoload 'gtags-mode "gtags" "" t)
(setq gtags-mode-hook
'(lambda ()
(local-set-key "\M-t" 'gtags-find-tag)
(local-set-key "\M-r" 'gtags-find-rtag)
(local-set-key "\M-s" 'gtags-find-symbol)
(local-set-key "\C-t" 'gtags-pop-stack)
))
(add-hook 'c-mode-common-hook
'(lambda()
(gtags-mode 1)
(gtags-make-complete-list)
))
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
;; Emacs Server Settings
;;(autoload 'server-edit "server" nil t)
;;(server-edit)
;;(if window-system
;; (setq server-visit-hook
;; '(lambda () (setq server-window
;; (make-frame '((name . "Server frame")(width . 80)(heigth . 40)))))))
;;(if window-system
;; (setq server-done-hook '(lambda () (kill-buffer buffer))))
;;
;;(if window-system
;; (global-set-key "\C-x#"
;; '(lambda ()
;; (interactive)
;; (server-edit)
;; (if (string-equal "Server frame"
;; (cdr (assq 'name (frame-parameters server-window))))
;; (progn (delete-frame server-window)
;; (setq server-window nil))))))
;; start-up emacsclient server
;;(server-start)
(setq initial-frame-alist '((width . 200) (height . 60) (top . 0) (left . 100)))
(set-background-color "Black")
(set-foreground-color "LightGray")
(set-cursor-color "Gray")
(set-frame-parameter nil 'alpha 92)
(set-face-background 'region "LightSteelBlue1")
(setq default-frame-alist initial-frame-alist)
;(tool-bar-mode nil)
(tool-bar-mode -1)
;(menu-bar-mode -1)
;; Wheel mouse
(defun down-slightly () (interactive) (scroll-down 5))
(defun up-slightly () (interactive) (scroll-up 5))
(global-set-key [mouse-4] 'down-slightly)
(global-set-key [mouse-5] 'up-slightly )
(defun down-one () (interactive) (scroll-down 1))
(defun up-one () (interactive) (scroll-up 1))
(global-set-key [S-mouse-4] 'down-one)
(global-set-key [S-mouse-5] 'up-one )
(defun down-a-lot () (interactive) (scroll-down))
(defun up-a-lot () (interactive) (scroll-up ))
(global-set-key [C-mouse-4] 'down-a-lot)
(global-set-key [C-mouse-5] 'up-a-lot )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment