Skip to content

Instantly share code, notes, and snippets.

@nna774
Last active January 23, 2018 07:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nna774/46be4fe303b06b56c66d to your computer and use it in GitHub Desktop.
Save nna774/46be4fe303b06b56c66d to your computer and use it in GitHub Desktop.
;;; gc 間隔設定 128MB 使うまで走らなくなる * 4
(setq gc-cons-threshold (* 4 134217728))
(setq load-path (cons "~/.emacs.d/elisp" load-path))
(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("marmalade" . "https://marmalade-repo.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(package-initialize)
(require 'cl)
(menu-bar-mode -1)
(setq read-buffer-completion-ignore-case t)
(setq read-file-name-completion-ignore-case t)
;; ;;; 誤爆しかしないのでundef
(define-key global-map (kbd "C-t") nil)
;;; No backup
(setq make-backup-files nil)
;;; タイトルバーにファイルのフルパス表示
(setq frame-title-format
(format "%%f - Emacs@%s" (system-name)))
;;; 行番号表示
(global-linum-mode t)
(set-face-attribute 'linum nil
:foreground "#800"
:height 0.9)
;; ; 行番号フォーマット
(setq linum-format "%4d")
;;; スタートページ無し
(setq inhibit-startup-message t)
;;; use tab
;(setq-default indent-tabs-mode t)
;;; yes no -> y,no
(fset 'yes-or-no-p 'y-or-n-p)
;;; 最近使ったファイルをメニューに表示
(recentf-mode t)
(global-set-key "\C-xf" 'recentf-open-more-files)
;; ; 最近使ったファイルの表示数
(setq recentf-max-menu-items 10)
;; ; 最近開いたファイルの保存数を増やす
(setq recentf-max-saved-items 3000)
;;; ミニバッファの履歴を保存する
(savehist-mode 1)
;; ; ミニバッファの履歴の保存数を増やす
(setq history-length 3000)
;;; show column-number
(column-number-mode t)
;;; scratchの初期メッセージ消去
;(setq initial-scratch-message "")
;;; C-Ret で矩形選択
;; 詳しいキーバインド操作:http://dev.ariel-networks.com/articles/emacs/part5/
(cua-mode t)
(setq cua-enable-cua-keys nil)
;;; スクラッチバッファを安心して利用できるようにする拡張をつくった [http://d.hatena.ne.jp/kitokitoki/20100612/p1]
;(require 'scratch-log)
;; (setq sl-scratch-log-file "~/.emacs.d/.scratch-log")
;; (setq sl-prev-scratch-string-file "~/.emacs.d/.scratch-log-prev")
;; nil なら emacs 起動時に,最後に終了したときの スクラッチバッファの内容を復元しない。初期値は t です。
;; (setq sl-restore-scratch-p nil)
;; nil なら スクラッチバッファを削除できるままにする。初期値は t です。
;; (setq sl-prohibit-kill-scratch-buffer-p nil)
;;;
;;; C-hでバックスペース
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key "\M-h" 'backward-kill-word)
;;; 画像ファイルを表示
(auto-image-file-mode t)
;;; 対応する括弧を光らせる
(show-paren-mode t)
(setq show-paren-style 'mixed)
;;; 現在行を目立たせる
(global-hl-line-mode)
;;; カーソルの場所を保存する
(require 'saveplace)
(setq-default save-place t)
(save-place-mode 1)
(setq save-place-file "/home/nona/.emacs.d/saved-places")
;;; 行の先頭でC-kを一回押すだけで行全体を消去する
(setq kill-whole-line t)
;;; 補完可能なものを随時表示
;;; 少しうるさい
(icomplete-mode 1)
;;; gzファイルも編集できるようにする
(auto-compression-mode t)
;;; auto spell check
(setq-default flyspell-mode t)
(setq ispell-dictionary "american")
;; shell-modeでpasswordを隠す
(add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt)
;;; auto-insert
;; ファイル形式に応じて自動でテンプレート挿入
;; (add-hook 'find-file-hooks 'auto-insert)
;; (setq auto-insert-directory "~/.emacs.d/templates")
;; (setq auto-insert-alist
;; '((perl-mode . "perl-template.pl")
;; (html-mode . "html-template.html")
;; ("base.css" . "base.css")
;; (css-mode . "css-template.css")))
;;; バッファ一覧をまともに
(global-set-key "\C-x\C-b" 'bs-show)
;;; ファイル名が重複していたらディレクトリ名を追加する。
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
;;; ファイルの先頭に#!...があるファイルを保存すると実行権をつけます。
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)
;;; ウィンドウの上部に現在の関数名を表示します。
(which-function-mode t)
;;; 自動でスペルチェックを実行します。
(setq-default flyspell-mode t)
(setq ispell-dictionary "american")
;;; Tab でインデントする
;(setq indent-tabs-mode t)
;;; elファイルをいじって保存したときに自動でバイトコンパイル [by auto-async-byte-compile.el]
;(require 'auto-async-byte-compile)
;;(setq auto-async-byte-compile-exclude-files-regexp "init.el")
;(add-hook 'emacs-lisp-mode-hook 'enable-auto-async-byte-compile-mode)
;;; 対応する括弧の自動補完
;; (global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
;; (global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
;; (global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
;; (global-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
;; (global-set-key (kbd "'") 'skeleton-pair-insert-maybe)
;; (setq skeleton-pair t)
(electric-pair-mode 1)
;;; ---------------------------------------;;;
;;; magit
;(setq load-path (cons "~/.emacs.d/vendor/magit/share/emacs/site-lisp/" load-path))
;(require 'magit)
;;; shell-command
;(define-key global-map "\M-s" 'shell-command)
(setq require-final-newline t)
;(partial-completion-mode t)
;; M-x shell での ls 等の color での表示のための設定
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(add-hook 'lisp-mode-hook (lambda () (auto-complete-mode t)))
;;; auto-complete
(require 'auto-complete)
(require 'auto-complete-config)
(global-auto-complete-mode t)
(ac-config-default)
(setq ac-ignore-case t)
;(ac-config-default)
;(define-key ac-complete-mode-map "\C-n" 'ac-next)
;(define-key ac-complete-mode-map "\C-p" 'ac-previous)
;(el-get 'sync '(auto-complete))
;;; windmove
;(windmove-default-keybindings 'meta)
;; ;;; commentout
;; (global-set-key (kbd "C-c ;") 'comment-or-uncomment-region)
;;; comment
(setq comment-style 'multi-line)
;;; スペースと改行の強調表示 --
(global-whitespace-mode 1)
;; スペースの定義は全角スペースとする。
(setq whitespace-space-regexp "\x3000+")
;; 改行の色を変更
(set-face-foreground 'whitespace-newline "gray40")
;; 半角スペースと改行を除外
(dolist (d '((space-mark ?\ ) (newline-mark ?\n)))
;(dolist (d '((space-mark ?\ )))
(setq whitespace-display-mappings
(delete-if
'(lambda (e) (and (eq (car d) (car e))
(eq (cadr d) (cadr e))))
whitespace-display-mappings)))
;; 全角スペースと改行を追加
(dolist (e '((space-mark ?\x3000 [?\□])
(newline-mark ?\n [?\u21B5 ?\n] [?$ ?\n])))
(add-to-list 'whitespace-display-mappings e))
;; 強調したくない要素を削除
(dolist (d '(face lines space-before-tab
indentation empty space-after-tab tab-mark))
(setq whitespace-style (delq d whitespace-style)))
;; スペースと改行の強調表示 -- ここまで
;; バイトコンパイル用
(defun byte-compile-this-file ()
"Compile current-buffer-file of Lisp into a file of byte code."
(interactive)
(byte-compile-file buffer-file-name t))
;;; Anything
;(require 'anything)
;(require 'anything-config)
;(add-to-list 'anything-sources 'anything-c-source-emacs-commands)
;(define-key global-map (kbd "C-;") 'anything)
;(add-to-list 'anything-sources 'anything-c-source-google-suggest)
;;; >> 突然の死 <<
;(require 'sudden-death)
;;; c++-mode
(add-hook 'c-mode-common-hook
(lambda ()
(c-set-style "bsd")
;; (local-set-key "\t" 'self-insert-command)
(setq c-basic-offset 2)
(setq indent-tabs-mode nil)
(subword-mode 1)
(setq tab-stop-list '(2 4 6 8 10 12 14 16 18 20 22 24 26 28 30))
)
)
;;; markdown-mode
;(require 'markdown-mode)
;(add-hook
; 'emacs-lisp-mode-hook
; (lambda ()
; (setq indent-tabs-mode t)))
;(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))
;(setq auto-mode-alist
; (cons '("\\.mk?d$" . markdown-mode) auto-mode-alist))
;(add-hook 'markdown-mode-hook 'flyspell-mode)
;;; LaTeX mode
;; (add-hook 'latex-mode-hook (lambda () (auto-complete-mode t)))
;; ghc-mod
;; cabal でインストールしたライブラリのコマンドが格納されている bin ディレクトリへのパスを exec-path に追加する
;(add-to-list 'exec-path (concat (getenv "HOME") "/.cabal/bin"))
;; ghc-flymake.el などがあるディレクトリ ghc-mod を ~/.emacs.d 以下で管理することにした
;(add-to-list 'load-path "~/.emacs.d/elisp/ghc-mod")
;(autoload 'ghc-init "ghc" nil t)
(add-hook 'haskell-mode-hook
(lambda ()
(ghc-init)
(local-set-key "\C-j" (lambda () (interactive)(insert " -> ")))
(local-set-key "\M-j" (lambda () (interactive)(insert " => ")))
(local-set-key "\C-l" (lambda ()(interactive)(insert " <- ")))
))
;;; Tab でインデントしないで
(setq indent-tabs-mode -1)
;;; Auto-save
;; (require 'auto-save-buffers)
;; (run-with-idle-timer 0.1 t 'auto-save-buffers)
(require 'auto-save-buffers-enhanced)
;;; 1秒後に保存
(setq auto-save-buffers-enhanced-interval 0.1)
;;; 特定のファイルのみ有効にする
(setq auto-save-buffers-enhanced-include-regexps '(".+")) ;全ファイル
;; not-save-fileと.ignoreは除外する
;;(setq auto-save-buffers-enhanced-exclude-regexps '("^not-save-file" "\\.ignore$"))
;;; Wroteのメッセージを抑制
;;(setq auto-save-buffers-enhanced-quiet-save-p t)
;;; *scratch*も ~/.emacs.d/scratch に自動保存
(setq auto-save-buffers-enhanced-save-scratch-buffer-to-file-p t)
(setq auto-save-buffers-enhanced-file-related-with-scratch-buffer
(locate-user-emacs-file "scratch"))
(auto-save-buffers-enhanced t)
;;; C-x a sでauto-save-buffers-enhancedの有効・無効をトグル
(global-set-key "\C-xas" 'auto-save-buffers-enhanced-toggle-activity)
(setq set-mark-command-repeat-pop t)
(setq mark-ring-max 32)
;;; client
(when (daemonp)
(defalias 'exit 'save-buffers-kill-emacs)
(global-set-key (kbd "C-x c") 'suspend-frame)
(global-set-key (kbd "C-x C-c") '(lambda ()
(interactive)
(if current-prefix-arg
(save-buffers-kill-emacs)
(save-buffers-kill-terminal)))))
(require 'go-mode)
(add-hook 'go-mode-hook
(lambda ()
(setq tab-width 2)
))
(setq ruby-insert-encoding-magic-comment nil)
(require 'oniisama)
(imouto)
(when (require 'undo-tree nil t)
(global-undo-tree-mode))
(setq auto-mode-alist
(cons '("\\.s?css$" . css-mode) auto-mode-alist))
;; yaml-mode
(when (require 'yaml-mode nil t)
(add-to-list 'auto-mode-alist '("¥¥.yml$" . yaml-mode)))
(require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.jsx$" . js2-mode))
(add-to-list 'auto-mode-alist '("\\.jsx$" . js2-jsx-mode))
(setq js2-basic-offset 2)
(setq js2-strict-missing-semi-warning t)
(setq js2-missing-semi-one-line-override t)
(add-hook 'js2-mode-hook
'(lambda ()
(setq indent-tabs-mode nil)
))
;; (add-to-list 'auto-mode-alist '("\\.jsx\\'" . jsx-mode))
;; (autoload 'jsx-mode "jsx-mode" "JSX mode" t)
;; (require 'esup)
(defun insert-binding-pry ()
(interactive)
(insert "binding.pry\n"))
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.erb$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode)) ;; shebangがrubyの場合、ruby-modeを開く
(add-hook 'ruby-mode-hook
'(lambda ()
(local-set-key (kbd "C-c b") 'insert-binding-pry)
))
;; (defconst *dmacro-key* "\C-t" "繰返し指定キー")
;; (global-set-key *dmacro-key* 'dmacro-exec)
;; (autoload 'dmacro-exec "dmacro" nil t)
;; (require 'gtags)
;; (global-set-key "\M-t" 'gtags-find-tag)
;; (global-set-key "\M-r" 'gtags-find-rtag)
;; (global-set-key "\M-s" 'gtags-find-symbol)
;; (global-set-key "\C-t" 'gtags-pop-stack)
(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.
'(package-selected-packages
(quote
(go-mode package-utils auto-save-buffers-enhanced jsx-mode auto-complete undo-tree js2-mode esup elnode))))
(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.
)
(defun kill-line-or-region ()
"kill region if active only or kill line normally"
(interactive)
(if (region-active-p)
(call-interactively 'kill-region)
(call-interactively 'kill-line)))
(global-set-key (kbd "C-k") 'kill-line-or-region)
(require 'git-complete)
(global-set-key (kbd "C-c C-c") 'git-complete)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment