Skip to content

Instantly share code, notes, and snippets.

@nidate
Last active September 30, 2020 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nidate/109c2d384ef29d3d1e3e to your computer and use it in GitHub Desktop.
Save nidate/109c2d384ef29d3d1e3e to your computer and use it in GitHub Desktop.
init.el
;(require 'un-define)
(setq debug-on-error t)
(setenv "SSH_AUTH_SOCK" "/tmp/501/SSHKeychain.socket")
(setq transient-mark-mode nil)
(setq-default case-fold-search t)
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
; fix japanese filename for dired mode
;(set-file-name-coding-system 'utf-8)
(when (>= emacs-major-version 25)
;; http://qiita.com/maangie/items/8d354feb687516f96061
(when (string-equal system-type "darwin")
;; Emacs とシェルの変数共有
;; http://d.hatena.ne.jp/kiririmode/20130804/p1
;; https://github.com/syl20bnr/spacemacs/issues/3920
(when (functionp 'exec-path-from-shell-initialize)
(setq exec-path-from-shell-arguments '("-l"))
(exec-path-from-shell-initialize))
(mac-input-method-mode) ; 日本語入力
;; カーソルの色の設定
;; http://blog.n-z.jp/blog/2013-11-12-cocoa-emacs-ime.html
(mapc
(lambda (param)
(let ((name (car param)))
(when (string-match "Japanese\\(\\.base\\)?\\'" name)
(mac-set-input-method-parameter name 'cursor-color "gray"))))
mac-input-method-parameters)
(mac-set-input-method-parameter "com.apple.keylayout.US"
'cursor-color "white"))
)
(when (>= emacs-major-version 24)
;https://email.esm.psu.edu/pipermail/macosx-emacs/2011-August/002767.html
; 濁点、半濁点を修正
; M-x utfix
(defun utfix (rs re)
(interactive "r")
(save-excursion
(goto-char rs)
(ns-utf8-nfd-post-read-conversion (- re rs)))
)
)
(when (>= emacs-major-version 23)
(progn
(setq ns-command-modifier (quote meta))
(setq ns-alternate-modifier (quote super))
;http://d.hatena.ne.jp/setoryohei/20110117/1295336454
(let* ((fontset-name "myfonts") ; フォントセットの名前
(size 12) ; ASCIIフォントのサイズ [9/10/12/14/15/17/19/20/...]
(asciifont "Monaco") ; ASCIIフォント
(jpfont "Hiragino Kaku Gothic ProN") ; 日本語フォント
;(jpfont "Hiragino Maru Gothic ProN") ; 日本語フォント
;(jpfont "Osaka") ; 日本語フォント
(font (format "%s-%d:weight=normal:slant=normal" asciifont size))
(fontspec (font-spec :family asciifont))
(jp-fontspec (font-spec :family jpfont))
(fsn (create-fontset-from-ascii-font font nil fontset-name)))
(set-fontset-font fsn 'japanese-jisx0213.2004-1 jp-fontspec)
(set-fontset-font fsn 'japanese-jisx0213-2 jp-fontspec)
(set-fontset-font fsn 'japanese-jisx0208 jp-fontspec)
(set-fontset-font fsn 'katakana-jisx0201 jp-fontspec)
(set-fontset-font fsn '(#x0080 . #x024F) fontspec) ; 分音符付きラテン
(set-fontset-font fsn '(#x0370 . #x03FF) fontspec) ; ギリシャ文字
)
;; デフォルトのフレームパラメータでフォントセットを指定
(add-to-list 'default-frame-alist '(font . "fontset-myfonts"))
;; フォントサイズの比を設定
(setq face-font-rescale-alist
'(
(".*Hiragino Kaku Gothic ProN.*" . 1.2)
("^-apple-hiragino.*" . 1.2)
(".*osaka-bold.*" . 1.2)
(".*osaka-medium.*" . 1.2)
(".*courier-bold-.*-mac-roman" . 1.0)
(".*monaco cy-bold-.*-mac-cyrillic" . 0.9)
(".*monaco-bold-.*-mac-roman" . 0.9)
("-cdac$" . 1.3)))
;; デフォルトフェイスにフォントセットを設定
;; # これは起動時に default-frame-alist に従ったフレームが
;; # 作成されない現象への対処
(set-face-font 'default "fontset-myfonts")
(setq read-buffer-completion-ignore-case t)
(setq read-file-name-completion-ignore-case t)
))
(when (= emacs-major-version 23)
(progn
(setq load-path
(append
(list
(expand-file-name "~/Library/emacs23")
(expand-file-name "~/Library/emacs23/ee")
(expand-file-name "~/Library/elisp/navi2ch")
(expand-file-name "~/Library/emacs23/google-maps")
(expand-file-name "~/Library/emacs23/rinari")
)
load-path))
;
(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)
))
(when (<= emacs-major-version 22)
(progn
;GNU Emacs 22.2.50.1 (i386-apple-darwin9.4.0, Carbon Version 1.6.0) of 2008-07-17 on seijiz.local
(require 'utf-8m)
(set-file-name-coding-system 'utf-8m)
(prefer-coding-system 'utf-8-unix)
(mac-add-ignore-shortcut '(control))
;;(mac-add-ignore-shortcut '(command control))
(mac-input-method-mode 1)
(setq mac-pass-command-to-system t)
;;(setq mac-pass-control-to-system nil)
;;(global-set-key "\C-o" 'mac-toggle-input-method)
;;(require 'mac-utf) ;; *2
(setq load-path
(append
(list
(expand-file-name "~/Library/elisp/navi2ch")
(expand-file-name "~/Library/elisp")
(expand-file-name "~/Library/elisp/ee")
(expand-file-name "~/Library/elisp/epg")
(expand-file-name "~/Library/elisp/emacs-rails")
(expand-file-name "/Applications/Emacs.app/Contents/Resources/share/emacs/site-lisp")
)
load-path))
)
)
(setq exec-path
(append
(list
(expand-file-name "/usr/local/bin")
(expand-file-name "~/homebrew/bin")
(expand-file-name "~/homebrew/sbin")
;(expand-file-name "/usr/local/src/emacs-23.1/nextstep/Emacs.app/Contents/Resources/bin")
)
exec-path))
(setq recentf-mode 'nil)
(setq procecss-connection-type t )
(global-set-key "\M-g" 'goto-line)
(global-set-key "\C-z" 'scroll-other-window)
(global-set-key "\C-\M-z" 'scroll-other-window-down)
(global-set-key "\C-\M-v" 'scroll-other-window)
(global-set-key "\C-h" 'help)
(global-set-key [delete] 'delete-backward-char)
(global-set-key "\C-xx" 'copy-to-register)
(global-set-key "\C-xg" 'insert-register)
;(turn-on-auto-fill)
;if you want to change fill mode evalute below
;(auto-fill-mode)
;http://www.morishima.net/~naoto/fragments/archives/2005/11/14-1707.php
(defun toggle-beginning-or-indentation-of-line (arg)
(interactive "p")
(if (looking-at "^")
(back-to-indentation)
(beginning-of-line arg)))
(define-key global-map "\C-a" 'toggle-beginning-or-indentation-of-line)
(define-key global-map "\C-h" 'help)
(require 'grep)
(autoload 'igrep "igrep"
"*Run `grep` PROGRAM to match EXPRESSION in FILES..." t)
(autoload 'igrep-find "igrep"
"*Run `grep` via `find`..." t)
(autoload 'dired-do-igrep "igrep"
"*Run `grep` on the marked (or next prefix ARG) files." t)
(autoload 'igrep-insinuate "igrep"
"Define `grep' aliases for the corresponding `igrep' commands." t)
(setq igrep-find-use-xargs 'nil)
(autoload 'php-mode "php-mode" "Major mode for editing php code." t)
(add-to-list 'auto-mode-alist (cons "\\.php\\'" 'php-mode))
(setq indent-tabs-mode nil)
(setq ring-bell-function '(lambda ()))
;(autoload 'navi2ch "navi2ch" "Navigator for 2ch for Emacs" t)
;(autoload 'mew "mew" nil t)
;(autoload 'mew-send "mew" nil t)
(if (boundp 'epa-setup)
(require 'epa-setup))
;; If using XEmacs/Emacs 21
;(setq mew-icon-directory "icon directory")
;(setq browse-url-browser-function 'browse-url-generic
; browse-url-generic-program "/usr/bin/open"
; browse-url-generic-args '("-a" "Firefox3.1b1.app"))
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "/usr/bin/open")
(setq browse-url-filename-alist
'(("/webmaster@webserver:/home/www/html/" . "http://www.acme.co.uk/")
("^/\(ftp@\|anonymous@\)?\([^:]+\):/*" . "ftp://\2/")
("^/\([^:@]+@\)?\([^:]+\):/*" . "ftp://\1\2/")
("^/+" . "/")
))
;(load "elscreen" "ElScreen" t)
(elscreen-start)
(setq elscreen-frefix-key "\C-z")
; in emacs 23.1 it need libraries apel, flim, semi.
;(recentf-mode)
;http://www.bookshelf.jp/cgi-bin/goto.cgi?file=meadow&node=desktop-read-save
(setq desktop-files-not-to-save "\\(^/[^/:]*:\\|\\.diary$\\)")
(autoload 'desktop-save "desktop" nil t)
(autoload 'desktop-clear "desktop" nil t)
(autoload 'desktop-load-default "desktop" nil t)
(autoload 'desktop-remove "desktop" nil t)
;(require 'ido)
;(ido-mode t)
;(ido-mode nil)
(add-to-list 'auto-mode-alist (cons "\\.js\\'" 'javascript-mode))
;;(autoload 'perl-mode "cperl-mode" "cperl mode" t)
;; (add-hook 'c-mode-hook
;; (lambda ()
;; (setq indent-tabs-mode nil)
;; (setq tab-width 4)
;; (setq c-indent-level 4)
;; ))
(setq write-file-functions nil)
;;(setq write-file-functions '(untabify-before-write))
(add-hook 'c-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq tab-width 2)
))
(add-hook 'perl-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq tab-width 4)
(setq perl-indent-level 4)
))
(add-hook 'cperl-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq tab-width 4)
(setq perl-indent-level 4)
))
(add-hook 'php-mode-hook
(lambda ()
;(setq php-indent-level 2)
;(setq indent-tabs-mode t)
(setq indent-tabs-mode nil)
(setq c-basic-offset 2)
(setq tab-width 2)
(setq write-file-functions nil)
))
(add-hook 'html-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq tab-width 2)
(setq write-file-functions nil)
))
(add-hook 'java-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq js-indent-level 2)
(setq tab-width 2)
(setq write-file-functions nil)
))
(add-hook 'javascript-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq js-indent-level 2)
(setq tab-width 2)
(setq write-file-functions nil)
))
(add-hook 'js-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq js-indent-level 2)
(setq tab-width 2)
(setq write-file-functions nil)
))
(add-hook 'sgml-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq js-indent-level 2)
(setq tab-width 2)
))
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq tab-width 2)
(setq python-indent 2)
))
(add-hook 'css-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq css-indent-offset 2)
))
(add-hook 'markdown-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
))
;;http://superuser.com/questions/306272/disable-emacs-auto-indentation-for-javascript-mode-completely
(defun my-js-mode-fix-hook ()
"日本語でjs-insert-and-indentがおかしいので無効にする"
(mapc (lambda (key)
(local-set-key key 'self-insert-command))
'("{" "}" "(" ")" ":" ";" ",")))
(add-hook 'js-mode-hook 'my-js-mode-fix-hook)
;(autoload 'gtags-mode "gtags" "" t)
;(require 'ee-autoloads)
;;change list-buffers
;;(global-set-key "\C-x\C-b" 'ee-buffers)
;;(global-set-key "\C-x\C-b" 'list-buffers)
(global-set-key "\C-x\C-b" 'buffer-menu)
(delete 'sgml-html-meta-auto-coding-function auto-coding-functions)
(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
;;http://yummyapplepie.wordpress.com/2008/07/29/open-python-eggs-directly-from-emacs/
(add-to-list 'auto-mode-alist '("\\.zip\\'" . archive-mode))
(add-to-list 'auto-mode-alist '("\\.egg\\'" . archive-mode))
(add-to-list 'auto-mode-alist '("\\.xlsx\\'" . archive-mode))
(add-to-list 'auto-mode-alist (cons "\\.wsgi\\'" 'python-mode))
(add-hook
'python-mode-hook
'(lambda ()
(define-key python-mode-map "\C-c\C-n" (lambda () ""
(interactive)
(if (or (python-comment-line-p)
(python-blank-line-p))
(python-next-statement)
;;decoratorも飛ばしたい
)
(python-end-of-block)))
;(define-key python-mode-map "\C-c\C-n" 'python-end-of-block)
(define-key python-mode-map "\C-c\C-p" 'python-beginning-of-block)
))
(require 'mule)
(set-language-environment 'Japanese)
;(set-default-coding-systems 'euc-jp-unix)
(set-default-coding-systems 'utf-8)
(prefer-coding-system 'utf-8-unix)
;(set-terminal-coding-system 'euc-jp-unix) ;; *1
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-clipboard-coding-system 'sjis-mac)
(setq coding-system-for-write nil)
(require 'rst)
(setq auto-mode-alist
(append '(("\\.rst$" . rst-mode)
("\\.rest$" . rst-mode)) auto-mode-alist))
;; 背景が黒い場合はこうしないと見出しが見づらい
;(setq frame-background-mode 'dark)
;; 全部スペースでインデントしましょう
(add-hook 'rst-mode-hook '(lambda()
(setq indent-tabs-mode nil)
(setq rst-slides-program "open")
))
(setq rst-compile-toolsets '((html "/opt/local/bin/rst2html-2.6.py" ".html" nil)
(latex "/opt/local/bin/rst2latex-2.6.py" ".tex" nil)
(newlatex "/opt/local/bin/rst2newlatex.py-2.6" ".tex" nil)
(pseudoxml "/opt/local/bin/rst2pseudoxml-2.6.py" ".xml" nil)
(xml "/opt/local/bin/rst2xml-2.6.py" ".xml" nil)
(pdf "/opt/local/bin/rst2pdf-2.6.py" ".pdf" nil)
(s5 "/opt/local/bin/rst2s5-2.6.py" ".xml" nil)))
;;http://lisperblog.blogspot.jp/2010/09/emacsunicode.html
(defun unicode-unescape-region (start end)
"指定した範囲のUnicodeエスケープ文字(\\uXXXX)をデコードする."
(interactive "*r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "\\\\u\\([[:xdigit:]]\\{4\\}\\)" nil t)
(replace-match (string (unicode-char
(string-to-number (match-string 1) 16)))
nil t))))
(defun unicode-escape-region (&optional start end)
"指定した範囲の文字をUnicodeエスケープする."
(interactive "*r")
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(while (re-search-forward "." nil t)
(replace-match (format "\\u%04x"
(char-unicode
(char (match-string 0) 0)))
nil t))))
;; #+:Emacs
;; こちらも参照→ http://github.com/kosh04/emacs-lisp > xyzzy.el
(defun char-unicode (char) (encode-char char 'ucs))
(defun unicode-char (code) (decode-char 'ucs code))
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
;;http://d.hatena.ne.jp/kitokitoki/20101114/p3
(require 'thingatpt)
(defadvice ruby-end-of-block (around my-ruby-end-of-block activate)
(interactive)
(if (thing-at-point-looking-at "\(\\|\{\\|\\[")
(forward-list)
ad-do-it))
(defadvice ruby-beginning-of-block (around my-ruby-beginning-of-block activate)
(interactive)
(if (thing-at-point-looking-at "\)\\|\}\\|\\]")
(backward-list)
ad-do-it))
;http://willnet.in/13
(setq ruby-deep-indent-paren-style nil)
(defadvice ruby-indent-line (after unindent-closing-paren activate)
(let ((column (current-column))
indent offset)
(save-excursion
(back-to-indentation)
(let ((state (syntax-ppss)))
(setq offset (- column (current-column)))
(when (and (eq (char-after) ?\))
(not (zerop (car state))))
(goto-char (cadr state))
(setq indent (current-indentation)))))
(when indent
(indent-line-to indent)
(when (> offset 0) (forward-char offset)))))
(require 'indent-guide)
;; M-x indent-guide-mode".
;; https://github.com/zk-phi/indent-guide
(indent-guide-global-mode)
;(require 'rinari)
;(ad-activate 'ruby-compilation-do)
;(require 'yaml-mode)
;(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
(require 'web-mode)
;http://gongo.hatenablog.com/entry/2015/04/01/215524
(require 'mmm-mode)
(setq mmm-global-mode 'maybe)
(add-hook 'mmm-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
))
(dolist (langsets '(("script" . ((coffee . coffee-mode)
(es6 . js-mode)))
("template" . ((jade . jade-mode)
(html . web-mode)))
("style" . ((stylus . stylus-mode)
(less . less-css-mode)
(scss . scss-mode)))))
(let ((tag (car langsets)))
(dolist (pair (cdr langsets))
(let* ((lang (car pair))
(submode (cdr pair))
(class-name (make-symbol (format "vueify-%s-%s" tag lang)))
(front (format "<%s lang=\"%s\">" tag lang))
(back (format "</%s>" tag)))
(mmm-add-classes
`((,class-name
:submode ,submode
:front ,front
:back ,back)))
(mmm-add-mode-ext-class nil "\\.vue?\\'" class-name)))))
(add-to-list 'auto-mode-alist '("\\.vue?\\'" . web-mode))
;; orgtbl-modeを使いたい
;(require 'org-install) ;必要?
(require 'org-table)
;;http://stackoverflow.com/questions/23378271/how-do-i-display-ansi-color-codes-in-emacs-for-any-mode
(require 'ansi-color)
(defun display-ansi-colors ()
(interactive)
(ansi-color-apply-on-region (point-min) (point-max)))
(require 'nvm)
(nvm-use "v6.11.0")
(add-hook 'js2-mode-hook 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)
(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.
'(auto-coding-functions nil)
'(bookmark-save-flag 1)
'(bookmark-version-control (quote never))
'(browse-url-generic-args nil)
'(coffee-tab-width 2)
'(dired-guess-shell-alist-user nil)
'(ediff-window-setup-function (quote ediff-setup-windows-plain))
'(flymake-gui-warnings-enabled nil)
'(indent-guide-inhibit-modes (quote (dired-mode)))
'(markdown-indent-on-enter nil)
'(markdown-italic-underscore nil)
'(package-selected-packages
(quote
(nvm prettier-js igrep yaml-mode web-mode stylus-mode scss-mode org mmm-mode markdown-mode+ less-css-mode js2-refactor js2-highlight-vars jade-mode indent-guide helm elscreen csv-mode coffee-mode)))
'(safe-local-variable-values (quote ((encoding . utf-8))))
'(tool-bar-mode nil)
'(vc-diff-switches "-bBwc")
'(web-mode-enable-auto-indentation nil))
(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.
'(indent-guide-face ((t (:foreground "light gray"))))
'(markdown-italic-face ((t (:slant normal))))
'(mmm-default-submode-face ((t nil)))
'(web-mode-html-attr-name-face ((t (:foreground "gray50"))))
'(web-mode-html-tag-face ((t (:foreground "blue1")))))
(put 'narrow-to-region 'disabled nil)
@nidate
Copy link
Author

nidate commented Sep 18, 2015

もうとっくに使ってないnavi2chとか入っていて恥ずかしい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment