現状の init.el 構成¶
基本コードのリスティング¶
init.el¶
;; ======================================== ;;
;; ===== init.el ====== ;;
;; ======================================== ;;
;; -------------------------------- ;;
;; --- [1] Package include --- ;;
;; -------------------------------- ;;
;;
;; --- proxy --- ;;
;; (setq url-proxy-services
;; '(("http" . "http://proxy.intra.co.jp:8080")
;; ("https" . "http://proxy.intra.co.jp:8080"))
;; )
;;
;; --- packages --- ;;
(require 'package)
(setq package-archives
'(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)
;; --------------------------------- ;;
;; --- [2] call init-loader --- ;;
;; --------------------------------- ;;
(require 'init-loader)
(init-loader-load "~/.emacs.d/inits")
inits/00_language.el¶
;; ================================================== ;;
;; === 00 Language === ;;
;; ================================================== ;;
;;
;; ---------------------------- ;;
;; --- language :: Japanese --- ;;
;; ---------------------------- ;;
;;
(set-language-environment "Japanese")
(prefer-coding-system 'utf-8)
(setq-default buffer-file-coding-system 'utf-8)
(setq coding-system-for-read 'utf-8)
(setq coding-system-for-write 'utf-8)
;; --- default fonts for japanese -- ;;
;;
;; -- HackGen Fonts -- ;;
;; (set-frame-font "HackGen-13" nil t)
;; (set-fontset-font t 'japanese-jisx0208 "HackGen") -- Ricty-14 = HackGen-13 --
;;
;; -- Ricty Fonts -- ;;
(set-frame-font "ricty-14" nil t)
(set-fontset-font t 'japanese-jisx0208 "Ricty")
;;
;; ------------------------------------ ;;
;; -- Windows WSL2用 日本語設定 -- ;;
;; ------------------------------------ ;;
;; ;; --- 日本語IMEの設定 --- ;;
;; (require 'mozc)
;; (setq default-input-method "japanese-mozc")
;; (global-set-key [zenkaku-hankaku] 'toggle-input-method)
;; ;; -- macOS-like な変換 --- ;;
;; (defun my-ime-on () "日本語入力ON"
;; (interactive)
;; (unless current-input-method
;; (toggle-input-method))
;; )
;; (defun my-ime-off () "日本語入力OFF"
;; (interactive)
;; (when current-input-method
;; (deactivate-input-method))
;; )
;; (global-set-key [henkan] 'my-ime-on)
;; (global-set-key [muhenkan] 'my-ime-off)
;; ;; モードラインでIME状態を表示(任意)
;; (setq-default mode-line-format
;; (append mode-line-format
;; '((:eval (if current-input-method "[あ]" "[--]")))))
inits/10_basics.el¶
;; ================================================== ;;
;; === 50 General Settings === ;;
;; ================================================== ;;
;; --------------------------------------- ;;
;; --- [1] Window size --- ;;
;; --------------------------------------- ;;
(setq initial-frame-alist '((fullscreen . maximized)) )
;; (add-to-list 'default-frame-alist '(undecorated .t)) ;; -- 枠なし -- ;;
;; --------------------------------------- ;;
;; --- [2] Color theme --- ;;
;; --------------------------------------- ;;
(setq custom-theme-directory "~/.emacs.d/themes")
(load-theme 'mytheme t)
;; --------------------------------------- ;;
;; --- [3] Preferences --- ;;
;; --------------------------------------- ;;
;;
;; バックアップファイルの保存先ディレクトリ
(setq backup-directory-alist
(cons (cons ".*" (expand-file-name "~/.emacs.d/backups/"))
backup-directory-alist))
;; 自動保存ファイルの保存先ディレクトリ
(setq auto-save-file-name-transforms
`((".*", (expand-file-name "~/.emacs.d/backups/") t)))
;;
(menu-bar-mode -1) ;; -- メニューバー要らない -- ;;
(tool-bar-mode -1) ;; -- ツールバー 要らない -- ;;
(scroll-bar-mode -1) ;; -- スクロールバー 要らない -- ;;
;; (global-linum-mode t) ;; -- 行番号を常に表示 -- ;;
(global-hl-line-mode t) ;; -- カーソル行をハイライト -- ;;
(show-paren-mode 1) ;; -- 対応する括弧を光らせる -- ;;
(setq ring-bell-function 'ignore) ;; -- beep off -- ;;
(setq scroll-conservatively 1) ;; -- スクロールは1行ごとに -- ;;
(setq isearch-case-fold-search t) ;; -- インクリメンタルサーチ時には大文字小文字の区別をしない -- ;;
(display-time) ;; -- モードラインに時刻表示 -- ;;
(line-number-mode t) ;; -- 行番号、桁番号を表示する -- ;;
(transient-mark-mode 1) ;; -- リージョンを光らせる -- ;;
(defalias 'yes-or-no-p 'y-or-n-p) ;; -- yes => y , no => n -- ;;
;; -- 大文字・小文字区別 case-insensitiveにする -- ;;
(setq read-buffer-completion-ignore-case t)
(setq read-file-name-completion-ignore-case t)
inits/20_customs.el¶
;; -------------------------------------------------- ;;
;; --- 21 Original Functions --- ;;
;; -------------------------------------------------- ;;
;; --------------------------------------- ;;
;; --- [1] C-x #で画面横3分割 --- ;;
;; --------------------------------------- ;;
(defun split-window-horizontally-n (num_wins)
(interactive "p")
(if (= num_wins 2)
(split-window-horizontally)
(progn
(split-window-horizontally
(- (window-width) (/ (window-width) num_wins)))
(split-window-horizontally-n (- num_wins 1)))))
(global-set-key "\C-x#" '(lambda ()
(interactive)
(split-window-horizontally-n 3)))
;; --------------------------------------- ;;
;; --- [2] 更新コマンド --- ;;
;; --------------------------------------- ;;
;; Ctr-r == update window ;;
(defun revert-buffer-no-confirm (&optional force-reverting)
(interactive "P")
(if (or force-reverting (not (buffer-modified-p)))
(revert-buffer :ignore-auto :noconfirm)
(error "The buffer has been modified")))
;; -- Revert バッファ を フック --- ;;
(global-set-key "\M-r" 'revert-buffer-no-confirm)
;; --------------------------------------- ;;
;; --- [3] emacsを最大化 (Ctr-x +w) --- ;;
;; --------------------------------------- ;;
;; 画面最大化するコマンド ==
(global-set-key "\C-xw" 'toggle-frame-maximized)
;; --------------------------------------- ;;
;; --- [4] 整列コマンド (align-regexp) --- ;;
;; --------------------------------------- ;;
;; 空白でスペース
;; Align with spaces only
(defadvice align-regexp (around align-regexp-with-spaces)
"Never use tabs for alignment."
(let ((indent-tabs-mode nil))
ad-do-it))
(ad-activate 'align-regexp)
(global-set-key "\C-xt" 'align-regexp)
;; --------------------------------------- ;;
;; --- [5] File 名入力関数 --- ;;
;; --------------------------------------- ;;
;; -- https://www.emacswiki.org/emacs/InsertFileName -- ;;
(defun bjm/insert-file-name (filename &optional args)
;; Based on insert-file in Emacs -- ashawley 20080926
(interactive "*fInsert file name: \nP")
(cond ((eq '- args)
(insert (expand-file-name filename)))
((not (null args))
(insert filename))
(t
(insert (file-relative-name filename))))
)
(global-set-key (kbd "C-c i") 'bjm/insert-file-name)
;; -------------------------------------------------- ;;
;; --- 22 Original modes load --- ;;
;; -------------------------------------------------- ;;
;; --------------------------------------- ;;
;; --- [1] Original mode / theme --- ;;
;; --------------------------------------- ;;
(add-to-list 'load-path "~/.emacs.d/modes/")
(require 'def-mode)
(require 'phits-mode)
(require 'elmer-mode)
(require 'jsonc-mode)
(require 'rst-extensions)
;; --------------------------------------- ;;
;; --- [2] yasnippets --- ;;
;; --------------------------------------- ;;
;; (add-to-list 'load-path
;; (expand-file-name "~/.emacs.d/elpa/yasnippet/"))
;; (add-to-list 'load-path
;; (expand-file-name "~/.emacs.d/elpa/yasnippet-snippets-20190422.1416/"))
;; 自分用・追加用テンプレート -> mysnippetに作成したテンプレートが格納される
(add-to-list 'load-path
"~/.emacs.d/lisps/yasnippet")
(require 'yasnippet)
(setq yas-snippet-dirs
'("~/.emacs.d/snippets"))
(yas-global-mode 1)