こちらも取り急ぎ備忘録として。
最近webで情報を無理矢理ピックアップしてemacsを使いやすいようにsetupしました。
;; ロードパス
(setq load-path (cons "~/emacs/site-lisp" load-path))
(setq load-path (cons "~/emacs/site-lisp/w3m" load-path))
(add-to-list 'load-path "~/emacs/site-lisp/")
;; 画面の設定
(if window-system (progn
;;ウィンドウサイズでフォルト
(setq initial-frame-alist '((width . 200) (height . 52) (top . 0)(left . 0)))
;;文字の色
(add-to-list 'default-frame-alist '(foreground-color . "white"))
;; 背景色
(add-to-list 'default-frame-alist '(background-color . "black"))
))
;; カーソルの色を設定
(add-to-list 'default-frame-alist '(cursor-color . "Gray"))
;; マウスポインタの色を設定します。
(add-to-list 'default-frame-alist '(mouse-color . "SlateBlue2"))
;; モードラインの文字の色を設定します。
(set-face-foreground 'modeline "white")
;; モードラインの背景色を設定します。
(set-face-background 'modeline "MediumPurple2")
;; 選択中のリージョンの色を設定します。
; (set-face-background 'region "LightSteelBlue1")
;; モードライン(アクティブでないバッファ)の文字色を設定します。
(set-face-foreground 'mode-line-inactive "gray30")
;; モードライン(アクティブでないバッファ)の背景色を設定します。
(set-face-background 'mode-line-inactive "gray85")
;; ビープ音を消す
(setq visible-bell t)
;; デフォルトの透明度を設定する (85%)
(add-to-list 'default-frame-alist '(alpha . (80 50)))
;; 文字色変更
;(if window-system (progn;
;
;(set-face-foreground 'font-lock-comment-face "MediumSeaGreen")
;(set-face-foreground 'font-lock-string-face "purple")
;(set-face-foreground 'font-lock-keyword-face "blue")
;(set-face-foreground 'font-lock-function-name-face "blue")
;(set-face-bold-p 'font-lock-function-name-face t)
;(set-face-foreground 'font-lock-variable-name-face "black")
;(set-face-foreground 'font-lock-type-face "LightSeaGreen")
;(set-face-foreground 'font-lock-builtin-face "purple")
;(set-face-foreground 'font-lock-constant-face "gray")
;(set-face-foreground 'font-lock-warning-face "blue")
;(set-face-bold-p 'font-lock-warning-face nil)
;
;))
;; ファイルパス表示
(setq frame-title-format (format "%%f - Emacs@%s" (system-name)))
;; 行数表示
(line-number-mode t)
;; スタートアップページを表示しない
(setq inhibit-startup-message t)
;;バックアップファイルを作らない
(setq backup-inhibited t)
;; Macのキーバインドを使う. optionをメタキーにする
;;(mac-key-mode 1)
;(setq mac-option-modifier 'meta)
;; spotlightにとられないためのコード
;(mac-add-ignore-shortcut '(? ))
;(mac-add-ignore-shortcut '(control))
;;範囲指定 Ctr+Space
(setq transient-mark-mode t)
;;シフト + 矢印で範囲選択
(setq pc-select-selection-keys-only t)
(pc-selection-mode 1)
;;; タブ文字はスペース4文字分
(setq default-tab-width 4)
;; フォント設定
;(if (eq window-system 'mac) (require 'carbon-font))
;(fixed-width-Set-fontset "hirakaku_w3" 10)
;(setq fixed-width-rescale nil)
;;メニューバーを隠す
;(tool-bar-mode -1)
;;対応する括弧を光らせる
(show-paren-mode 1)
;; hline 編集行
(defface hlline-face
'((((class color)
(background dark))
;;(:background "dark state gray"))
(:background "gray10"
:underline "gray24"))
(((class color)
(background light))
(:background "ForestGreen"
:underline nil))
(t ()))
"*Face used by hl-line.")
(setq hl-line-face 'hlline-face)
;;(setq hl-line-face 'underline)
;; 編集行のハイライト
(global-hl-line-mode)
;; ウィンドウ分割時に画面外へ出る文章を折り返す
(setq truncate-partial-width-windows nil)
ここまでがもろもろの設定。
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; コマンド群 ;;;;;;;;;;;;
;;選択範囲をインデントする
(global-set-key "\C-x\C-i" 'indent-region)
;;リターンと改行でインデント
(global-set-key "\C-m" 'newline-and-indent)
;;改行
(global-set-key "\C-j" 'newline)
;;範囲指定コメント
(global-set-key "\C-c\C-c" 'comment-region)
;;上記解除
(global-set-key "\C-c\C-u" 'uncomment-region)
使いやすくするためのコマンド群.
;;linum 設定
(require 'linum)
(global-linum-mode t)
;(setq linum-format "%d5")
;F5キーにON/OFFの切り替えを割り当てる
(global-set-key [f5] 'linum-mode)
;; Elscreen ;;
;;tab
(require 'elscreen)
(if window-system
(define-key elscreen-map "\C-z" 'iconify-or-deiconify-frame)
(define-key elscreen-map "\C-z" 'suspend-emacs))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 使い方
;; C-z c : 新規タブ
;; C-z k : タブ閉じる
;; C-z 0~9 : タブの切り替え(番号)
;; C-z n : 次のタブ
;; C-z p : 前のタブ
;; C-z a : 直前のウィンドウ
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; tab 一覧表示 ;;
;; (defun elscreen-frame-title-update ()
;; (when (elscreen-screen-modified-p 'elscreen-frame-title-update)
;; (let* ((screen-list (sort (elscreen-get-screen-list) '<))
;; (screen-to-name-alist (elscreen-get-screen-to-name-alist))
;; (title (mapconcat
;; (lambda (screen)
;; (format "%d%s %s"
;; screen (elscreen-status-label screen)
;; (get-alist screen screen-to-name-alist)))
;; screen-list " ")))
;; (if (fboundp 'set-frame-name)
;; (set-frame-name title)
;; (setq frame-title-format title)))))
;; (eval-after-load "elscreen"
;; '(add-hook 'elscreen-screen-update-hook 'elscreen-frame-title-update))
;; 'mcomplete 他
;; ミニバッファで M-x時のインクリメンタル補完
(require 'mcomplete)
;; よく使うヒストリを優先させる
(load "mcomplete-history")
(turn-on-mcomplete-mode)
;; cycle-mini
(require 'cycle-mini)
(define-key minibuffer-local-map [up] 'previous-history-element)
(define-key minibuffer-local-completion-map [up] 'previous-history-element)
(define-key minibuffer-local-must-match-map [up] 'previous-history-element)
(define-key minibuffer-local-ns-map [up] 'previous-history-element)
(define-key minibuffer-local-ns-map [down] 'next-history-element)
(define-key minibuffer-local-map [down] 'next-history-element)
(define-key minibuffer-local-completion-map [down] 'next-history-element)
(define-key minibuffer-local-must-match-map [down] 'next-history-element)
行数を表示するlinum, tab化するElscreen, 補完機能強化のmcomplete, cycle-miniの設定ファイル. いずれも
~/emacs/site-lisp/
配下に
- linum.el
- elscreen.el
- mcomplete.el
- mcomplete-history.el
- cycle-mini.el
を置きます。
例によってこれで素人がCarbon Emacsを使える設定となりました。
linumがページを動かすたびに行数表示のため更新されるので少し動作がもっさりするのが不満。
ずぶの素人がなぜemacsかというと、学校でemacsしか使ったことがなく、vimよりも慣れているということです。
ぱっと書く程度のエディタならvimの方が便利そうなので、普通の使い方くらいは覚えます。
それも備忘録としてまた今度。