Skip to content

Instantly share code, notes, and snippets.

@laiso
Created September 1, 2009 09:20
Show Gist options
  • Save laiso/179000 to your computer and use it in GitHub Desktop.
Save laiso/179000 to your computer and use it in GitHub Desktop.
;;; arch
;; .emacs で OS の判定を関数化しよう - msshの日記 http://d.hatena.ne.jp/mssh/20081208/1228742294
(defvar os-type nil)
(cond ((string-match "apple-darwin" system-configuration) ;; Mac
(setq os-type 'mac))
((string-match "linux" system-configuration) ;; Linux
(setq os-type 'linux))
((string-match "freebsd" system-configuration) ;; FreeBSD
(setq os-type 'bsd))
((string-match "mingw" system-configuration) ;; Windows
(setq os-type 'win)))
(defun mac? ()
(eq os-type 'mac))
(defun linux? ()
(eq os-type 'linux))
(defun bsd? ()
(eq os-type 'freebsd))
(defun win? ()
(eq os-type 'win))
;;;; Font settings
(set-language-environment "English")
(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)
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
;;;; View settings
(if window-system (progn
(set-background-color "Black")
(set-foreground-color "Green")
(set-face-foreground 'font-lock-comment-face "dark orange")
(set-face-foreground 'font-lock-string-face "slateGray1")
(set-face-foreground 'font-lock-keyword-face "violet")
(set-face-foreground 'font-lock-constant-face "yellow")
(set-face-foreground 'font-lock-function-name-face "maroon2")
(set-face-foreground 'font-lock-variable-name-face "deep sky blue")
(set-face-foreground 'font-lock-type-face "wheat1")
(set-face-foreground 'font-lock-warning-face "violet")
(set-face-bold-p 'font-lock-function-name-face t)
(set-face-bold-p 'font-lock-warning-face nil)
(set-cursor-color "Gray")
(set-frame-parameter nil 'alpha 80)
))
(setq inhibit-startup-message t)
;; (tool-bar-mode nil)
(set-scroll-bar-mode nil)
(line-number-mode t)
;; hightlight cursor line
;; http://blog.iwa-ya.net/2009/06/21/093100
(defface hlline-face
'((((class color)
(background dark))
;;(:background "dark state gray"))
(:background "gray10"
:underline "gray24"))
(((class color)
(background light))
(:background "ForestGreen"
:underline nil))
(t ()))
"*Face used by hl-line.")
(setq hl-line-face 'hlline-face)
;;(setq hl-line-face 'underline)
(global-hl-line-mode)
;; Full screen
(defun toggle-fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen
(if (frame-parameter nil 'fullscreen) nil 'fullboth)))
(if window-system
(progn
(setq default-frame-alist
(append
'((width . 150) (height . 70)
(background-color . "Black")
)
default-frame-alist))))
;====================================
;====================================
(defface my-face-b-1 '((t (:background "medium aquamarine"))) nil)
(defface my-face-b-1 '((t (:background "dark turquoise"))) nil)
(defface my-face-b-2 '((t (:background "cyan"))) nil)
(defface my-face-b-2 '((t (:background "SeaGreen"))) nil)
(defface my-face-u-1 '((t (:foreground "SteelBlue" :underline t))) nil)
(defvar my-face-b-1 'my-face-b-1)
(defvar my-face-b-2 'my-face-b-2)
(defvar my-face-u-1 'my-face-u-1)
(defadvice font-lock-mode (before my-font-lock-mode ())
(font-lock-add-keywords
major-mode
'(
(" " 0 my-face-b-1 append)
("\t" 0 my-face-b-2 append)
("[ ]+$" 0 my-face-u-1 append)
)))
;;;; Key settings
;; Ctrl-h
(keyboard-translate ?\C-h ?\C-?)
(global-set-key "\C-h" nil)
(global-set-key "\M-h" 'help-command)
(setq mac-command-modifier 'meta)
(setq mac-control-modifier 'control)
(setq mac-option-modifier 'alt)
;;; Core settings
(auto-compression-mode t)
(recentf-mode 1)
(pc-selection-mode 1)
(setq show-paren-mode 1)
(setq c-tab-always-indent t)
(setq default-tab-width 4)
(setq indent-line-function 'indent-relative-maybe)
;;(ad-enable-advice 'font-lock-mode 'before 'my-font-lock-mode)
;;(ad-activate 'font-lock-mode)
;;(add-hook 'find-file-hooks '(lambda ()
;; (if font-lock-mode
;; nil
;; (font-lock-mode t))))
(setq frame-title-format (format "emacs@%s : %%f" (system-name)))
;;;; Key settings
(define-key minibuffer-local-filename-completion-map
" " 'minibuffer-complete-word)
(define-key minibuffer-local-must-match-filename-map
" " 'minibuffer-complete-word)
;; Plugins load
(defun my-load-path (path)
(let ((epath (expand-file-name path)))
(unless (member epath load-path)
(setq load-path (cons epath load-path)))))
(my-load-path "~/.emacs.d/site-lisp")
(my-load-path "/usr/share/emacs/site-lisp/ddskk")
(my-load-path "/usr/share/emacs/site-lisp")
(my-load-path "/usr/share/emacs/site-lisp/howm")
;(my-load-path "/Applications/MacPorts/Emacs.app/Contents/Resources/lisp")
;; howm
(require 'howm)
;; rst.el
;; Emacs で ReStructuredText - SPEAKER BREAKA
;; http://d.hatena.ne.jp/namaco35/20090526/1243355997
(require 'rst)
(setq auto-mode-alist
(append '(("\\.txt$" . rst-mode)
("\\.howm$" . rst-mode)
("\\.rst$" . rst-mode)
("\\.rest$" . rst-mode)) auto-mode-alist))
(add-hook 'rst-adjust-hook 'rst-toc-update)
(add-hook 'rst-mode-hook
(lambda ()
(setq rst-slides-program "open -a Firefox")
))
;;(require 'vc-git)
;;(require 'git-emacs)
;;(require 'git-blame)
(require 'grep-edit)
;;;; ddskk
;(require 'skk) (setq skk-large-jisyo"/usr/share/skk/SKK-JISYO.L")
;;;;;;;;;;;;;;
; GUNU Linux
;;;;;;;;;;;;;;
;; uim
;(cond
;((string-match "linux" system-configuration)
; (my-load-path "/usr/share/emacs/site-lisp/uim")
; (require 'uim)
; (global-set-key "\C-o" 'uim-mode)
;))
(autoload 'ansi-color-for-comint-mode-on "ansi-color"
"Set `ansi-color-for-comint-mode' to t." t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
;; auto-complete
(require 'auto-complete)
(global-auto-complete-mode t)
(require 'ac-dabbrev)
(setq ac-sources
(list ac-source-dabbrev))
;; Filetype
;; php-mode
(add-hook 'php-mode-hook
(lambda ()
(require 'php-completion)
(php-completion-mode t)
(define-key php-mode-map (kbd "C-o") 'phpcmp-complete)
(when (require 'auto-complete nil t)
(make-variable-buffer-local 'ac-sources)
(add-to-list 'ac-sources 'ac-source-php-completion)
(auto-complete-mode t))))
;; js2-mode
;(autoload 'js2-mode "js2" nil t)
;(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;(add-to-list 'auto-mode-alist '("\\.json$" . js2-mode))
;; http://8-p.info/emacs-javascript.html
;(setq-default c-basic-offset 4)
;(when (load "js2" t)
; (setq js2-cleanup-whitespace nil
; js2-mirror-mode nil
; js2-bounce-indent-flag nil)
; (defun indent-and-back-to-indentation ()
; (interactive)
; (indent-for-tab-command)
; (let ((point-of-indentation
; (save-excursion
; (back-to-indentation)
; (point))))
; (skip-chars-forward "\s " point-of-indentation)))
;
; (define-key js2-mode-map "\C-i" 'indent-and-back-to-indentation)
; (define-key js2-mode-map "\C-m" nil))
;; java-mode
(add-hook 'java-mode-hook
'(lambda ()
(c-set-style "stroustrup")
(setq tab-width 4)
(setq indent-tabs-mode nil)
))
;;;; Python settings
(require 'python)
;; pymacs
;(require 'pymacs)
;(autoload 'pymacs-apply "pymacs")
;(autoload 'pymacs-call "pymacs")
;(autoload 'pymacs-eval "pymacs" nil t)
;(autoload 'pymacs-exec "pymacs" nil t)
;(autoload 'pymacs-load "pymacs" nil t)
;(eval-after-load "pymacs"
; '(add-to-list 'pymacs-load-path "~/.emacs.d/pymacs/"))
;; python-mode, pycomplete
;(setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))
;(add-to-list 'interpreter-mode-alist '("python" . python-mode))
;(setq interpreter-mode-alist (cons '("python" . python-mode)
; interpreter-mode-alist))
;(autoload 'python-mode "python-mode" "Python editing mode." t)
;(add-hook 'python-mode-hook '(lambda ()
; (require 'pycomplete)
; ))
;; ropemacs
;;(pymacs-load "ropemacs" "rope-")
;;(setq ropemacs-enable-autoimport t)
;(require 'ipython)
;(setq ipython-command "/opt/local/bin/ipython"))
; (require 'pysmell)
;(add-hook 'python-mode-hook (lambda () (pysmell-mode 1)))
;(add-hook 'python-mode-hook
; '(lambda ()
; (define-key python-mode-map "\C-m" 'newline-and-indent)
; (define-key python-mode-map "\M-\"" 'electric-pair)
; (define-key python-mode-map "\M-\'" 'electric-pair)
; (define-key python-mode-map "\M-[" 'electric-pair)
; (define-key python-mode-map "\M-{" 'electric-pair)
; (define-key python-mode-map "\M-(" 'electric-pair)
; (define-key inferior-python-mode-map "\t" 'python-complete-symbol)
; ))
;(defvar ac-source-pysmell
; '((candidates
; . (lambda ()
; (require 'pysmell)
; (pysmell-get-all-completions))))
; "Source for PySmell")
;
;(add-hook 'python-mode-hook
; '(lambda ()
; (set (make-local-variable 'ac-sources) (append ac-sources '(ac-source-pysmell)))))
;;scheme-complete
;(require 'scheme-complete)
;(eval-after-load 'scheme
; '(progn
; (setq scheme-default-implementation 'gauche)
; (setq *scheme-current-implementation* 'gauche)
; ;; scheme-smart-complete: M-TAB
; (define-key scheme-mode-map "\C-t" 'scheme-smart-complete)
; ;; scheme-complete-or-indent: TAB
; (define-key scheme-mode-map "\t" 'scheme-complete-or-indent))
;)
;(add-hook 'scheme-mode-hook
;(lambda ()
;(setq default-scheme-implementation 'gauche)
;(setq *current-scheme-implementation* 'gauche)
;; eldoc-mode
;;(setq (make-local-variable 'eldoc-documentation-function)
; 'scheme-get-current-symbol-info)
;(eldoc-mode t)
;)
;; install-elisp.el *package installer
(require 'install-elisp)
(setq install-elisp-repository-directory "~/.emacs.d/site-lisp")
;; migemo
(load "migemo.el")
(setq migemo-command "/opt/local/bin/cmigemo")
(setq migemo-options '("-q" "--emacs" "-i" "¥a"))
(setq migemo-dictionary (expand-file-name "~/local/migemo/migemo-dict"))
;(setq migemo-dictionary "/opt/local/share/migemo/utf-8/migemo-dict")
(setq migemo-user-dictionary nil)
(setq migemo-regex-dictionary nil)
;; anything
(require 'anything)
(require 'anything-config)
(require 'anything-match-plugin)
(setq anything-sources (list anything-c-source-buffers+
anything-c-source-bookmarks
anything-c-source-recentf
anything-c-source-buffer-not-found
anything-c-source-imenu
anything-c-source-file-name-history
anything-c-source-locate))
(setq imenu-auto-rescan t)
(define-key anything-map (kbd "C-p") 'anything-previous-line)
(define-key anything-map (kbd "C-n") 'anything-next-line)
(define-key anything-map (kbd "C-v") 'anything-next-source)
(define-key anything-map (kbd "M-v") 'anything-previous-source)
(global-set-key (kbd "C-;") 'anything)
(require 'anything-etags)
(add-to-list 'anything-sources 'anything-c-source-etags-select)
(require 'anything-yaetags)
(add-to-list 'anything-sources 'anything-c-source-yaetags-select)
(global-set-key (kbd "M-.") 'anything-yaetags-find-tag)
;; session
(when (locate-library "session")
(setq session-globals-max-size 512)
(setq session-globals-regexp "-\\(ring\\|history\\|hist\\)\\'")
(require 'session)
(defadvice find-alternate-file
(before session-store-buffer-places last activate)
"Invoke session-kill-buffer-hook."
(session-kill-buffer-hook))
(add-to-list 'session-kill-buffer-commands 'find-alternate-file)
(add-hook 'after-init-hook 'session-initialize))
(when (locate-library "minibuf-isearch")
(setq minibuf-isearch-indicator-string nil)
(setq minibuf-isearch-display-message-always t)
(setq minibuf-isearch-match-format-string "[isearch with '%s']")
(setq minibuf-isearch-no-match-format-string "[No further match with '%s']")
(setq minibuf-isearch-message-on-right t)
(setq history-length 128)
(require 'minibuf-isearch))
;; window
;(require 'windows)
;(setq win:use-frame nil)
;(win:startup-with-window)
;(define-key ctl-x-map "C" 'see-you-again)
;; sense-region.el
;(autoload 'sense-region-on "sense-region"
; "System to toggle region and rectangle." t nil)
;(sense-region-on)
;; emacs23 用設定
;(cond ( (string-match "^23\." emacs-version)
; (cond (window-system
; (set-default-font "Bitstream Vera Sans Mono-12")
; (set-fontset-font (frame-parameter nil 'font)
; 'japanese-jisx0208
; '("IPA モナー ゴシック" . "unicode-bmp"))
; ))
;))
;; init-loader
(require 'init-loader)
(init-loader-load (expand-file-name "~/.emacs.d/inits"))
;; yasnippet.el
(require 'yasnippet)
(setq yas/trigger-key (kbd "C-c <kp-multiply>"))
(yas/initialize)
(yas/load-directory "~/.emacs.d/snippets")
(put 'upcase-region 'disabled nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment