Skip to content

Instantly share code, notes, and snippets.

@hatsusato
Created February 22, 2016 13:17
Show Gist options
  • Save hatsusato/62deea2751071f11cf7a to your computer and use it in GitHub Desktop.
Save hatsusato/62deea2751071f11cf7a to your computer and use it in GitHub Desktop.
;; load-path追加。
(add-to-list 'load-path "~/.emacs.d/site-lisp/")
;; C-hをバックスペースにする。
(global-set-key (kbd "C-h") 'backward-delete-char-untabify)
;; C-tの挙動をC-b C-tの感じにする。
(defun my-transpose-chars()
(interactive)
(forward-char -1)
(transpose-subr 'forward-char 1))
(global-set-key (kbd "C-t") 'my-transpose-chars)
;; C-uの挙動をTerminalと同じにする。
(defun my-cancel-line()
(interactive)
(setq my-cancel-ending (point))
(beginning-of-line)
(setq my-cancel-beginning (point))
(kill-region my-cancel-beginning my-cancel-ending))
(global-set-key (kbd "C-u") 'my-cancel-line)
;; C-x p, C-x n でウィンドウを前後に移動する。
(defun my-next-window()
(interactive)
(other-window 1))
(defun my-prev-window()
(interactive)
(other-window -1))
(global-set-key (kbd "C-x n") 'my-next-window)
(global-set-key (kbd "C-x p") 'my-prev-window)
;; バッファリストを最小限の画面で表示する。
(global-set-key (kbd "C-x C-b") 'bs-show)
;; C-\でtoggle-input-methodが起動しないようにする。
(global-set-key (kbd "C-\\") nil)
;; スタートページ非表示。
(setq inhibit-startup-message t)
;; yes no -> y,n
(fset 'yes-or-no-p 'y-or-n-p)
;; scratchの初期メッセージを明示的に指定できるようにする。
(setq initial-scratch-message
(concat initial-scratch-message ""))
;; 矩形選択。
;; http://dev.ariel-networks.com/articles/emacs/part5/ のcua-modeの項。
(cua-mode t)
(setq cua-enable-cua-keys nil)
;; リージョンを削除できるようにする。
(delete-selection-mode t)
;; ミニバッファでの補完を表示。
(icomplete-mode 1)
;; タイトルバーにファイルのフルパス表示。
(setq frame-title-format (format "%%f - Emacs@%s" (system-name)))
;; 自動改行について
;; http://www.emacswiki.org/FillColumnIndicator
;; (setq-default fill-column 160)
;; (turn-off-auto-fill)
;; (auto-fill-mode -1)
;; (remove-hook 'text-mode-hook 'turn-on-auto-fill)
(setq text-mode-hook 'turn-off-auto-fill)
;; (add-hook 'text-mode-hook 'turn-off-auto-fill)
(setq auto-fill-mode nil)
;; 行末の空白を表示
(setq-default show-trailing-whitespace t)
;; 末尾に必ず改行を入れる。
(setq require-final-newline t)
;; 末尾に改行を入れないhook。
(defun my-reset-require-final-newline()
(interactive)
(let ((require-final-newline nil))
(call-interactively 'save-buffer)))
;; 保存時に行末の空白を自動で削除する。
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; 行末の空白を自動で削除するhookを無効化するhook。
(defun my-reset-delete-trailing-whitespace()
(interactive)
(remove-hook 'before-save-hook 'delete-trailing-whitespace))
;; 保存時の自動処理を無効化するhookを追加する。
(defun my-reset-before-save-hook(hook-name)
(add-hook hook-name 'my-reset-require-final-newline)
(add-hook hook-name 'my-reset-delete-trailing-whitespace))
;; diff-modeのときは保存時に処理をしない。
(my-reset-before-save-hook 'diff-mode-hook)
;; 80文字以上になると色を変える。
(setq my-80-longer-chars-regex
'(("^[^\n]\\{80\\}\\(.+\\)$" 1 font-lock-warning-face t)))
(defun my-80-longer-chars()
(font-lock-add-keywords nil my-80-longer-chars-regex))
(add-hook 'c-mode-hook 'my-80-longer-chars)
(add-hook 'c++-mode-hook 'my-80-longer-chars)
(add-hook 'python-mode-hook 'my-80-longer-chars)
(add-hook 'yatex-mode-hook 'my-80-longer-chars)
;; Google C++ Style Guideの書式設定ファイルを導入。
;; http://www.textdrop.net/google-styleguide-ja/cppguide.xml
;; http://google-styleguide.googlecode.com/svn/trunk/google-c-style.el
(require 'google-c-style)
(add-hook 'c-mode-common-hook 'google-set-c-style)
;; auto-complete-modeを導入。
;; http://cx4a.org/software/auto-complete/index.ja.html
(add-to-list 'load-path "~/.emacs.d/site-lisp/auto-complete")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/site-lisp/auto-complete/ac-dict")
(ac-config-default)
(setq ac-ignore-case t)
;; auto-complete-latexを導入。
;; https://bitbucket.org/tequilasunset/auto-complete-latex
(add-to-list 'load-path "~/.emacs.d/site-lisp/auto-complete-latex/")
(require 'auto-complete-latex)
(setq ac-l-dict-directory "~/.emacs.d/site-lisp/auto-complete-latex/ac-l-dict/")
(add-to-list 'ac-modes 'yatex-mode)
(add-hook 'yatex-mode-hook 'ac-l-setup)
;; undo-treeを導入。
;; http://www.emacswiki.org/emacs/UndoTree
(require 'undo-tree)
(global-undo-tree-mode)
;; AUCTeXを導入。
;; https://www.gnu.org/software/auctex/
;; (load "auctex.el" nil t t)
;; (setq TeX-auto-save t)
;; (setq TeX-parse-self t)
;; (setq-default TeX-master nil)
;; YaTeXを導入。
;; http://www.yatex.org/
(setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/yatex") load-path))
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
(add-to-list 'auto-mode-alist '("\\.tex\\'" . yatex-mode))
(setq YaTeX-kanji-code 4)
;; markdown-modeを利用。
;; http://jblevins.org/projects/markdown-mode/
(autoload 'markdown-mode "markdown-mode" "Major mode for editing Markdown files" t)
;; (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
(add-hook 'markdown-mode-hook
(lambda ()
(define-key markdown-mode-map (kbd "C-i") 'markdown-cycle)
(hide-sublevels 2)))
;; 自作のDiff Mode
(defun my-diff-mode()
"Diff Mode "
(interactive)
(kill-all-local-variables)
(setq mode-name "Diff")
(setq major-mode 'my-diff-mode)
(run-hooks 'my-diff-mode-hook))
(autoload 'my-diff-mode
"my-diff-mode" "Major mode for editing diff files" t)
(add-to-list 'auto-mode-alist '("COMMIT_EDITMSG\\'" . my-diff-mode))
(add-to-list 'auto-mode-alist '("git-rebase-todo\\'" . my-diff-mode))
(my-reset-before-save-hook 'my-diff-mode-hook)
;; (setq-local comment-start "# ")
;; (setq-local comment-end "")
(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)
'(indicate-empty-lines t)
'(save-place t nil (saveplace))
'(scroll-bar-mode nil)
'(show-paren-mode t)
'(tool-bar-mode nil)
'(uniquify-buffer-name-style (quote forward) nil (uniquify)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment