UbuntuにEmacs24をインストールした時のログとinit.elの備忘録

インストー

ubuntu@ubuntu-14:~/c++/2.2$ sudo apt-get install emacs24-nox
[sudo] password for ubuntu: 
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下の特別パッケージがインストールされます:
  emacs24-bin-common emacs24-common emacs24-common-non-dfsg emacsen-common libasound2 libasound2-data
提案パッケージ:
  emacs24-el libasound2-plugins alsa-utils
以下のパッケージが新たにインストールされます:
  emacs24-bin-common emacs24-common emacs24-common-non-dfsg emacs24-nox emacsen-common libasound2 libasound2-data
アップグレード: 0 個、新規インストール: 7 個、削除: 0 個、保留: 63 個。
21.4 MB のアーカイブを取得する必要があります。
この操作後に追加で 87.0 MB のディスク容量が消費されます。
続行しますか? [Y/n] Y
取得:1 http://jp.archive.ubuntu.com/ubuntu/ trusty/main libasound2-data all 1.0.27.2-3ubuntu7 [26.3 kB]
取得:2 http://jp.archive.ubuntu.com/ubuntu/ trusty/main libasound2 amd64 1.0.27.2-3ubuntu7 [327 kB]
取得:3 http://jp.archive.ubuntu.com/ubuntu/ trusty/main emacsen-common all 2.0.7 [17.1 kB]
取得:4 http://jp.archive.ubuntu.com/ubuntu/ trusty/main emacs24-common-non-dfsg all 24.3+1-1 [4,421 kB]
取得:5 http://jp.archive.ubuntu.com/ubuntu/ trusty/main emacs24-common all 24.3+1-2ubuntu1 [13.7 MB]                                         
取得:6 http://jp.archive.ubuntu.com/ubuntu/ trusty/main emacs24-bin-common amd64 24.3+1-2ubuntu1 [104 kB]                                    
取得:7 http://jp.archive.ubuntu.com/ubuntu/ trusty/main emacs24-nox amd64 24.3+1-2ubuntu1 [2,807 kB]                                         
21.4 MB を 1分 43秒 で取得しました (207 kB/s)                                                                                                
以前に未選択のパッケージ libasound2-data を選択しています。
(データベースを読み込んでいます ... 現在 60398 個のファイルとディレクトリがインストールされています。)
Preparing to unpack .../libasound2-data_1.0.27.2-3ubuntu7_all.deb ...
Unpacking libasound2-data (1.0.27.2-3ubuntu7) ...
以前に未選択のパッケージ libasound2:amd64 を選択しています。
Preparing to unpack .../libasound2_1.0.27.2-3ubuntu7_amd64.deb ...
Unpacking libasound2:amd64 (1.0.27.2-3ubuntu7) ...
以前に未選択のパッケージ emacsen-common を選択しています。
Preparing to unpack .../emacsen-common_2.0.7_all.deb ...
Unpacking emacsen-common (2.0.7) ...
以前に未選択のパッケージ emacs24-common-non-dfsg を選択しています。
Preparing to unpack .../emacs24-common-non-dfsg_24.3+1-1_all.deb ...
Unpacking emacs24-common-non-dfsg (24.3+1-1) ...
以前に未選択のパッケージ emacs24-common を選択しています。
Preparing to unpack .../emacs24-common_24.3+1-2ubuntu1_all.deb ...
Unpacking emacs24-common (24.3+1-2ubuntu1) ...
以前に未選択のパッケージ emacs24-bin-common を選択しています。
Preparing to unpack .../emacs24-bin-common_24.3+1-2ubuntu1_amd64.deb ...
Unpacking emacs24-bin-common (24.3+1-2ubuntu1) ...
以前に未選択のパッケージ emacs24-nox を選択しています。
Preparing to unpack .../emacs24-nox_24.3+1-2ubuntu1_amd64.deb ...
Unpacking emacs24-nox (24.3+1-2ubuntu1) ...
Processing triggers for install-info (5.2.0.dfsg.1-2) ...
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for mime-support (3.54ubuntu1) ...
libasound2-data (1.0.27.2-3ubuntu7) を設定しています ...
libasound2:amd64 (1.0.27.2-3ubuntu7) を設定しています ...
emacsen-common (2.0.7) を設定しています ...
emacs24-common-non-dfsg (24.3+1-1) を設定しています ...
emacs24-common (24.3+1-2ubuntu1) を設定しています ...
emacs24-bin-common (24.3+1-2ubuntu1) を設定しています ...
update-alternatives: /usr/bin/ctags (ctags) を提供するために 自動モード で /usr/bin/ctags.emacs24 を使います
update-alternatives: /usr/bin/ebrowse (ebrowse) を提供するために 自動モード で /usr/bin/ebrowse.emacs24 を使います
update-alternatives: /usr/bin/emacsclient (emacsclient) を提供するために 自動モード で /usr/bin/emacsclient.emacs24 を使います
update-alternatives: /usr/bin/etags (etags) を提供するために 自動モード で /usr/bin/etags.emacs24 を使います
update-alternatives: /usr/bin/grep-changelog (grep-changelog) を提供するために 自動モード で /usr/bin/grep-changelog.emacs24 を使います
emacs24-nox (24.3+1-2ubuntu1) を設定しています ...
update-alternatives: /usr/bin/emacs (emacs) を提供するために 自動モード で /usr/bin/emacs24-nox を使います
Install emacsen-common for emacs24
emacsen-common: Handling install of emacsen flavor emacs24
Wrote /etc/emacs24/site-start.d/00debian-vars.elc
Wrote /usr/share/emacs24/site-lisp/debian-startup.elc
Processing triggers for libc-bin (2.19-0ubuntu6) ...
ubuntu@ubuntu-14:~/c++/2.2$ 

init.el

;; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*-
(require 'cl)

;;;---------------------------------------------------------------------
;;; 標準機能の設定
;;;---------------------------------------------------------------------
;; スタートアップメッセージ非表示
(setq inhibit-startup-screen t)

;; tool-bar
;; (tool-bar-mode 0)

;; menu-bar
(menu-bar-mode 0)

;; TABの表示幅(初期値8から4に変更)
(setq default-tab-width 4)
(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72
                       76 80 84 88 92 96 100 104 108 112 116 120 124 128 132 136 140 144
                       148 152 156 160 164 168 172 176 180 184 188 192 196 200 204 208 212 216))

;; TABでなくスペースを使う
(setq-default indent-tabs-mode nil)

;; 改行コード表示
(setq eol-mnemonic-dos "(CRLF)")
(setq eol-mnemonic-mac "(CR)")
(setq eol-mnemonic-unix "(LF)")

;; メニューバーにファイルのフルパスを表示
;; (setq frame-title-format (format "%%f"))

;; ファイルの拡張子とモードの関連付け
(add-to-list 'auto-mode-alist '("\\.ddl$" . sql-mode))

;; 履歴を次回Emacs起動時にも保存する
(savehist-mode 1)

;; 対応する括弧を表示させる
(show-paren-mode 1)

;; 行が長くても自動的に折り返ししない
(auto-fill-mode 0)

