Top/Editor/emacs

目次

Links

emacs / XEmacs 共通

表示関連

(setq frame-title-format (format "emacs@%s : %%f" (system-name)))	; タイトルバーの表示書式にファイル名を入れる

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

文字数を数える

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文書編集での自動補完

色設定

emacs only

{menu|tool}-barを消す

(tool-bar-mode 0)		; tool bar を表示しない
(menu-bar-mode 0)		; menu bar を表示しない
(which-function-mode 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)

カレンダーで日本の祝日を表示する

cscope

tag の生成

$ cscope-indexer -r

xcsxope.el で見る

`cscope-minor-mode' Minor Mode Bindings:
key             binding
---             -------

C-c             Prefix Command

C-c s           Prefix Command

C-c s A         cscope-unset-initial-directory
C-c s B         cscope-display-buffer-toggle
C-c s C         cscope-find-called-functions
C-c s D         cscope-dired-directory
C-c s E         cscope-edit-list-of-files-to-index
C-c s G         cscope-find-global-definition-no-prompting
C-c s I         cscope-index-files
C-c s L         cscope-create-list-of-files-to-index
C-c s N         cscope-next-file
C-c s P         cscope-prev-file
C-c s S .. C-c s T              cscope-tell-user-about-directory
C-c s W         cscope-tell-user-about-directory
C-c s a         cscope-set-initial-directory
C-c s b         cscope-display-buffer
C-c s c         cscope-find-functions-calling-this-function
C-c s d         cscope-find-global-definition
C-c s e         cscope-find-egrep-pattern
C-c s f         cscope-find-this-file
C-c s g         cscope-find-global-definition
C-c s i         cscope-find-files-including-file
C-c s n         cscope-next-symbol
C-c s p         cscope-prev-symbol
C-c s s         cscope-find-this-symbol
C-c s t         cscope-find-this-text-string
C-c s u         cscope-pop-mark

参考リンク

gtags / global の利用

tag の生成

$ gtags [options] [path]
$ gtags -f <files>
$ gtags -v

emacs の設定

(setq default-case-fold-search nil)  ; 大文字・小文字を区別させる

; "\M-p" が prefix-command に喰われていて使えないので、全て "\C-\M-" のシリーズにしている
(global-set-key "\C-\M-t" 'gtags-find-tag)     ;関数の定義元へ
(global-set-key "\C-\M-r" 'gtags-find-rtag)    ;関数の参照先へ
(global-set-key "\C-\M-s" 'gtags-find-symbol)  ;変数の定義元/参照先へ
(global-set-key "\C-\M-p" 'gtags-find-pattern)
(global-set-key "\C-\M-f" 'gtags-find-file)    ;ファイルにジャンプ
(global-set-key [?\C-,] 'gtags-pop-stack)   ;前のバッファに戻る

参考リンク

etags (ctags for Emacs)の利用

tag の生成

emacs に TAGS ファイルを読みこませる

M-x: tags-reset-tags-tables 一旦リセットする
M-x: visit-tags-table 明示的に TAGS ファイルを読み込む

ctags-exuberant

TAGS file の生成

$ ctags-exuberant -e -R [path]

emacs から TAGS の生成を行えるようにする

参考リンク

ebrowse (ebrowse for Emacs)の利用

Links

モードラインに現在カーソルが位置している関数の関数名を表示する

gdb-mode

XEmacs only

fume-mode

;=========================================================
; fume-mode (XEmacs only)
(defun function-menu-mode()
  (interactive)
  (fume-mode t)
  (fume-add-menubar-entry t)) ; モード行に現在カーソルがある関数の名前を表示

(global-set-key "\C-\M-l" 'function-menu-mode)	; function-menu-mode に入る

using Unicode

emacsでは使えるのに、何故かXEmacsのdefaultでは使えないUnicode. 使えるようにするには、以下をinit.elに追記する:

(require 'un-define)
(unless (emacs-version>= 21 5 6)
  (require 'mule-ucs-unicode "unicode"))
(set-coding-category-system 'utf-8 'utf-8)
(set-coding-priority-list '(utf-8))


(load "term/keyswap")
(global-set-key [backspace] 'backward-delete-char)
(keyboard-translate ?\C-h 'backspace)
(global-set-key [delete] 'delete-char)

ホイールマウスのスクロールを有効にする

(autoload
  'mwheel-install "mwheel" "Enabal mouse wheel support.")
(mwheel-install)

多言語入力

ドイツ語

  1. M-x set-input-method german
  2. ウムラウトは以下のキー入力にて。ちなみに z と y が入れ替わるので、慣れてない人は注意!
    CharacterKey binding
    äC-x 8 " a
    üC-x 8 " u
    öC-x 8 " o

チェコ語

  1. M-x set-input-method czech
    CharacterKey binding
    č+ c
    Č+ C
    ě+ e
    Ě+ E
    ř+ r
    Ř+ R
    ň+ n
    Ň+ N
    ď+ d
    Ď+ D
    ť+ t
    Ť+ T
    á= a
    Á= A
    é= e
    É= E
    í= i
    Í= I
    ó= o
    Ó= O
    ů+
    Ů~ U
    ú- u
    Ú- U

html-mode

キーバインド

keycommanddescriptionremark
C-c C-jhtml-line改行+ <br>挿入
C-c C-hhtml-paragraph<p> 挿入
C-c C-asgml-attributes
C-c C-bsgml-skip-tag-backward一つ前の開始タグまで戻る(?)
C-c C-ddelete-tagタグ単位で消す
C-c C-fsgml-skip-tag-foward1つ先の終了タグまで飛ぶ(?)
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 chtml-checkboxes'<input type="checkbox" name="' を挿入する
C-c C-c hhtml-href-ancor'<a href="' を挿入する
C-c C-c ihtml-image対話的に img タグを挿入する
C-c C-c nhtml-name-anchor'<a name="' を挿入する
C-c C-c ohtml-ordered-list番号リストの開始タグを挿入する
C-c C-c rhtml-radio-buttonラジオボタンを挿入する
C-c C-c uhtml-unordered-list番号なしリストの開始タグを挿入する
C-c DELsgml-delete-tagカーソルの後ろのタグを消す

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS