Emacs(20200101_0010)
■Emacsを使う理由■インストール
■init.el
■スタートアップメッセージを表示させない
■ビープ音禁止
■バックアップファイルを作成させない
■オートセーブファイルを作らない
■タイトルバーにファイルのフルパスを表示
■行番号の表示
■位置表示(行列)
■現在行を目立たせる
■カーソルの場所を保存する
■タブ幅の設定
■対応するカッコをハイライト表示する
■勝手にインデントされるのを防ぐ
■カレントディレクトリをホームディレクトリに設定
■C-x C-b でバッファリストを開く時に、ウィンドウを分割しない
■行を折り返さないようにする
■水平スクロールバー表示
■起動時のウィンドウサイズ、色などを設定
■フォント
■履歴
■日本語環境
■Grep
■Windowsキーバインド
■plugin
■tabbar
■redo+
■ツールバー
■ファイルをダブルクリックで同じWindowに表示する
■使用方法
■org-mode
■Emacsを使う理由
・Window操作 ・実績がある ・VimはキーバインドがWindows標準と比べて特殊すぎる しかし、日本語に不親切なところも・・・
■インストール ・Windowsの場合
GNU Emacs https://www.gnu.org/software/emacs/download.html#windows
■init.el
C:\Users\ユーザー名\AppData\Roaming\.emacs.d 以下にinit.elを作成 ;でコメント
■スタートアップメッセージを表示させない
(setq inhibit-startup-message t)
■ビープ音禁止
(setq ring-bell-function 'ignore)
■バックアップファイルを作成させない
(setq make-backup-files nil)
■オートセーブファイルを作らない
(setq auto-save nil)
■タイトルバーにファイルのフルパスを表示
(setq frame-title-format "%f")
■行番号の表示
(global-linum-mode t)
■位置表示(行列)
(line-number-mode t) (column-number-mode t)
■現在行を目立たせる
(global-hl-line-mode)
■カーソルの場所を保存する
(save-place-mode 1)
■タブ幅の設定
(setq tab-width 4)
■対応するカッコをハイライト表示する
(show-paren-mode 1)
■勝手にインデントされるのを防ぐ
(show-paren-mode 1)
■カレントディレクトリをホームディレクトリに設定
(cd "~/")
■C-x C-b でバッファリストを開く時に、ウィンドウを分割しない
(global-set-key "\C-x\C-b" 'buffer-menu)
■行を折り返さないようにする
;; 通常のウィンドウ用の設定 (setq truncate-lines t) ;; ウィンドウを左右に分割したとき用の設定 (setq truncate-partial-width-windows t)
■水平スクロールバー表示
(custom-set-variables '(horizontal-scroll-bar-mode t))
■起動時のウィンドウサイズ、色などを設定
;; 起動時のウィンドウサイズ、色などを設定 (if (boundp 'window-system) (setq default-frame-alist (append (list '(foreground-color . "black") ; 文字色 '(background-color . "white") ; 背景色 '(border-color . "white") ; ボーダー色 '(mouse-color . "black") ; マウスカーソルの色 '(cursor-color . "black") ; カーソルの色 '(cursor-type . box) ; カーソルの形状 '(top . 30) ; ウィンドウの表示位置(Y座標) '(left . 240) ; ウィンドウの表示位置(X座標) '(width . 140) ; ウィンドウの幅(文字数) '(height . 55) ; ウィンドウの高さ(文字数) ) default-frame-alist))) (setq initial-frame-alist default-frame-alist )
■フォント
;; フォント (set-face-attribute 'default nil :family "Menlo" :height 140) (set-fontset-font (frame-parameter nil 'font) 'japanese-jisx0208 (font-spec :family "Hiragino Kaku Gothic ProN")) (add-to-list 'face-font-rescale-alist '(".*Hiragino Kaku Gothic ProN.*" . 1.2))
■履歴
;; 履歴を次回Emacs起動時にも保存する (savehist-mode 1) ;;; 履歴をたくさん保存する (setq history-length 1000)
■日本語環境
(set-language-environment "Japanese") ;UTF-8 ;(prefer-coding-system 'utf-8)
■Grep
;日本語をgrepするなら素直にWindows標準のfindstr (setq grep-command "findstr /n /s *") ;/s:再帰検索 ;/r:正規表現 ;*(すべてのファイル):*.txt *.c *.h でtxtファイル、cファイル、hファイルを検索 ;M-x grepでfindstr /n /s 検索文字列 *のように使う ;検索結果一覧でn,pボタンで順に表示
■Windwosキーバインド
cua-mode
■plugin
C:\Users\ユーザー名\AppData\Roaming\.emacs.d 以下にelispフォルダを作成 init.elの先頭に以下を追加 (add-to-list 'load-path "~/.emacs.d/elisp")
■tabbar
C:\Users\ユーザー名\AppData\Roaming\.emacs.d\elisp にtabbar.elを追加 init.elに以下を追加 (when (require 'tabbar nil t) (tabbar-mode)) (tabbar-mode 1) ;; タブ上でマウスホイール操作無効 (tabbar-mwheel-mode -1) ;; グループ化しない (setq tabbar-buffer-groups-function nil) ;; 画像を使わないことで軽量化する (setq tabbar-use-img nil) ;;----- 左側のボタンを消す (dolist (btn '(tabbar-buffer-home-button tabbar-scroll-left-button tabbar-scroll-right-button)) (set btn (cons (cons "" nil) (cons "" nil)))) (global-set-key (kbd "C-") 'tabbar-forward-tab) (global-set-key (kbd "C- ") 'tabbar-backward-tab)
■redo+
C:\Users\ユーザー名\AppData\Roaming\.emacs.d\elisp にredo+.elを追加 init.elに以下を追加 ;; リドゥ (require 'redo+) (setq undo-no-redo t) ; 過去のundoがredoされないようにする (setq undo-limit 600000) (setq undo-strong-limit 900000) (define-key global-map(kbd "M-_") 'redo)
■ツールバー
C:\Users\ユーザー名\AppData\Roaming\.emacs.d\img以下にxpmファイル(画像)を追加 init.elに以下を追加 ;; init.elを開く (defun my-init-el () (interactive) (find-file "~/.emacs.d/init.el")) ;; 子メニューの定義 (setq menu-bar-my-menu-work (make-sparse-keymap)) (define-key-after menu-bar-my-menu-work [my-anything-buffer-not-found] '("新規作成" . find-file)) ;; マイメニューの定義 (setq menu-bar-my-menu (make-sparse-keymap "マイメニュー")) ;; init.elを開く (define-key-after menu-bar-my-menu [initel] '("init.elを開く" . my-init-el)) ;; セパレーター (define-key-after menu-bar-my-menu [separator1] '("--")) ;; 子メニュー (define-key-after menu-bar-my-menu [work] (cons "work" menu-bar-my-menu-work)) ;; command menu (defun show-menu-bar-my-menu () (interactive) (popup-menu menu-bar-my-menu)) (let ((tool-bar-map (default-value 'tool-bar-map))) (tool-bar-add-item "new" 'show-menu-bar-my-menu 'メニュー :help "メニュー"))
■ファイルをダブルクリックで同じWindowに表示する
◇init.el (require 'server) (server-start) ◇いずれかを実行(レジストリを触りたくない場合はemacs.bat) ・regeditで(レジストリを触る際は注意!システムが起動しなくなる場合あり!) HKEY_CLASSES_ROOT\Applications\emacsclientw.exe\shell\open\command "C:\Program Files\emacs-26.3-x86_64\bin\emacsclientw.exe" "%1" を "C:\Program Files\emacs-26.3-x86_64\bin\emacsclientw.exe" "-a C:\PROGRA~1\emacs-26.3-x86_64\bin\runemacs.exe" "%1" に変更 (なぜか-aはPROGRA~1にしないと起動できなかった) ・emacs.bat emacs.batを C:\Program Files\emacs-26.3-x86_64\bin に作成 内容 cd C:\Program Files\emacs-26.3-x86_64\bin start emacsclientw -a runemacs %1 exit