;; シェルに合わせるためにC-hを後退に割り当てる
;; ※ヘルプは<f1>も使える
(global-set-key (kbd "C-h") 'delete-backward-char)

;; カレントバッファを閉じる。初期値は kill-sentence
(define-key global-map (kbd "M-k") 'kill-this-buffer)

;; 言語設定
(set-coding-system-priority 'utf-8 'euc-jp 'iso-2022-jp 'cp932)

;; 現在行に色をつける
(global-hl-line-mode 1)

;; リージョンに色をつける
(transient-mark-mode 1)

;; 行番号、桁番号を表示する
(line-number-mode 1)
(column-number-mode 1)

;; カーソル位置のファイルパスやアドレスを "C-x C-f" で開く
(ffap-bindings)

;; *.~ とかのバックアップファイルを一箇所にまとめる
;; (setq make-backup-files nil)
(setq make-backup-files t)
(setq backup-directory-alist
     (cons (cons "\\.*$" (expand-file-name "~/.emacs.d/backup"))
           backup-directory-alist
           )
     )
;; バックアップをバージョン管理する
(setq version-control t)
;; 新しいものをいくつ残すか
(setq kept-new-versions 10)
;; 古いものをいくつ残すか
(setq kept-old-versions 10)

;; .#* とかのバックアップファイルを作らない
(setq auto-save-default nil)

;; Emacsからの質問を y/n で回答
(fset 'yes-or-no-p 'y-or-n-p)

;; "C-m" に newline-and-indent を割り当てる(初期値は newline)
(define-key global-map (kbd "C-m") 'newline-and-indent)

;; GCを減らして軽くする
;; 現在のマシンパワーではもっと大きくしてもよい
;; デフォルトの1000倍とする
(setq gc-cons-threshold (* 1000 gc-cons-threshold))

;; ログの記録行数を増やす
(setq message-log-max 10000)

;; 履歴をたくさん保存する
(setq history-length 10000)

;; キーストロークをエコーエリアに早く表示する
(setq echo-keystrokes 0.1)

;; 大きいファイルを開こうとしたときに警告を発生させる
;; デフォルトは10MBなので50MBに拡張する
(setq large-file-warning-threshold (* 50 1024 1024))

;; emacs24で右から左に書く言語のための設定のようだが,デフォルトでは無効にしたほう が動作が軽快らしい
;; http://www.kaichan.mydns.jp/~kai/orgweb/init.html
(setq-default bidi-display-reordering nil
              bidi-paragraph-direction (quote left-to-right))


;;;---------------------------------------------------------------------
;;; 標準pluginの設定
;;;---------------------------------------------------------------------
;; 行番号表示
(require 'linum)
(global-linum-mode 1)

;; cua-mode: 矩形編集を強力にする
;; リージョン選択中に C-RET で矩形編集に入る、C-g で終了
(require 'cua-mode nil t)
(cua-mode t)
(setq cua-enable-cua-keys nil)

;; org-modeでHTML出力した時のHTML末尾に出力される"Validate XHTML 1.0"を抑制する
(setq org-export-html-validation-link nil)

;; インライン画像の表示
(setq org-startup-with-inline-images t)

;; 特殊文字の色付け
;; http://masutaka.net/chalow/2011-10-12-1.html
(global-whitespace-mode 1)
(setq whitespace-style '(face tabs tab-mark spaces space-mark newline newline-mark))
(setq whitespace-space-regexp "\\(\u3000+\\)")
(setq whitespace-display-mappings
         '((space-mark   ?\u3000 [?\u25a1])                ; 全角スペースを□で表わす
           (tab-mark     ?\t     [?\u00BB ?\t] [?\\ ?\t])  ; tab - left quote mark
           (newline-mark ?\n     [?\u21B5 ?\n] [?$ ?\n])   ; eol - overscore
           ))
(set-face-foreground 'whitespace-tab "#7594FF")
(set-face-background 'whitespace-tab 'nil)
(set-face-foreground 'whitespace-space "#7594FF")
(set-face-background 'whitespace-space 'nil)
(set-face-foreground 'whitespace-newline "#7594FF")
(set-face-background 'whitespace-newline 'nil)


;;;---------------------------------------------------------------------
;;; 追加pluginの設定
;;;---------------------------------------------------------------------
(add-to-list 'load-path "~/.emacs.d/elisp/")

;; auto-install
(require 'auto-install)
(setq auto-install-directory "~/.emacs.d/elisp")
(auto-install-update-emacswiki-package-name t)
(auto-install-compatibility-setup)

;; anything
(require 'anything-startup)
(global-set-key (kbd "C-:") 'anything-for-files)
;; 変数のチューニング
;; 打鍵から更新されるまでの遅延時間
(setq anything-input-idle-delay 0.1)
;; 候補を表示するまでの時間
(setq anything-idle-delay 0.1)
;; 表示されている情報源以外をdelayed扱いにする
(setq anything-quick-update nil)

;; recentfの拡張
;; ディレクトリもrecentfの対象にする
;; (install-elisp-from-emacswiki "recentf-ext.el")
;; 最近のファイル500個を保存する
(setq recentf-max-saved-items 500)
(require 'recentf-ext)

;; lixpxmp
;; (install-elisp "http://www.emacswiki.org/emacs/download/lispxmp.el")
(require 'lispxmp)

;; LaTeXの文書クラスについては以下を参照
;; http://keizai.xrea.jp/latex/tutorial/class.html
;; init.elの設定については以下を参照
;; http://d.hatena.ne.jp/tamura70/20100217/org
;; http://skalldan.wordpress.com/2011/06/10/%E5%9F%B7%E7%AD%86%E7%92%B0%E5%A2%83/
(setq org-export-latex-coding-system 'shift_jis)
(setq org-export-latex-date-format "%Y-%m-%d")
(setq org-export-latex-classes nil)
(add-to-list 'org-export-latex-classes
  '("jsarticle"
    "\\documentclass[a4j]{jsarticle}"
    ("\\section{%s}" . "\\section*{%s}")
    ("\\subsection{%s}" . "\\subsection*{%s}")
    ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
    ("\\paragraph{%s}" . "\\paragraph*{%s}")
    ("\\subparagraph{%s}" . "\\subparagraph*{%s}")
))
(setq org-export-latex-packages-alist
  '(("AUTO" "inputenc"  t)
    ("T1"   "fontenc"   t)
;;     ("deluxe,expert,multi"     "otf"   nil)
;;     ;; (""     "txfonts"   nil)
;; ;;     ;; ...                                     ; 使用するパッケージを適宜追加
    ))


;;; --------------------------------------------------------------------
;;;  カスタム設定
;;; --------------------------------------------------------------------
;; http://d.hatena.ne.jp/rubikitch/20100210/emacs
;; C-x o は激しく押しにくい
;; other-windowは分割していないときには何も動作しない。せっかく1ストロークにわりあてたのに、
;; これでは勿体ない
;; 分割してない状態のときにも働いてもらおう。分割してないときは、分割するようにする
;; 押しやすいキーには、状況に応じて空気を読んでくれるコマンドを割り当てるのが
;; 使い勝手を向上させるポイント
;; 初期値は transpose-chars だが使わないので
(defun other-window-or-split ()
 (interactive)
 (when (one-window-p)
   (split-window-horizontally))
 (other-window 1))
(global-set-key (kbd "C-t") 'other-window-or-split)

;; tmpファイルを作成する
(defun tmpfile ()
 (interactive)
 (let* ((file (expand-file-name
               (format-time-string
                ;;"%Y/%m/%Y-%m-%d-%H%M%S." (current-time))
                "%Y%m%d.%H%M%S.txt" (current-time))
               "~/"))
        (dir (file-name-directory file)))
   (make-directory dir t)
   (find-file-other-window (read-string "tmpfile: " file))))

;; 折り返し表示ON/OFF
(defun toggle-truncate-lines ()
 "折り返し表示をトグル動作します."
 (interactive)
 (if truncate-lines
     (setq truncate-lines nil)
   (setq truncate-lines t))
 (recenter))
(global-set-key "\C-c\C-l" 'toggle-truncate-lines)  ; 折り返し表示ON/OFF