自己紹介、その他

mayotako

片倉駅付近在住。一人暮し。
学校まで徒歩30分です。

Emacsメモ

個人的なEmacsの設定、elispなどを書こうと思います。
紹介というよりはバックアップ的な意味で書いてます。
ネットの色々な所からコピペしたものが多くあります.
見た目は適当です。綺麗に見えるようにしようとか微塵も考えてません。
ショートカットなどのEmacsの基本コマンドなどについてはEmacsに聞いてください.
XWinsowSystem上での操作を想定しています。

最初に

・Windowsの場合

まずXkeymacsを入れましょう。すばらしいソフトです。
これは強くは進めませんがMeadowをいれると良いと思います。
Emacsとほぼ同じですがWindowsでは(私は)常用起動をしないため起動時間が気になります。

・Linuxなどの場合

Emacsを入れましょう。そして生涯の伴侶としてください。
Emacs23マジオススメ。emacsclient -t で夢広がりすぎ。

しておくといい設定(gnome)

現在(2010/5/14)の私のディストリビューションはFedora12です(もうすぐ13!)。

[システム->設定->キーボードショートカット]で
[ウインドウメニューをアクティブ]にするというのがあると思います。
おそらく[Alt+Space]になっているのでそれを無効、もしくは変えます。

これで[M-Space]の連続したスペースをスペースひとつ残して削除のコマンドが
メニューに邪魔されることなく打てるようになります。(今はもう標準で無効なのかな)

[アプリケーション->システムツール->設定エディタ]から
[desktop->gnome->interface]の[gtk-_key_theme]の値を[Emacs]に変更。
どうもgnomeでの操作がEmacs風になるそうですが…うーん。

