覚え書き

Emacs のたち上げ時のログをとる

Emacs を batch モードでたちあげる.

% emacs -batch -l ~/.emacs

.emacs のデバッグ

1) .emacs を読み込まないで起動.

% emacs -q

2) debug-on-error を ON にする

 M-x set-variable
 debug-on-error
 t

3) 手動で .emacs をロードする

  M-x load-file
  ~/.emacs

これでエラーが発生した時点でスタックトレースが表示される.

ちなみに .emacs の所々に

(message "point(1) passed")

といった行をいれておくと,どこまでうまくいったかがわかる.

.emacs に新しい設定をいれる時の鉄則

新しい設定は必ずファイルの最後にいれる.

というのは,エラーが起こるとそれ以後の行が実行されないから.


Emacs の起動オプション

Emacs の起動オプションは,以下のようなものがあるみたいです.

(標準ライブラリの startup.el より引用)

  ;;; Commentary:

  ; These are processed only at the beginning of the argument list.
  ; -batch             execute noninteractively (messages go to stdout,
  ;                     variable noninteractive set to t)
  ;                     This option must be the first in the arglist.
  ;                     Processed by `main' in emacs.c -- never seen by lisp
  ; -t file            Specify to use file rather than stdin/stdout
  ;                     as the terminal.
  ;                     This option must be the first in the arglist.
  ;                     Processed by `main' in emacs.c -- never seen by lisp
  ; -nw                Inhibit the use of any window-system-specific display
  ;                     code; use the current virtual terminal.
  ;                     This option must be the first in the arglist.
  ;                     Processed by `main' in emacs.c -- never seen by lisp
  ; -q                 load no init file
  ; -no-init-file      same
  ; -u user            load user's init file
  ; -user user         same
  ; -debug-init        Don't catch errors in init file; let debugger run.

  ; These are processed in the order encountered.
  ; -f function        execute function
  ; -funcall function  same
  ; -l file            load file
  ; -load file         same
  ; -insert file       same
  ; file               visit file
  ; -kill              kill (exit) emacs

scratch buffer

NetNews に流れていた Emacs Lisp プログラミングを行うための (ちょっとした)コツから引用します.

Emacs で,Lisp のプログラムを実行または評価(eval)する方法

(1) *scratch* バッファに行きます.(Emacs を起動した時の最初のバッファ)

(2) モードラインに "(Lisp Interaction)" という(モード名)表示が 出ていることを確認します. もし,"(Fundamental)" など別のモードになっていたら,

   M-x lisp-interaction-mode RET

を入力して,Lisp Interaction モードにします。

(3) *scratch* バッファの任意の場所(通常は最後)に,実行したい Lisp の式を書きます.

   例: (find-file "~/.emacs")

(4) Lisp の式の後ろにカーソルを持っていきます.

   例: (find-file "~/.emacs")■
                             ↑
                             カーソル

(5) ここで,C-j (LFD とも呼ぶ)を入力します. Lisp Interaction モードでは, C-j は直前の Lisp の式を実行(評価=eval)して, その結果を表示(print)するためのコマンド(eval-print-last-sexp)が 割り当てられています. 実際には,上の例を実行すると, ホームディレクトリにある,初期化ファイル(.emacs)が開かれます.

(6) この時、*scratch* バッファには,以下のように表示されます. "#<buffer .emacs>" というのは,(find-file "~/.emacs") の返した値です.

   例: (find-file "~/.emacs")
       #<buffer .emacs>

参考:

(call-interactively 'find-file) を実行すると, C-x C-f を入力した場合と同じように, "Find file: ~/" というプロンプトが出ます.


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-08-06 (土) 21:18:50