表示関連†
(setq frame-title-format (format "emacs@%s : %%f" (system-name))) ; タイトルバーの表示書式にファイル名を入れる
文字色の変更†
- emacs 上で指定された文字色を変更する方法について。
- magit, xcscope などのパッケージで、文字色の制御を行っているものがある。これらは端末の background color などの関係で、場合によって却って見難くなることがある。
terinal 上で動作させる場合†
- 方法1
$ cat ${HOME}/.bashrc
alias emacsd='env TERM=xterm emacs --daemon'
alias emacs='emacsclient -t'
- 方法2
$ TERM=xterm-256color emacs -nw
- 方法3 init.elに以下を追加する
(defun terminal-init-gnome ()
"Terminal initialization function for gnome-terminal."
;; This is a dirty hack that I accidentally stumbled across:
;; initializing "rxvt" first and _then_ "xterm" seems
;; to make the colors work... although I have no idea why.
(tty-run-terminal-initialization (selected-frame) "rxvt")
(tty-run-terminal-initialization (selected-frame) "xterm"))
- 方法4 init.elに以下を追加する
(add-hook 'tty-setup-hook
'(lambda ()
(set-terminal-parameter nil 'background-mode 'dark)))
どの変数で色定義されているかを調べる†
- 対象となる文字列にカーソルを合わせた上で、以下を実行する:
M-x: describe-face
すると、ミニバッファに以下のように表示される:
Describe face (default `cscope-file-face'):
- ここで決定(return キーを押す)と、以下のように表示される:
Face: cscope-file-face (sample) (customize this face)
Documentation:
Face used to highlight file name in the *cscope* buffer.
Defined in `xcscope.el'.
Family: unspecified
Foundry: unspecified
Width: unspecified
Height: unspecified
Weight: unspecified
Slant: unspecified
Foreground: yellow
DistantForeground: unspecified
Background: unspecified
Underline: unspecified
Overline: unspecified
Strike-through: unspecified
Box: unspecified
Inverse: unspecified
Stipple: unspecified
Font: unspecified
Fontset: unspecified
Inherit: unspecified
色変更の定義†
- 上記を元に、以下のように設定してやれば、色を変えることが出来る
(set-face-foreground 'cscope-file-face "#d54e53") ; yellow → (RGB)=(0xd5,0x4e,0x53)
色設定†
{menu|tool}-barを消す†
(tool-bar-mode 0) ; tool bar を表示しない
(menu-bar-mode 0) ; menu bar を表示しない
(which-function-mode 1) ; 現在の関数名をモードラインに表示
行頭に行番号を表示する(モード行ではなく)†
モードラインに現在カーソルが位置している関数の関数名を表示する†
Time-stamp†
; Time-stamp
; http://homepage.mac.com/zenitani/elisp-j.html#time-stamp
(require 'time-stamp)
(setq time-stamp-start "Last updated: <") ; 開始文字列の設定。通常は "Time-stamp: <>"
;; 日本語で日付を入れたくないのでlocaleをCにする
(defun time-stamp-with-locale-c ()
(let ((system-time-locale "C"))
(time-stamp)
nil))
(if (not (memq 'time-stamp-with-locale-c write-file-hooks))
(add-hook 'write-file-hooks 'time-stamp-with-locale-c))
; (setq time-stamp-format "%3a %3b %02d %02H:%02M:%02S %Z %:y")
(setq time-stamp-format "%04y/%02m/%02d %02H:%02M:%02S %Z") ; YYYY/MM/DD HH:MM:SS JST
文字数を数える†
- 対象領域を選択し、
M-x: count-lines-region
または
M-=
とする。
- 行数と文字数が表示される。文字数は、全角も半角もそれぞれ1文字として扱われる。
isearch で、カーソルの位置にある単語を検索対象にする†
shell-mode で制御文字を処理する†
; shell-mode で制御文字を処理する。
(autoload 'ansi-color-for-comint-mode-on "ansi-color"
"Set `ansi-color-for-comint-mode' to t." t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
ファイルを read-only で開く†
C-x C-r
バックアップファイルを作らないようにする†
(setq make-backup-files nil) ; *.~ とかのバックアップファイルを作らない
(setq auto-save-default nil) ; .#* とかのバックアップファイルを作らない
選択領域を [DEL] で一気に消せるようにする†
; (setq delete-selection-mode t)
(delete-selection-mode)
HTML文書編集での自動補完†
- yahtmlを使う(yahtmlは、YaTeXに付属しているもの)。
- 参考リンク
scroll を1行単位にする†
(setq scroll-step 1)
分割した window のサイズを変える†
command | description | remark |
M-x: enlarge-window | 縦方向にサイズを大きくする | |
M-x: shrink-window | 縦方向にサイズを小さくする | |
M-x: enlarge-window-horizontally | 横方向にサイズを大きくする | |
M-x: shrink-window-horizontally | 横方向にサイズを小さくする | |
ウインドウ自動分割時の制御†
beep 音を消す†
- 嘗ては、以下の設定でカスタマイズすることが出来たが、emacs 24.4.1 では効かないようである。
前のウインドウに戻る†
; XEmacsにはあるが、emacsにはない(!)
; http://matome.replore.com/index.php?title=Emacs_Lisp%E3%81%BE%E3%81%A8%E3%82%81
; xemacsに合わせて、関数名を backward-other-window に変更。
; (defun other-window-backward (&optional n)
(defun backward-other-window (&optional n)
"Select nth previous window."
(interactive "P")
(other-window (- (prefix-numeric-value n))))
起動済みのemacs にファイルを渡す (emacsclient)†
検索時に大文字・小文字を区別するかしないかの設定†
(setq default-case-fold-search nil) ; 大文字・小文字を区別させる(〜emacs23.1)
(setq case-fold-search nil) ; 大文字・小文字を区別させる (emacs23.2〜)
- emacs23.2 以降では default-case-fold-search ではなく case-fold-search を使うように推奨されている
(see also M-x describe-variable case-fold-search)
カレンダーで日本の祝日を表示する†
- M-x: calendar で表示するカレンダーで日本の祝日を表示する方法。
- japanese-holidays.el を入手する
- 設定
- enmacs 起動時に cl-lib が見つからないと怒られた場合
gdb-mode†
- gdb-mode のコマンド
bindings | description | remark |
C-x C-a C-t | ソースコードの現在のカーソル位置に break point を設定する | |
C-h m | EmacsのGDBモードの機能に関する説明を表示 | |
M-s | Step実行。関数なら入って止まる | |
C-x C-a C-s |
M-n | GDBのnextコマンドのように、 関数呼び出しをすべてスキップして、 現在の関数内の次のソース行まで実行 | |
C-x C-a C-s |
M-i | GDBのstepiコマンドのように、 1命令を実行 | |
C-x C-a C-i |
M-x gdb-nexti | GDBのnextiコマンドを使って、 次の命令まで実行 | |
C-c C-f | GDBのfinishコマンドのように、 選択されたスタック・フレームを終了するまで実行を継続 | |
M-c | GDBのcontinueコマンドのように、 ユーザ・プログラムの実行を継続 | |
M-u | GDBのupコマンドのように、 数値引数によって示される数だけ上位のフレームに移動 | |
M-d | GDBのdownコマンドのように、 数値引数によって示される数だけ下位のフレームに移動 | |
C-x & | カーソルの位置にある数値を読み取り、 GDBのI/Oバッファの末尾に挿入 | |
C-x C-a C-r | 次の break point まで実行 | |
C-x C-a C-f | 現在のカーソル位置まで実行 | |
helm†
入手先†
参考リンク†
多言語入力†
ドイツ語†
- M-x set-input-method german
- ウムラウトは以下のキー入力にて。ちなみに z と y が入れ替わるので、慣れてない人は注意!
Character | Key binding |
ä | C-x 8 " a |
ü | C-x 8 " u |
ö | C-x 8 " o |
チェコ語†
- uim 環境下で setxkbmap cz として使用した場合
- 数字キー(≠テンキー)でチャールカ付き・ハーチェク付き文字の幾つかが打てる。
- "Ctrl(+Shift)+文字" では、チャールカ付き・ハーチェク付き文字を打つことが出来ない。
Character | Key binding |
ě | 2 |
š | 3 |
č | 4 |
ř | 5 |
ž | 6 |
ý | 7 |
á | 8 |
í | 9 |
é | 0 |
ů | + |
- それぞれ、CAPS LOCK した状態で打つと大文字の入力となる。
- 以下は "setxkbmap cz" を しない状態での説明。
- M-x set-input-method czech
- type following keybind
Character | Key binding |
č | + c |
Č | + C |
ď | + d |
Ď | + D |
ě | + e |
Ě | + E |
ň | + n |
Ň | + N |
ř | + r |
Ř | + R |
š | + s |
Š | + S |
ť | + t |
Ť | + T |
á | = a |
Á | = A |
é | = e |
É | = E |
í | = i |
Í | = I |
ó | = o |
Ó | = O |
ů | + |
Ů | ~ U |
ú | = u |
Ú | = U |
ý | = y |
Ý | = y |
html-mode†
キーバインド†
key | command | description | remark |
C-c C-j | html-line | 改行+ <br>挿入 | |
C-c C-h | html-paragraph | <p> 挿入 | |
C-c C-a | sgml-attributes | | |
C-c C-b | sgml-skip-tag-backward | 一つ前の開始タグまで戻る(?) | |
C-c C-d | delete-tag | タグ単位で消す | |
C-c C-f | sgml-skip-tag-foward | 1つ先の終了タグまで飛ぶ(?) | |
C-c / | sgml-close-tag | 終了タグを挿入する | |
C-c <1-6> | html-headline-<1-6> | h1-h6 の開始・終了タグを挿入する | |
C-c C-c - | html-horizontal-rule | <hr> タグを挿入する | |
C-c C-c c | html-checkboxes | '<input type="checkbox" name="' を挿入する | |
C-c C-c h | html-href-ancor | '<a href="' を挿入する | |
C-c C-c i | html-image | 対話的に img タグを挿入する | |
C-c C-c n | html-name-anchor | '<a name="' を挿入する | |
C-c C-c o | html-ordered-list | 番号リストの開始タグを挿入する | |
C-c C-c r | html-radio-button | ラジオボタンを挿入する | |
C-c C-c u | html-unordered-list | 番号なしリストの開始タグを挿入する | |
C-c DEL | sgml-delete-tag | カーソルの後ろのタグを消す | |
参考リンク†