設定エディタが入っていない場合は。
yum install gconf-editor とかで入るんじゃないでしょうか。
(GUIな説明ですいません・・・

※現在はxmodmapでキーバインドを変更しWMはxmonad使用中・・・でした(あれ?

キー設定など

キー配列にもよりますがJISキーボードの場合
CapsLockとControlぐらいは入れ替えましょう。
この設定はEmacsの限りではないと思います。

Windowsの場合は
http://wiki.ohgaki.net/index.php?Windows%2FCTRL%E3%81%A8CapsLock%E3%82%AD%E3%83%BC%E3%82%92%E5%85%A5%E3%82%8C%E6%9B%BF%E3%81%88%E3%82%8B
こちらのページなんかを参考にさせていただくとよいと思います.。

・個人的なキーバインド

Shift_LにAltキーを割り当ててあります。
無変換キーにShiftを割り当ててあります。
変換キーはEmacsのsticky-keyで使います。キーボードやマシンが変わると死にます。

xmodmapに渡している設定


clear mod3
clear shift

remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L

keycode 50 = Alt_L
keycode 102 = Shift_L

add shift = Shift_L
add Lock = Caps_Lock
add Control = Control_L


上記の設定を毎回有効にしたい場合は[xinitrc]をコピーしてきて~/に置いて
そこに [xmodmap $HOME/.xmodhogehoge]とか追加すれば設定されると思います。
[.xmodhogehoge]は名前はなんでもよくて上記などの設定が書いてあればOKです。
書き方はぐぐるなりmanで見るなりしてください。
[xinitrc]はその名前でlocateでもすれば見つかるのではないでしょうか。

.emacs.el

ネットをあさるなりして見つけた様々なelispを書いておきます。
使いかたの多くは明記してませんがEmacsに聞いてください。
pathなんかも必要に応じて通す必要があるかもです.書かれている機能の多くはデフォルトでは存在しないため必要に応じて拾ってきてください。
製作者の方には感謝の気持ちとともに無断転載していることをお詫びします。

それとなく見直してますが見落としがあるかもしれません
ちなみに私が使っていない機能は削除しました.$br;

※うーん,これ一度コメントを書き直したほうがいいかもなぁ
何も知らなかった頃のコメントが目に痛い….


;;#load-path

 (add-to-list 'load-path "~/emacs-lisp")
 (add-to-list 'load-path "~/emacs-lisp/color-theme")
 (add-to-list 'load-path "~/emacs-lisp/lisp")
 (add-to-list 'load-path "~/emacs-lisp/yatex")
 (add-to-list 'load-path "~/emacs-lisp/navi2ch")
 (add-to-list 'load-path "~/emacs-lisp/goby-0.94")
 (add-to-list 'load-path "~/emacs-lisp/mode-info")
 (add-to-list 'load-path "~/emacs-lisp/gtags")
 (add-to-list 'load-path "~/emacs-lisp/muse")
 (add-to-list 'load-path "~/emacs-lisp/ac-mode")
 

;;#警告の停止

 (put 'upcase-region 'disabled nil)
 (put 'downcase-region 'disabled nil)
 (put 'scroll-left 'disabled nil)
 (put 'narrow-to-region 'disabled nil)
 

;;#common-lisp emu

 (require 'cl)
 

;;#ツールバー、タスクバーの非表示

 (tool-bar-mode 0)
 (menu-bar-mode 0)
 

;;#時計表示

 (setq display-time-day-and-date t)
 (display-time)
 

;;#バッファの切り替えC-x 方向キーを C-方向キーに

 (global-set-key [C-right] 'next-buffer)
 (global-set-key [C-left] 'previous-buffer)
 

;;#正規表現での検索

 (global-set-key "\M-s" 'isearch-forward-regexp)
 (global-set-key "\M-r" 'isearch-backward-regexp)
 

;;#特殊キー使用

 (set-input-mode nil nil t)
 

;;#C-hをバックスペースに

 (global-set-key "\C-h" 'backward-delete-char-untabify)
 

;;#改行時自動インデント

 (global-set-key "\C-m" 'newline-and-indent)
 (global-set-key "\C-j" 'newline)
 

;;#今あるカーソルの下に改行を行入れる

 (defun space-line-blank()
 (interactive)
 (move-end-of-line nil)
 (newline))
 (define-key mode-specific-map "j" 'space-line-blank)
 

;;#連続した空白の削除(c-mode)

 (defun my-c-common-mode ()
 (c-toggle-hungry-state 1))
 (add-hook 'c-mode-common-hook 'my-c-common-mode)
 

;;#goto-line

 (global-set-key "\M-g" 'goto-line)
 

;;#Shift+方向キーでウインドウ移動

 (windmove-default-keybindings)
 

;;#コンパイル:C-c c 間違えた構文へ飛ぶにはC-c n

 (define-key mode-specific-map "c" 'my-compile)
 (define-key mode-specific-map "n" 'next-error)
 (define-key mode-specific-map "r" 'compilation-close)
 (setq compilation-buffer-name "*compilation*")
 (setq compilation-scroll-output t)
 (setq command-history nil)
 (setq compile-history nil)
 (setq compilation-read-command t)
 (setq compilation-ask-about-save nil)
 (setq compilation-window-height 10)
 (setq compile-command "make")
 

;;#オートセーブ、バックアップの停止

 (setq make-backup-files nil)
 (setq auto-save-default nil)
 

;;#コピーなどemacs <--> gnome

 (setq x-select-enable-clipboard t)
 

;;#動的略語展開の設定

 (setq dabbrev-case-fold-search nil)
 

;;#シェルファイルなどを保存したとき自動でchmod +x

 (add-hook 'after-save-hook
 'executable-make-buffer-file-executable-if-script-p)
 

;;#起動時の画面*scratch*をtext-modeに

 (setq initial-major-mode 'text-mode)
 

;;#起動時の画面の文字を非表示に

 (setq initial-scratch-message "")
 ;;(setq initial-scratch-message (insert-file "~/Desktop/todo.txt"))
 

;;#最近使ったファイルを開く

 (require 'recentf-ext)
 (define-key mode-specific-map "l" 'recentf-open-files)
 

;;#最近使ったファイルの保存

 (recentf-mode)
 

;;#diredモード中にrで幸せになれる

 (require 'wdired)
 (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
 

;;#dired ディレクトリを先に表示する

 (setq ls-lisp-dirs-first t)
 

;;#指定した文字に一致する部分を色付けして強調表示

 (global-set-key [(super l)] 'highlight-regexp)
 (global-set-key [(super u)] 'unhighlight-regexp)
 

;;#diredでフォルダを開く時, 新しいバッファを作成しない

 ;; バッファを作成したい時にはoやC-u ^を利用する
 (defvar my-dired-before-buffer nil)
 (defadvice dired-advertised-find-file
 (before kill-dired-buffer activate)
 (setq my-dired-before-buffer (current-buffer)))
 (defadvice dired-advertised-find-file
 (after kill-dired-buffer-after activate)
 (if (eq major-mode 'dired-mode)
 (kill-buffer my-dired-before-buffer)))
 (defadvice dired-up-directory
 (before kill-up-dired-buffer activate)
 (setq my-dired-before-buffer (current-buffer)))
 (defadvice dired-up-directory
 (after kill-up-dired-buffer-after activate)
 (if (eq major-mode 'dired-mode)
 (kill-buffer my-dired-before-buffer)))
 

;;#dired を使って、一気にファイルの coding system (漢字) を変換する

 (require 'dired-aux)
 (add-hook 'dired-mode-hook
 (lambda ()
 (define-key (current-local-map) "T"
 'dired-do-convert-coding-system)))
 
 (defvar dired-default-file-coding-system nil
 "*Default coding system for converting file (s).")
 (defvar dired-file-coding-system 'no-conversion)
 (defun dired-convert-coding-system ()
 (let ((file (dired-get-filename))
 (coding-system-for-write dired-file-coding-system)
 failure)
 (condition-case err
 (with-temp-buffer
 (insert-file file)
 (write-region (point-min) (point-max) file))
 (error (setq failure err)))
 (if (not failure)
 nil
 (dired-log "convert coding system error for %s:\n%s\n" file failure)
 (dired-make-relative file))))
 (defun dired-do-convert-coding-system (coding-system &optional arg)
 "Convert file (s) in specified coding system."
 (interactive
 (list (let ((default (or dired-default-file-coding-system
 buffer-file-coding-system)))
 (read-coding-system
 (format "Coding system for converting file (s) (default, %s): "
 default)
 default))
 current-prefix-arg))
 (check-coding-system coding-system)
 (setq dired-file-coding-system coding-system)
 (dired-map-over-marks-check
 (function dired-convert-coding-system) arg 'convert-coding-system t))
 

;;#コンパイルウインドウのサイズ

 (setq compilation-window-height 12)
 

;;#ウインドウ名の変更

 (setq frame-title-format "%b")
 

;;#対応するカッコをハイライト表示(mic-parenに変更)

 ;;(show-paren-mode)
 

;;#emacsclientサーバー起動

 (server-start)
 

;;#echo領域の表示待ち時間

 (setq echo-keystrokes 0.1)
 

;;#スタートアップメッセージの非表示

 (setq inhibit-startup-message t)
 

;;#リージョンのカラー設定

 (setq transient-mark-mode nil)
 

;;#ミニバッファの可変

 (setq resize-minibuffer-mode t)
 

;;#インデントをタブに

 (setq indent-tabs-mode t)
 

;;#タブ幅

 (setq default-tab-width 2)
 (setq tab-width 2)
 

;;#インデント幅

 (setq c-basick-offset 2)
 

;;#ls --color

 (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
 

;;#右側で折り返さない

 (setq truncate-lines t)
 

;;#分割したウインドウでも折り返さない

 (setq truncate-partial-width-windows t)
 

;;#アクティブでないウインドウのカーソル非表示

 (setq cursor-in-non-selected-windows)
 

;;#yes no を y nに

 (fset 'yes-or-no-p 'y-or-n-p)
 

;;#GDBの設定

 (setq gdb-many-windows t)
 (setq gdb-use-separate-io-buffer t)
 (setq gdb-find-source-frame nil)
 

;;#文字設定

 (set-language-environment "Japanese")
 (set-default-coding-systems 'utf-8)
 (set-buffer-file-coding-system 'utf-8-unix)
 (set-terminal-coding-system 'utf-8)
 (set-keyboard-coding-system 'utf-8)
 

;;#linum-mode(ちなみにこのキーはThinkpadボタン)

 (global-set-key (kbd "<XF86Launch1>") 'linum-mode)
 

;;#scala-mode

 (require 'scala-mode-auto)
 (setq scala-interpreter "/home/mayotako/scala/bin/scala")
 
 

;;#シェルモードの設定

 (add-hook 'shell-mode-hook
 (lambda ()
 (set-buffer-process-coding-system 'utf-8 'utf-8)))
 (setq network-coding-system-alist
 '(("nntp" . (junet-unix . junet-unix))
 (110 . (no-conversion . no-conversion))
 (25 . (no-conversion . no-conversion))))
 

;;#KONAMI(コナミコマンド)

 (defun start-button ()
 (interactive)
 (progn
 (setq old-up-binding (key-binding [up]))
 (global-set-key (kbd "<up>") nil)
 (global-set-key (kbd "<up> <up> <down> <down> <left> <right> <left> <right> b a")
 (lambda () (interactive)
 (global-set-key (kbd "<up>") old-up-binding)
 (shell-command "echo \"KONAMI!!\"")))))
 

;;#行番号の表示

 (line-number-mode t)
 (column-number-mode t)
 

;;#圧縮されたファイルの編集

 (auto-compression-mode t)
 

;;#occurの結果にkeeplineなどをする

 (define-key occur-mode-map "F"
 (lambda (str) (interactive "sflush: ")
 (let ((buffer-read-only))
 (save-excursion
 (beginning-of-buffer)
 (forward-line 1)
 (beginning-of-line)
 (flush-lines str)))))
 (define-key occur-mode-map "K"
 (lambda (str) (interactive "skeep: ")
 (let ((buffer-read-only))
 (save-excursion
 (beginning-of-buffer)
 (forward-line 1)
 (beginning-of-line)
 (keep-lines str)))))
 

;;#occurを使いやすくしたもの

 (require 'color-moccur)

;;#moccurの結果を直接編集する(r)

 (load "moccur-edit")
 (global-set-key "\M-p" 'moccur)
 (global-set-key (kbd "C-M-p") 'dmoccur)
 
 ;;color-moccurの設定
 ;;第三引数がnon-nilだとloadできなかった場合にエラーではなくnilを返す
 (when (require 'migemo nil t)
 (setq moccur-use-migemo t))
 

;;#sticky-shift

 (defvar sticky-key [henkan])
 (defvar sticky-list
 '(("a" . "A")("b" . "B")("c" . "C")("d" . "D")("e" . "E")("f" . "F")("g" . "G")
 ("h" . "H")("i" . "I")("j" . "J")("k" . "K")("l" . "L")("m" . "M")("n" . "N")
 ("o" . "O")("p" . "P")("q" . "Q")("r" . "R")("s" . "S")("t" . "T")("u" . "U")
 ("v" . "V")("w" . "W")("x" . "X")("y" . "Y")("z" . "Z")
 ("1" . "!")("2" . "\"")("3" . "#")("4" . "$")("5" . "%")("6" . "^")("7" . "&")
 ("8" . "*")("9" . "(")("0" . ")")
 ("`" . "~")("[" . "{")("]" . "}")("-" . "_")("=" . "+")("," . "<")("." . ">")
 ("/" . "?")(";" . ":")("'" . "\"")("\\" . "|")
 ))
 (defvar sticky-map (make-sparse-keymap))
 (define-key global-map sticky-key sticky-map)
 (mapcar (lambda (pair)
 (define-key sticky-map (car pair)
 `(lambda()(interactive)
 (setq unread-command-events
 (cons ,(string-to-char (cdr pair)) unread-command-events)))))
 sticky-list)
 (define-key sticky-map sticky-key '(lambda ()(interactive)(insert sticky-key)))
 
 (define-key isearch-mode-map sticky-key sticky-map)
 

;;#tramp

 (require 'tramp)
 (setq tramp-default-method "ssh")
 (assoc "sudo" tramp-methods)
 

;;#killbufferの復元

 (defvar killed-file-name nil)
 (add-hook 'kill-buffer-hook
 (lambda ()
 (when (buffer-file-name)
 (setq killed-file-name (expand-file-name (buffer-file-name))))))
 (defun find-killed-file ()
 (interactive)
 (when killed-file-name
 (find-file killed-file-name)
 (setq killed-file-name nil)))
 (define-key mode-specific-map "/" 'find-killed-file)
 

;;#タイムスタンプ

 (defun insert-time-function ()
 (interactive)
 (insert (format-time-string "[%Y/%m/%d %H:%M:%S]"))
 )
 (global-set-key [f9] 'insert-time-function)
 

;;#bm Alt+Ctrl+Speでしおり C-;次へ C-: 戻る

 (require 'bm)
 (global-set-key [?\C-\;] 'bm-previous)
 (global-set-key [?\C-\:] 'bm-next)
 (global-set-key [C-M-return] 'bm-toggle)
 

;;#Emacsの背景色などの変更

 (require 'color-theme)
 (color-theme-initialize)
 (color-theme-euphoria)
 ;;(color-theme-lethe)
 

;;#howmモード(メモ雑多落書き

 ;;C-c,, で起動
 (setq howm-menu-lang 'ja)
 (require 'howm)
 

;;#s を何回か入力すると,拡張子やサイズによる並び換えもできる

 (load "sorter")
 ;;; ディレクトリを先に表示する
 (setq ls-lisp-dirs-first t)
 

;;#補完時のウインドウを自動消去

 (require 'lcomp)
 (lcomp-install)  
 

;;#M-x b の操作性の向上

 (require 'iswitchb)
 (iswitchb-default-keybindings)
 (defadvice iswitchb-exhibit
 (after
 iswitchb-exhibit-with-display-buffer
 activate)
 "選択している buffer を window に表示してみる。"
 (when (and
 (eq iswitchb-method iswitchb-default-method)
 iswitchb-matches)
 (select-window
 (get-buffer-window (cadr (buffer-list))))
 (let ((iswitchb-method 'samewindow))
 (iswitchb-visit-buffer
 (get-buffer (car iswitchb-matches))))
 (select-window (minibuffer-window))))
 

;;#dmacro

 ;;(defconst *dmacro-key* [?\s-t] "繰返し指定キー")
 (defconst *dmacro-key* "\C-t" "繰返し指定キー")
 (global-set-key *dmacro-key* 'dmacro-exec)
 (autoload 'dmacro-exec "dmacro" nil t)
 

;;#w3m

 (require 'w3m-load)
 (setq w3m-home-page "http://www.google.co.jp")
 (setq w3m-key-binding 'info)
 (setq w3m-default-display-inline-images t)
 (autoload 'w3m "w3m" "Interface for w3m on Emacs." t)
 (autoload 'w3m-find-file "w3m" "w3m interface function for local file." t)
 (autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
 (autoload 'w3m-search "w3m-search" "Search QUERY using SEARCH-ENGINE." t)
 (autoload 'w3m-weather "w3m-weather" "Display weather report." t)
 (autoload 'w3m-antenna "w3m-antenna" "Report chenge of WEB sites." t)
 
 (add-hook 'w3m-mode-hook
 '(lambda ()
 (set-face-foreground 'w3m-anchor-face "DodgerBlue")
 (set-face-foreground 'w3m-arrived-anchor-face "SteelBlue")
 ;; (set-face-foreground 'w3m-bitmap-image-face "")
 ;; (set-face-foreground 'w3m-bold-face "")
 ;; (set-face-foreground 'w3m-current-anchor-face "")
 ;; (set-face-foreground 'w3m-form-face "")
 ;; (set-face-foreground 'w3m-header-line-location-content-face "")
 ;; (set-face-foreground 'w3m-header-line-location-title-face "")
 ;; (set-face-foreground 'w3m-history-current-url-face "")
 ;; (set-face-foreground 'w3m-image-face "")
 ;; (set-face-foreground 'w3m-underline-face "")
 ))
 ;;(global-set-key "\C-cmw" 'w3m)
 (autoload 'wget "wget" "wget interface for Emacs." t)
 (autoload 'wget-web-page "wget" "wget interface to download whole web page." t)
 (load "w3m-wget")
 (global-set-key [M-up] 'w3m-previous-buffer)
 (global-set-key [M-down] 'w3m-next-buffer)
 (setq w3m-weather-default-area "東京都・東京")
 

;;#compileコマンドによるウインドウ分割の制御

 (defun compilation-open ()
 "*compilation*バッファを表示するwindowをオープンする"
 (interactive)
 (let ((cur-window (selected-window))
 (com-buffer (get-buffer compilation-buffer-name)))
 (if (null com-buffer)
 (setq com-buffer (get-buffer-create compilation-buffer-name)))
 (let ((com-window (get-buffer-window com-buffer)))
 (if com-window
 (select-window com-window)
 (select-window
 (split-window (selected-window) (- (window-height) 15) nil)))
 (switch-to-buffer (get-buffer compilation-buffer-name))
 (select-window cur-window))))
 (defun compilation-close ()
 "*compilation*バッファを表示しているwindowをクローズする"
 (interactive)
 (let ((com-buffer (get-buffer compilation-buffer-name)))
 (if com-buffer
 (let ((com-window (get-buffer-window com-buffer)))
 (if com-window
 (delete-window com-window))))))
 (defun my-compile (command &optional comint)
 "*compilation*バッファの表示位置を固定化してcompileコマンドを実行する関数。"
 (interactive
 (list
 (let ((command (eval compile-command)))
 (if (or compilation-read-command current-prefix-arg)
 (read-from-minibuffer "Compile command: "
 command nil nil
 (if (equal (car compile-history) command)
 '(compile-history . 1)
 'compile-history))
 command))
 (consp current-prefix-arg)))
 (unless (equal command (eval compile-command))
 (setq compile-command command))
 (save-some-buffers (not compilation-ask-about-save) nil)
 (setq compilation-directory default-directory)
 (compilation-open)
 (compilation-start command comint))
 

;;#session

 (require 'session)
 (add-hook 'after-init-hook 'session-initialize)
 

;;#grep occurなどの検索結果を別ウインドウに表示させる

 (require 'fm)
 (add-hook 'occur-mode-hook 'fm-start)
 (add-hook 'compilation-mode-hook 'fm-start)
 

;;#sdic-mode 用の設定

 ;;(autoload 'sdic-describe-word "sdic" "英単語の意味を調べる" t nil)
 (require 'sdic)
 (global-set-key "\C-cw" 'sdic-describe-word)
 ;;(autoload 'sdic-describe-word-at-point "sdic" "カーソルの位置の英単語の意味を調べる" t nil)
 (global-set-key "\C-cW" 'sdic-describe-word-at-point)
 

;;#SKK

 (setq load-path (cons "skk" load-path))
 (autoload 'skk-mode "skk" nil t)
 (setq skk-preload t)
 ;;(global-set-key "\C-xj" 'skk-auto-fill-mode)
 (setq skk-egg-like-newline t)
 (global-set-key [zenkaku-hankaku] 'skk-mode)
 (global-set-key [M-zenkaku-hankaku] 'skk-toggle-kutouten)
 (setq skk-large-jisyo nil)
 (setq skk-server-host "127.0.0.1")                                  
 (setq skk-server-portnum 1178)
 (setq skk-use-look t)
 (setq skk-kutouten-type 'en)
 ;; . や ,など文章の終りを入力した場合に変換の確定
 ;;(setq skk-kakutei-early nil)
 ;;変換候補で使われなくなった漢字の変換優先度の低下.(上のskk-kakutei-earlyとは相容れない
 (setq skk-henkan-strict-okuri-precedence t)
 
 (setq skk-dcomp-activate t)
 (setq skk-dcomp-multiple-activate t)
 ;;上記elispの停止
 ;;(setq skk-dcomp-activate nil)
 ;; 送り仮名の自動処理
 ;;(setq skk-auto-okuri-process nil)
 

;;#migemo 基本設定

 (setq migemo-command "cmigemo")
 (setq migemo-options '("-q" "--emacs" "-i" "\a"))
 ;; migemo-dict のパスを指定
 (setq migemo-dictionary "/usr/local/share/migemo/utf-8/migemo-dict")
 (setq migemo-user-dictionary nil)
 (setq migemo-regex-dictionary nil)
 ;; キャッシュ機能を利用する
 (setq migemo-use-pattern-alist t)
 (setq migemo-use-frequent-pattern-alist t)
 (setq migemo-pattern-alist-length 1024)
 ;; 辞書の文字コードを指定.
 ;; バイナリを利用するなら,このままで構いません
 (setq migemo-coding-system 'utf-8)
 (load-library "migemo")
 ;; 起動時に初期化も行う
 (migemo-init)
 

;;#skk <--> migemo

 (remove-hook 'isearch-mode-hook
 (lambda ()
 (if (and (boundp 'skk-mode)
 skk-mode
 skk-isearch-mode-enable)
 (skk-isearch-mode-setup))))
 (add-hook 'isearch-mode-hook
 (lambda ()
 (if (and (boundp 'skk-mode)
 skk-mode)
 (progn
 (setq migemo-isearch-enable-p nil)
 (skk-isearch-mode-setup))
 (setq migemo-isearch-enable-p t))))
 

;;#gtags

 ;;gtags -v GTAGSファイル作成
 ;; Ctrl+t gtagsでジャンプする一つ前の状態に戻る
 ;; Alt +s 指定した変数、定義の定義元を探す
 ;; Alt +r 指定した関数が参照されている部分を探す
 ;; Alt +t 指定した関数が定義されている部分をさがす
 (autoload 'gtags-mode "gtags" "" t)
 (setq gtags-mode-hook
 '(lambda ()
 (local-set-key "\M-t" 'gtags-find-tag)
 (local-set-key "\M-r" 'gtags-find-rtag)
 (local-set-key "\M-s" 'gtags-find-symbol)
 (local-set-key "\C-t" 'gtags-pop-stack)
 ))

;;#c,c++,javaなどでgtagsを有効にする

 (add-hook 'c-mode-common-hook
 '(lambda() (progn
 (gtags-mode t)
 (c-toggle-hungry-state t)
 (local-set-key "\C-c\C-r" 'uncomment-region)
 )
 ;;(gtags-make-complete-list)
 ))
 

;;#anything

 (setq woman-cache-filename (expand-file-name "~/.emacs.d/woman_cache"))
 (require 'anything-config)
 (require 'anything-gtags)
 (require 'anything-migemo)
 (require 'anything-dabbrev-expand)
 (require 'anything-c-shell-history)
 (require 'ac-anything)
 

;;#anythingの履歴保存の停止(session.elで代用)

 (remove-hook 'kill-emacs-hook 'anything-c-adaptive-save-history)
 (ad-disable-advice 'anything-exit-minibuffer 'before 'anything-c-adaptive-exit-minibuffer)
 (ad-disable-advice 'anything-select-action 'before 'anything-c-adaptive-select-action)
 (setq anything-c-adaptive-history-length 0)
 

;;#anythingでsdicを動かしてみた.anything-sourcesの末尾に記述推奨

 ;;actionは未実装.動けばOKな感じで.(やべ,すごく使えないぞこれ)
 (defvar anything-c-source-sdic
 '((name . "sdic")
 (init . (lambda ()
 (setq anything-c-source-sdic-buffer (current-buffer))))
 (candidates . (lambda ()
 (let ((result
 (flet ((message (n) n)) ;;sdicのメッセージを非表示
 (sdic-describe-word anything-pattern))))
 (prog1
 (when result
 (with-current-buffer "*sdic*"
 (split-string (buffer-string) "\n" t)))
 (set-buffer anything-buffer)))));;こんな実装で本当にいいのか
 
 (cleanup . (lambda () nil))
 (requires-pattern . 3)
 (volatile)))
 

;;#anything-c-moccurの設定

 (require 'anything-c-moccur)
 (setq moccur-split-word t)
 ;; カスタマイズ可能変数の設定(M-x customize-group anything-c-moccur でも設定可能)
 (setq anything-c-moccur-anything-idle-delay 0.1 ;`anything-idle-delay'
 anything-c-moccur-higligt-info-line-flag t ; `anything-c-moccur-dmoccur'などのコマンドでバッファの情報をハイライトする
 anything-c-moccur-enable-auto-look-flag t ; 現在選択中の候補の位置を他のwindowに表示する
 anything-c-moccur-enable-initial-pattern nil) ; `anything-c-moccur-occur-by-moccur'の起動時にポイントの位置の単語を初期パターンにする
 
 (setq anything-sources
 (list
 anything-c-source-buffers
 anything-c-source-elscreen			 
 anything-c-source-file-name-history
 anything-c-source-imenu
 anything-c-source-gtags-select
 ;;anything-c-source-occur
 ;;anything-c-source-files-in-current-dir
 ;;anything-c-source-shell-history
 ;;anything-c-source-kill-ring
 anything-c-source-locate
 ;;anything-c-source-calculation-result
 ;;anything-c-source-arrived-url-history
 ;;anything-c-source-man-pages
 anything-c-source-emacs-commands
 ;;anything-c-source-sdic
 ))
 

;;#anythingのキーバインド

 (global-set-key [menu] 'anything)
 

;;#anythingでの動的略語補完

 (global-set-key [M-menu] 'anything-dabbrev-expand)
 (define-key anything-dabbrev-map [M-menu] 'anything-dabbrev-find-all-buffers)
 
 ;;anything-c-moccurの設定
 (global-set-key (kbd "M-o") 'anything-c-moccur-occur-by-moccur) ;バッファ内検索
 (global-set-key (kbd "C-o") 'anything-c-moccur-buffer-list) ;全バッファ内検索
 (global-set-key (kbd "C-M-o") 'anything-c-moccur-dmoccur) ;ディレクトリ
 (add-hook 'dired-mode-hook ;dired
 '(lambda ()
 (local-set-key (kbd "O") 'anything-c-moccur-dired-do-moccur-by-moccur)))

;;#anythingでのauto-completeの補完

 (define-key ac-complete-mode-map "\M-;" 'ac-complete-with-anything)
 

;;#anythingのキーバインド

 (define-key anything-map "\C-v" 'anything-next-page)
 (define-key anything-map "\M-v" 'anything-previous-page)
 

;;#multiverse

 ;;M-x multiverse-storeで名前をつけてスナップショットを保存する。
 ;;M-x multiverse-restoreで保存したスナップショットに戻る。undoも効くから取り消すこともできる。
 ;;M-x multiverse-forgetでスナップショットを削除する。これは選択後にやろう。
 ;;M-x multiverse-diff-currentとM-x multiverse-diff-otherはスナップショットとのdiffを取る。
 (require 'multiverse)
 (global-set-key [(super s)] 'multiverse-store)
 (global-set-key [(super r)] 'multiverse-restore)
 (global-set-key [(super d)] 'multiverse-forget)
 

;;#Window分割の位置入れ替え

 (defun swap-screen()
 "Swap two screen,leaving cursor at current window."
 (interactive)
 (let ((thiswin (selected-window))
 (nextbuf (window-buffer (next-window))))
 (set-window-buffer (next-window) (window-buffer))
 (set-window-buffer thiswin nextbuf)))
 (defun swap-screen-with-cursor()
 "Swap two screen,with cursor in same buffer."
 (interactive)
 (let ((thiswin (selected-window))
 (thisbuf (window-buffer)))
 (other-window 1)
 (set-window-buffer thiswin (window-buffer))
 (set-window-buffer (selected-window) thisbuf)))
 (define-key mode-specific-map "1" 'swap-screen)
 (define-key mode-specific-map "2" 'swap-screen-with-cursor)
 

;;#yatex

 (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
 ;; YaTeX-mode
 (setq auto-mode-alist
 (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
 (setq dvi2-command "pxdvi"
 tex-command "platex -src-specials"
 dviprint-command-format "dvips %s | lpr"
 YaTeX-kanji-code 4)
 

;;#YaHtml-mode

 (setq auto-mode-alist
 (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist))
 (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t)
 (setq yahtml-www-browser "firefox")
 

;;#android

 (require 'android)
 

;;#コマンド履歴で先頭文字を入力してから補完

 (load-library "tails-history")
 

;;#重複した履歴の非表示

 (defun minibuffer-delete-duplicate ()
 (let (list)
 (dolist (elt (symbol-value minibuffer-history-variable))
 (unless (member elt list)
 (push elt list)))
 (set minibuffer-history-variable (nreverse list))))
 (add-hook 'minibuffer-setup-hook 'minibuffer-delete-duplicate)
 

;;#twitter-mode

 (require 'twittering-mode)
 ;(setq twittering-proxy-use t)
 ;(setq twittering-proxy-server "ここにプロキシ")
 ;(setq twittering-proxy-port 80)
 
 ;;auto-complete
 (require 'auto-complete-config)
 (add-to-list 'ac-dictionary-directories "~/emacs-lisp/ac-mode/dict")
 (ac-config-default)
 (require 'auto-complete-extension)
 ;(require 'ac-dabbrev)
 (global-auto-complete-mode t)
 (setq ac-auto-show-menu t)
 (setq ac-auto-start 3)
 (add-to-list 'ac-modes 'scala-mode)
 (setq ac-menu-height 20)
 (define-key ac-completing-map [up] nil)
 (define-key ac-completing-map [down] nil)
 
 ;;補完候補の中での説明の表示の停止
 ;;(setq ac-use-quick-help nil)
 
 (add-hook 'emacs-lisp-mode-hook
 (lambda ()
 (setq ac-sources '(ac-source-words-in-buffer ac-source-symbols))))
 

;;#Gauche

 ;(setq scheme-program-name "gosh")
 ;(require 'cmuscheme)
 ;(defun scheme-other-window ()
 ;  "Run scheme on other window"
 ;  (interactive)
 ;  (switch-to-buffer-other-window
 ;   (get-buffer-create "*scheme*"))
 ;  (run-scheme scheme-program-name))
 ;(define-key global-map
 ;  "\C-cS" 'scheme-other-window)
 

;;#現在行の強調表示

 (require 'hl-line)
 
 ;;強調表示を下線に
 ;;(setq hl-line-face 'underline)
 
 (defface my-hl-line-face
 '((((class color)
 (background dark))    ;; 背景色が暗い色のとき
 ; (:background "#222244"))
 (:background "gray8"))
 (((class color)
 (background light))    ;; 背景色が明るい色のとき
 (:background "gray8"))
 (t
 ()))
 "*Face used by hl-line.")
 (setq hl-line-face 'my-hl-line-face)
 (global-hl-line-mode)
 

;;#mode-info

 (setq Info-directory-list
 (append
 Info-default-directory-list
 (list
 (expand-file-name "~/emacs-lisp/info/glibcinfo"))))
 (require 'mi-config)
 (define-key global-map "\C-cf" 'mode-info-describe-function)
 (define-key global-map "\C-cv" 'mode-info-describe-variable)
 (define-key global-map "\C-ch" 'mode-info-find-tag)
 

;;#flymake

 (require 'flymake)
 ;;perl
 (require 'set-perl5lib)
 ;;ミニバッファへ表示
 (defun flymake-display-err-minibuf ()
 "Displays the error/warning for the current line in the minibuffer"
 (interactive)
 (let* ((line-no             (flymake-current-line-no))
 (line-err-info-list  (nth 0 (flymake-find-err-info flymake-err-info line-no)))
 (count               (length line-err-info-list)))
 (while (> count 0)
 (when line-err-info-list
 (let* ((file       (flymake-ler-file (nth (1- count) line-err-info-list)))
 (full-file  (flymake-ler-full-file (nth (1- count) line-err-info-list)))
 (text (flymake-ler-text (nth (1- count) line-err-info-list)))
 (line       (flymake-ler-line (nth (1- count) line-err-info-list))))
 (message "[%s] %s" line text)))
 (setq count (1- count)))))
 

;;#flymake for perl

 (push '("\\.pl$" flymake-perl-init) flymake-allowed-file-name-masks)
 (push '("\\.pm$" flymake-perl-init) flymake-allowed-file-name-masks)
 (push '("\\.t$" flymake-perl-init) flymake-allowed-file-name-masks)
 (push '("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1) flymake-err-line-patterns)
 (add-hook 'perl-mode-hook
 '(lambda ()
 ;;(define-key cperl-mode-map "\C-cd" 'credmp/flymake-display-err-minibuf)
 (set-perl5lib)
 (flymake-mode)))
 
 

;;#対応するカッコに下線表示

 (require 'mic-paren)
 (paren-activate)
 (setq paren-match-face '(underline paren-face))
 (setq paren-sexp-mode t)
 (setq parse-sexp-ignore-comments t)
 (put 'set-goal-column 'disabled nil)
 
 
 (require 'mi-fontify)
 

;;#外部コマンドの呼びだしによる自身のウインドウのサイズの最大化(トグル可能)

 (global-set-key [(super \1)] '(lambda ()
 (interactive)
 (shell-command "wmctrl -r :ACTIVE: -b toggle,fullscreen")))
 
 ;;speedbarのサイズに調節
 (global-set-key [(super \0)] '(lambda ()
 (interactive)
 (shell-command "wmctrl -r :ACTIVE: -b toggle -e 0,0,0,1480,1050")))
 

;;#ウィンドウの分割状態を保存

 ;;(require 'winring)
 ;;(winring-initialize)
 ;; 保存する分割状態の最大数を指定
 ;;(setq winring-ring-size 10)
 ;; 分割状態名を順番に数字に
 ;;(setq winring-prompt-on-create nil)
 ;; 現在の分割状態の名前をモードラインに表示する(文字コードの表記が消える)
 ;;(setq winring-show-names t)
 

;;#yasnippet

 (require 'yasnippet)
 (require 'anything-c-yasnippet)
 (yas/initialize)
 (yas/load-directory "~/emacs-lisp/snippets")
 (global-set-key (kbd "C-c y") 'anything-c-yas-complete)
 (require 'dropdown-list)
 (setq yas/prompt-functions '(yas/dropdown-prompt))
 

;;#yasnippet中のflymakeを停止

 (defvar flymake-is-active-flag nil)
 (defadvice yas/expand-snippet
 (before inhibit-flymake-syntax-checking-while-expanding-snippet activate)
 (setq flymake-is-active-flag
 (or flymake-is-active-flag
 (assoc-default 'flymake-mode (buffer-local-variables))))
 (when flymake-is-active-flag
 (flymake-mode-off)))
 
 (add-hook 'yas/after-exit-snippet-hook
 '(lambda ()
 (when flymake-is-active-flag
 (flymake-mode-on)
 (setq flymake-is-active-flag nil))))
 
 ;;ECB
 (setq load-path (cons (expand-file-name "~/emacs-lisp/ecb-2.40") load-path))
 (load-file "~/emacs-lisp/cedet-1.0pre6/common/cedet.el")
 (setq semantic-load-turn-useful-things-on t)
 (require 'ecb)
 (setq ecb-tip-of-the-day nil)
 (setq ecb-windows-width 0.25)
 (defun ecb-toggle ()
 (interactive)
 (if ecb-minor-mode
 (ecb-deactivate)
 (ecb-activate)))
 (global-set-key [f5] 'ecb-toggle)
 (when (and (require 'semantic)
 (require 'semantic-ia)
 (require 'semantic-imenu)
 (require 'semantic-load))
 

;;#imenuをsemanticで

 (semantic-load-enable-code-helpers))
 
 ;;semantic cache is ~/.semantic
 ;;(setq semanticdb-default-save-directory (expand-file-name "~/.semantic"))
 

;;#2chを見るためのもの

 (require 'navi2ch)
 ;(setq navi2ch-net-http-proxy "ここにプロキシ")
 

;;#muse

 (require 'muse-mode)                    ; load authoring mode
 (require 'muse-html)                    ; load publishing styles I use
 ;(require 'muse-latex)
 ;(require 'muse-texinfo)
 (require 'muse-docbook)
 (require 'muse-blosxom)
 

;;#elscreen

 (load "elscreen")
 (setq elscreen-)
 (global-set-key [C-tab] 'elscreen-create)
 (global-set-key [M-right] 'elscreen-next)
 (global-set-key [M-left] 'elscreen-previous)
 (global-set-key [C-delete] 'elscreen-kill)
 (global-set-key [M-delete] 'elscreen-kill-screen-and-buffers)
 

;;#ruby

 (autoload 'ruby-mode "ruby-mode"
 "Mode for editing ruby source files")
 (setq auto-mode-alist
 (append '(("\\.rb$" . ruby-mode)) auto-mode-alist))
 (setq interpreter-mode-alist (append '(("ruby" .ruby-mode))
 interpreter-mode-alist))
 (autoload 'run-ruby "inf-ruby"
 "Run an inferior Ruby process")
 (autoload 'inf-ruby-keys "inf-ruby"
 "set local key defs for inf-ruby in ruby-mode")
 (add-hook 'ruby-mode-hook
 '(lambda ()
 (inf-ruby-keys)))
 

;;#emacs-lisp関数定義場所に飛ぶ

 (require 'jump)
 (add-hook
 'emacs-lisp-mode-hook
 '(lambda()
 (define-key emacs-lisp-mode-map [(super f)] 'jump-symbol-at-point)
 (define-key emacs-lisp-mode-map [(super b)] 'jump-back)))
 

;;#透過処理

 (defun my-opacity-change (action)
 (let* ((op (frame-parameter (selected-frame)
 'alpha))
 val)
 (unless op
 (setq op 100))
 (when (setq val (cond
 ((eq action 'up)
 (if (> op 90) 100 (+ op 10)))
 ((eq action 'down)
 (if (> 10 op) 10 (- op 10)))
 ((eq action 'clear)
 100)
 ((numberp action)
 action)
 (t
 nil)))
 (set-frame-parameter (selected-frame) 'alpha val))))
 
 (my-opacity-change 95); 不透過度
 ;;(my-opacity-change 'up); 不透過度を10上昇させる
 ;;(my-opacity-change 'down); 不透過度を10下降させる
 ;;(my-opacity-change 'clear); 半透明にするをやめる
 
 (require 'sudoku)
 

;;#ispell

 (setq ispell-program-name "aspell")
 (setq ispell-grep-command "grep")
 (eval-after-load "ispell"
 '(add-to-list 'ispell-skip-region-alist '("[^\000-\377]")))
 

;;#英語の翻訳など

 (require 'text-translator)
 (setq text-translator-auto-selection-func
 'text-translator-translate-by-auto-selection-enja)
 

;;#undo-tree

 (require 'undo-tree)
 (global-undo-tree-mode)
 (set-default-font "DejaVu Sans Mono-10")
  • HTML
  • PDF
RSS2.0 RSS1.0 Atom1.0