Last active
November 29, 2022 03:20
-
-
Save ak-ymst/6eef32bf803ae767f6db054b6300c709 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*- | |
(when load-file-name | |
(setq user-emacs-directory (file-name-directory load-file-name))) | |
(setq ring-bell-function 'ignore) | |
(defvar oldemacs-p (<= emacs-major-version 22)) | |
(when oldemacs-p | |
(defvar user-emacs-directory | |
(expand-file-name (concat (getenv "HOME") "/.emacs.d/")))) | |
(defun add-to-load-path (&rest paths) | |
(let (path) | |
(dolist (path paths paths) | |
(let ((default-directry (expand-file-name (concat user-emacs-directory path)))) | |
(add-to-list 'load-path default-directory) | |
(if (fboundp 'normal-top-level-add-subdirs-to-load-path) | |
(normal-top-level-add-subdirs-to-load-path)))))) | |
;; elispとconfディレクトリをロ-ドパスに追加 | |
;; (add-to-load-path "elisp" "conf") | |
(add-to-list 'load-path' "~/.emacs.d/elisp") | |
(add-to-list 'load-path' "~/.emacs.d/elpa") | |
(add-to-list 'load-path' "~/.emacs.d/conf") | |
(add-to-list 'load-path (locate-user-emacs-file "el-get/el-get")) | |
(unless (require 'el-get nil 'noerror) | |
(with-current-buffer | |
(url-retrieve-synchronously | |
"https://raw.githubusercontent.com/dimitri/el-get/master/el-get-install.el") | |
(goto-char (point-max)) | |
(eval-print-last-sexp))) | |
;; add package archives | |
(require 'package) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.org/packages/") t) | |
; (add-to-list 'package-archives | |
; '("marmalade" . "http://marmalade-repo.org/packages/")) | |
(when (< emacs-major-version 24) | |
;; For important compatibility libraries like cl-lib | |
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) | |
(package-initialize) | |
;; バックアップファイルの保存先を変更 | |
(setq backup-directory-alist | |
(cons (cons ".*" (expand-file-name "~/.emacs.d/backup")) | |
backup-directory-alist)) | |
;; 自動保存ファイル(#...#)の保存先を変更 | |
(setq auto-save-file-name-transforms | |
`((".*", (expand-file-name "~/.emacs.d/backup/") t))) | |
(require 'exec-path-from-shell) | |
(exec-path-from-shell-initialize) | |
;; (install-elisp "http://www.emacswiki.org/emacs/download/auto-install.el") | |
(when (require 'auto-install nil t) | |
(setq auto-install-directory "~/.emacs.d/elisp/") | |
(auto-install-update-emacswiki-package-name t) | |
(auto-install-compatibility-setup)) | |
;; 暫定リ-ジョンモ-ドを有効にする | |
;; 何故かnilに設定すると有効になる… | |
(setq transient-mark-mode nil) | |
;; キ-バインド変更 | |
(define-key global-map (kbd "C-m") 'newline-and-indent) | |
(define-key global-map (kbd "C-t") 'other-window) | |
(define-key global-map (kbd "C-h") 'delete-backward-char) | |
(global-set-key (kbd "C-x <left>") 'windmove-left) | |
(global-set-key (kbd "C-x <down>") 'windmove-down) | |
(global-set-key (kbd "C-x <up>") 'windmove-up) | |
(global-set-key (kbd "C-x <right>") 'windmove-right) | |
;; Macの場合Metaキーを入れ替える | |
(setq mac-option-key-is-meta t | |
mac-command-key-is-meta nil | |
mac-command-modifier 'super | |
mac-option-modifier 'meta) | |
(setq default-input-method "MacOSX") | |
;; Macのクリップボードと同期する | |
(defun copy-from-osx () | |
(shell-command-to-string "pbpaste")) | |
(defun paste-to-osx (text &optional push) | |
(let ((process-connection-type nil)) | |
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy"))) | |
(process-send-string proc text) | |
(process-send-eof proc)))) | |
(setq interprogram-cut-function 'paste-to-osx) | |
(setq interprogram-paste-function 'copy-from-osx) | |
;; クレジット画面を表示しない | |
(setq inhibit-startup-screen t) | |
;; anything | |
;; (auto-install-batch "anything") | |
(when (require 'anything nil t) | |
(setq | |
anything-idle-delay 0.3 | |
anything-input-idle-delay 0.2 | |
anything-candidate-number-limit 100 | |
anything-quick-update t | |
anything-enable-shortcut 'alphabet) | |
(when (require 'anything-config nil t) | |
(setq anything-su-or-sudo "sudo")) | |
(require 'anything-match-plugin nil t) | |
(and (equal current-language-environment "Japanese") | |
(executable-find "cmigemo") | |
(require 'anything-migemo nil t)) | |
(when (require 'anything-complete nil t) | |
;; (anything-read-string-mode 1) | |
(anything-lisp-complete-symbol-set-timer 150)) | |
(require 'anything-show-completion nil t) | |
(when (require 'auto-install nil t) | |
(require 'anything-auto-install nil t)) | |
(when (require 'descbinds-anything nil t) | |
(descbinds-anything-install)) | |
(require 'anything-grep nil t) | |
) | |
;; Windowモードで起動した際の設定 | |
(if window-system (progn | |
(tool-bar-mode 0) | |
(scroll-bar-mode 0) | |
(menu-bar-mode 0) | |
(setq show-paren-delay 0) | |
(show-paren-mode t) | |
(setq show-paren-style 'expression) | |
;(set-face-background 'show-paren-match-face nil) | |
;(set-face-underline-p 'show-paren-match-face "yellow") | |
(set-face-attribute 'show-paren-match nil :background 'unspecified :unserline "yellow") | |
;; asciiフォントをMenloに変更 | |
(set-face-attribute 'default nil :family "Menlo" :height 120) | |
(set-language-environment "Japanese") | |
(require 'ucs-normalize) | |
(prefer-coding-system 'utf-8) | |
(setq file-name-coding-system 'utf-8) | |
(setq locale-coding-system 'utf-8) | |
;; 日本語フォントをヒラギノ明朝ProNに変更 | |
(set-fontset-font nil 'japanese-jisx0208 | |
(font-spec :family "Hiragino_Mincho_ProN")) | |
)) | |
;; 行番号フォーマット | |
(setq linum-format "%4d") | |
;; 括弧の範囲内を強調表示 | |
(show-paren-mode t) | |
(setq show-paren-delay 0) | |
(setq show-paren-style 'expression) | |
;; 括弧の範囲色 | |
; (set-face-background 'show-paren-match-face "#1ABC9C") | |
(set-face-attribute 'show-paren-match nil :background "#1ABC9C") | |
;; 選択領域の色 | |
(set-face-background 'region "#555") | |
;; 行末の空白を強調表示 | |
(setq-default show-trailing-whitespace t) | |
(set-face-background 'trailing-whitespace "#b14770") | |
;; Emacs用ターミナル | |
;; (install-elisp "http://www.emacswiki.org/emacs/download/multi-term.el") | |
(when (require 'multi-term nil t) | |
(setq multi-term-program shell-file-name) | |
) | |
;; Gitフロントエンド | |
(require 'magit) | |
(setq magit-last-seen-setup-instructions "1.4.0") | |
(global-set-key (kbd "C-c m") 'magit-status) | |
;;php-mode | |
(load-library "php-mode") | |
(require 'php-mode) | |
(autoload 'php-mode "php-mode") | |
(setq auto-mode-alist (cons '("\\.php\\'" . php-mode) auto-mode-alist)) | |
(add-hook 'php-mode-hook | |
(lambda() | |
(setq tab-width 4) | |
(setq indent-tabs-mode nil) | |
(setq c-basic-offset 4) | |
;; (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)) | |
) | |
) | |
;;server strt for emacs-client | |
(require 'server) | |
(unless (server-running-p) | |
(server-start)) | |
(require 'whitespace) | |
(set-face-foreground 'whitespace-space "DarkGoldenrod1") | |
(set-face-background 'whitespace-space nil) | |
(set-face-bold-p 'whitespace-space t) | |
(set-face-foreground 'whitespace-tab "DarkOliveGreen1") | |
(set-face-background 'whitespace-tab nil) | |
(set-face-underline 'whitespace-tab t) | |
(setq whitespace-style '(face tabs tab-mark spaces space-mark)) | |
(setq whitespace-space-regexp "\\(\x3000+\\)") | |
(setq whitespace-display-mappings | |
'((space-mark ?\x3000 [?\□]) | |
(tab-mark ?\t [?\xBB ?\t]) | |
)) | |
(global-whitespace-mode 1); 全角スペースを常に表示 | |
(global-set-key (kbd "C-x w") 'global-whitespace-mode) ; 全角スペース表示の切替 | |
(setq whitespace-style '(face ; faceで可視化 | |
trailing ; 行末 | |
tabs ; タブ | |
empty ; 先頭/末尾の空行 | |
space-mark ; 表示のマッピング | |
tab-mark | |
)) | |
(require 'tramp) | |
(setq tramp-default-method "ssh") | |
(el-get-bundle yasnippet) | |
;; (require 'yasnippet) | |
;; (setq yas-snippet-dirs | |
;; '("~/.emacs.d/snippets")) | |
;; (yas-global-mode 1) | |
(el-get-bundle helm) | |
(el-get-bundle helm-git-grep) | |
(el-get-bundle helm-ls-git) | |
(require 'helm-config) | |
(helm-mode 1) | |
(define-key helm-read-file-map (kbd "C-h") 'delete-backward-char) | |
(define-key helm-read-file-map (kbd "<tab>") 'helm-execute-persistent-action) | |
;; (el-get-bundle flycheck) -- not supported el-get | |
(add-hook 'after-init-hook #'global-flycheck-mode) | |
;; gtags-mode | |
(el-get-bundle helm-gtags) | |
(require 'gtags) | |
;; helm-gtags-modeのキーバインド | |
;; (add-hook 'helm-gtags-mode-hook | |
;; '(lambda () | |
;; (define-key helm-gtags-mode-map (kbd "C-c g t") 'helm-gtags-find-tag) ;;入力された関数の定義元へジャンプ | |
;; (define-key helm-gtags-mode-map (kbd "C-c g r") 'helm-gtags-find-rtag) ;;入力関数を参照する場所へジャンプ | |
;; (define-key helm-gtags-mode-map (kbd "C-c g s") 'helm-gtags-find-symbol) ;;入力した変数を参照する場所へジャンプ | |
;; (define-key helm-gtags-mode-map (kbd "C-c g l") 'helm-gtags-select) ;;タグ一覧からタグを選択し, その定義元にジャンプする | |
;; (define-key helm-gtags-mode-map (kbd "C-c g b") 'helm-gtags-pop-stack)) ;;ジャンプ前の場所に戻る(back) | |
;; (define-key helm-gtags-mode-map (kbd "C-c g p") 'helm-gtags-parse-file) ;;現在のファイルを解析 | |
;; ) | |
(add-hook 'php-mode-hook 'helm-gtags-mode) | |
(defun sqlf (start end) | |
"リージョンのSQLを整形する" | |
(interactive "r") | |
(let ((case-fold-search t)) | |
(let* ((s (buffer-substring-no-properties start end)) | |
(s (replace-regexp-in-string "\\(select \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(update \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(insert into \\)\\(fuga\\)\\(fuga\\)" "\n\\2\n " s)) | |
(s (replace-regexp-in-string "\\(delete from \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(create table \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(alter table \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(drop constraint \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(from \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(exists \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(where \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(values \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(order by \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(group by \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(having \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(left join \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(left outer join )\\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(right join \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(right outer join \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(inner join \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(cross join \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(union join \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(and \\)" "\n \\1" s)) | |
(s (replace-regexp-in-string "\\(or \\)" "\n \\1\n" s)) | |
(s (replace-regexp-in-string "\\(any \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(on update restrict \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(on update cascade \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(on update set null \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(on update no action \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(on delete restrict \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(on delete cascade \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(on delete set null \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(on delete no action \\)" "\n\\1\n " s)) | |
(s (replace-regexp-in-string "\\(,\\)" "\n \\1" s))) | |
(save-excursion | |
(insert s))))) | |
(el-get-bundle anzu) | |
(global-anzu-mode +1) | |
(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. | |
'(anzu-deactivate-region t) | |
'(anzu-mode-lighter "") | |
'(anzu-search-threshold 1000) | |
'(package-selected-packages | |
'(js2-mode geben howm markdown-mode use-package tern-auto-complete flycheck php-mode magit go-eldoc go-direx go-autocomplete exec-path-from-shell company-go))) | |
;; markdown-mode | |
(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)) | |
(autoload 'gfm-mode "gfm-mode" | |
"Major mode for editing GitHub Flavored Markdown files" t) | |
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode)) | |
;; howm-mode | |
;; (add-to-list 'load-path' "~/.emacs.d/elisp/howm/") | |
(global-set-key (kbd "C-c , ,") 'howm-menu) | |
(setq howm-menu-lang 'ja) | |
(defvar howm-view-title-header "# ") ; this should be evaluated in advance to handle markdown | |
(autoload 'howm-menu "howm" "Hitori Otegaru Wiki Modoki" t) | |
;; howmが生成するファイルの置き場所 | |
(setq howm-home-directory "~/howm/") | |
;; キーワード一覧 | |
(setq howm-keyword-file (concat howm-home-directory ".howm-keys")) | |
;; 履歴一覧 | |
(setq howm-history-file (concat howm-home-directory ".howm-history")) | |
;; 編集をmarkdown-modeで行う | |
(defun markdown-text-mode () | |
(markdown-mode) ; major | |
(outline-minor-mode) ; minor | |
) | |
(add-to-list 'auto-mode-alist '("\\.txt$" . markdown-text-mode)) | |
; disable auto-fill-mode | |
(add-hook 'howm-mode-hook '(lambda () (auto-fill-mode -1))) | |
;; golang | |
(require 'go-mode) | |
(require 'company-go) | |
(require 'go-autocomplete) | |
(require 'auto-complete-config) | |
(require 'go-direx) | |
(require 'go-eldoc) | |
;; 諸々の有効化、設定 | |
(add-hook 'go-mode-hook (lambda() | |
(add-hook 'before-save-hook' 'gofmt-before-save) | |
(local-set-key (kbd "M-.") 'godef-jump) | |
(local-set-key (kbd "C-c C-j") 'go-direx-pop-to-buffer) | |
(local-set-key (kbd "C-c C-a") 'go-import-add) | |
(local-set-key (kbd "C-c C-r") 'go-remove-unused-imports) | |
(set (make-local-variable 'company-backends) '(company-go)) | |
(company-mode) | |
(flycheck-mode) | |
(setq indent-tabs-mode t) ; タブを利用 | |
(setq c-basic-offset 4) ; tabサイズを4にする | |
(setq tab-width 4))) | |
(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. | |
) | |
;; geben vars | |
(setq geben-path-mappings '(("/Users/yamashita.akihito/project/s3_api/app" "/app"))) | |
;; spell checker | |
(setq-default ispell-program-name "aspell") | |
(with-eval-after-load "ispell" | |
(setq ispell-local-dictionary "en_US") | |
(add-to-list 'ispell-skip-region-alist '("[^\000-\377]+"))) | |
;; (add-hook 'latex-mode-hook 'flyspell-mode) | |
(use-package flyspell | |
:hook (php-mode . flyspell-mode)) | |
;; js2-mode | |
(use-package js2-mode | |
:init | |
(add-to-list 'auto-mode-alist '("\\.js$" . js-mode)) | |
(add-to-list 'auto-mode-alist '("\\.jsx$" . js-mode)) | |
(add-to-list 'auto-mode-alist '("\\.tsx$" . js-mode)) | |
(add-hook 'js-mode-hook 'js2-minor-mode) | |
:config | |
(setq indent-tabs-mode nil) | |
(setq js-indent-level 2) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment