8

新しいコンパイル中に以前のコンパイル エラーをブラウズできるように emacs をセットアップするにはどうすればよいですか?

2つのことがうまくいきません:

  1. 2 番目のコンパイルが進行中の場合、Mg Mg (next-error) 関数が機能しません。

  2. 私はemacsを5つの不均等なウィンドウに分割しています(分割ウィンドウを水平に)、コンパイル「ウィンドウ」はサイズが2倍です(dblモニターセットアップ)。コンパイルを開始すると、常に最後のダブル コンパイル ウィンドウに表示されます。これで、それ自体の新しいウィンドウが開きます。

4

3 に答える 3

3

すべての要件を満たすと思われるソリューションを次に示します。

  • バッファは*compilation-old*常に同じウィンドウにとどまります
  • next-error壊れない
  • *compilation-old*後続のすべてのコンパイル出力は、コンパイル プロセスが終了したときに末尾に追加されます。
(defun my-compilation-finish-function (buffer msg)
  ;; Don't do anything if we are in a derived mode
  (when (with-current-buffer buffer (eq major-mode 'compilation-mode))

    ;; Insert the last compilation output at the end of *compilation-old*
    (if (get-buffer "*compilation-old*")
        (with-current-buffer "*compilation-old*"
          (save-excursion
            (goto-char (point-max))
            (insert-buffer buffer)))
      (with-current-buffer buffer
        (rename-buffer "*compilation-old*")))))

(add-hook 'compilation-finish-functions 'my-compilation-finish-function)



(defadvice compile (around my-compile-show-old activate)
  "Show the *compilation-old* buffer after starting the compilation"
  (let ((buffer (current-buffer)))
    (when (get-buffer "*compilation-old*")
      (pop-to-buffer "*compilation-old*")
      (switch-to-buffer "*compilation*"))
    ad-do-it
    (when (get-buffer "*compilation-old*")
      (switch-to-buffer "*compilation-old*")
      (pop-to-buffer buffer))))
于 2012-11-08T08:11:33.320 に答える
2

以下を init ファイルに入れる*compilation-old*と、コンパイル コマンドが終了したときにコンパイル バッファの名前が変更されます。

古いコンパイル バッファから新しいコンパイル プロセスを実行すると、これは機能しないことに注意してください (compileこの場合、新しいバッファを作成する代わりにバッファを再利用するため)。

(defun my-rename-compilation-buffer (buffer message)
  ;; Don't do anything if we are in a derived mode
  (when (with-current-buffer buffer (eq major-mode 'compilation-mode))
    (let* ((old-compilation-buffer-name "*compilation-old*")
           (old-compilation-buffer (get-buffer old-compilation-buffer-name)))

      ;; Kill old compilation buffer if necessary
      (when old-compilation-buffer
        (kill-buffer old-compilation-buffer))

      ;; Rename the current compilation buffer
      (with-current-buffer buffer
        (rename-buffer old-compilation-buffer-name)))))

(add-hook 'compilation-finish-functions 'my-rename-compilation-buffer)
于 2012-11-19T15:46:48.100 に答える
0

少し面倒ですが、これを試してください:

新しいコンパイルを開始する前に、現在のコンパイル バッファをファイルに保存 (書き込み、Cx Cw) します。新しいファイルのバッファが「コンパイル モード」設定を失った場合は、単純にコンパイル モードをオンに戻します (Mx コンパイル モード)。

于 2012-11-07T14:38:40.220 に答える