2009-04-13 3 views
4

내가 이맥스에 하나의 창만 표시하고 M-x 컴파일을 사용하면 창문이 두 개로 나뉘어서 컴파일 버퍼를 쉽게 볼 수 있습니다. 그러나, 더 많은 윈도우가 보여지면, 컴파일 로그는 다른 것들 중 하나를 대신하여 자극을줍니다. Emacs가 컴파일 로그를 표시하기 위해 항상 새 창을 분할하도록하려면 어떻게합니까?어떻게 컴파일 로그를 Emacs에서 새 창을 만들 수 있습니까?

편집 : 내가 해왔 던 나의 독서에서 조금 더 많은 정보. compile.el은 display-buffer를 호출하는 것처럼 보입니다. display-buffer는 현재 전체 너비 인 경우에만 윈도우를 분할합니다. 이 문제를 피할 수있는 방법이 있습니까?

답변

4

귀하는 귀하의 필요에 맞게 Trey Jackson에서 제공되는 솔루션을 수정할 수 있습니다.

다음 스 니펫은 버퍼 *compilation*을 특별하게 표시하고 분할 된 창에 이미있는 경우에도 현재 창을 분할하는 표시 기능으로 사용자 지정 기능을 설정합니다.

1) :

(setq special-display-buffer-names 
     '("*compilation*")) 

(setq special-display-function 
     (lambda (buffer &optional args) 
     (split-window) 
     (switch-to-buffer buffer) 
     (get-buffer-window buffer 0))) 
+0

전혀 작동하지 않습니다. – CodyChan

3

원하는 최상위 창 (Emacs는 프레임)을 호출하면 트릭이 수행됩니다. 이 스 니펫에는 게재 지시 문이 포함되어 있지만 'special-display-buffer-names 변수를 맞춤 설정하면 원하는 것을 얻을 수 있습니다.

(setq special-display-buffer-names 
     `(("*compilation*" . ((name . "*compilation*") 
          ,@default-frame-alist 
          (left . (- 1)) 
          (top . 0))))) 
+0

나는 용어를 알고 있으며 실제로 물리적 인 것과는 반대로 논리적 인 이맥스 창을 찾고 있습니다. –

1

http://www.emacswiki.org/emacs/CompilationMode에서 How can I prevent emacs from opening new window for compilation output?에서 코드를 코드를 결합, 이것은 당신에게 4 개 기능을 제공, compile에 대한 모든 내 코드입니다. compile-again을 사용하면 자동으로 마지막 컴파일과 동일한 컴파일을 수행합니다. 마지막 시간이 없거나 접두사 인수가 있으면 M-x 컴파일과 같은 역할을합니다.

2). compile은 현재 창을 분할하므로이 프레임의 다른 창에는 영향을 미치지 않습니다.

3). 오류가 없으면 *compilation* 버퍼 (창)를 자동으로 닫고 오류가 있으면 그대로 두십시오.

4). *compilation* 버퍼에있는 오류 코드와 줄 번호를 강조 표시하고 M-n/p을 사용하여 *compilation* 버퍼의 모든 오류 (오류 코드 줄의 Enter)를 탐색하여 코드 코드의 줄로 이동합니다.

(require 'compile) 
(setq compilation-last-buffer nil) 
(defun compile-again (ARG) 
    "Run the same compile as the last time. 

If there is no last time, or there is a prefix argument, this acts like M-x compile." 
    (interactive "p") 
    (if (and (eq ARG 1) 
      compilation-last-buffer) 
     (progn 
     (set-buffer compilation-last-buffer) 
     (revert-buffer t t)) 
    (progn 
     (call-interactively 'compile) 
     (setq cur (selected-window)) 
     (setq w (get-buffer-window "*compilation*")) 
     (select-window w) 
     (setq h (window-height w)) 
     (shrink-window (- h 10)) 
     (select-window cur)))) 
(global-set-key (kbd "C-x C-m") 'compile-again) 
(defun my-compilation-hook() 
    "Make sure that the compile window is splitting vertically." 
    (progn 
    (if (not (get-buffer-window "*compilation*")) 
     (progn 
      (split-window-vertically))))) 
(add-hook 'compilation-mode-hook 'my-compilation-hook) 
(defun compilation-exit-autoclose (STATUS code msg) 
    "Close the compilation window if there was no error at all." 
    ;; If M-x compile exists with a 0 
    (when (and (eq STATUS 'exit) (zerop code)) 
    ;; then bury the *compilation* buffer, so that C-x b doesn't go there 
    (bury-buffer) 
    ;; and delete the *compilation* window 
    (delete-window (get-buffer-window (get-buffer "*compilation*")))) 
    ;; Always return the anticipated result of compilation-exit-message-function 
    (cons msg code)) 
(setq compilation-exit-message-function 'compilation-exit-autoclose) 
(defvar all-overlays()) 
(defun delete-this-overlay(overlay is-after begin end &optional len) 
    (delete-overlay overlay) 
) 
(defun highlight-current-line() 
"Highlight current line." 
    (interactive) 
    (setq current-point (point)) 
    (beginning-of-line) 
    (setq beg (point)) 
    (forward-line 1) 
    (setq end (point)) 
    ;; Create and place the overlay 
    (setq error-line-overlay (make-overlay 1 1)) 

    ;; Append to list of all overlays 
    (setq all-overlays (cons error-line-overlay all-overlays)) 

    (overlay-put error-line-overlay 
       'face '(background-color . "red")) 
    (overlay-put error-line-overlay 
       'modification-hooks (list 'delete-this-overlay)) 
    (move-overlay error-line-overlay beg end) 
    (goto-char current-point)) 
(defun delete-all-overlays() 
    "Delete all overlays" 
    (while all-overlays 
    (delete-overlay (car all-overlays)) 
    (setq all-overlays (cdr all-overlays)))) 
(defun highlight-error-lines(compilation-buffer process-result) 
    (interactive) 
    (delete-all-overlays) 
    (condition-case nil 
     (while t 
     (next-error) 
     (highlight-current-line)) 
    (error nil))) 
(setq compilation-finish-functions 'highlight-error-lines) 
0

smart-compile 패키지를 Emacs에 설치하십시오.

당신이 C-x C-m을 실행하는 처음 인 경우, 그것은 일반적으로 충분하다 (기본 명령을 변경하도록 요청합니다, 소스 코드를 컴파일하기 위해 init.el 또는 .emacs

(require 'compile) 
(setq compilation-last-buffer nil) 
;; save all modified buffers without asking before compilation 
(setq compilation-ask-about-save nil) 
(defun compile-again (ARG) 
    "Run the same compile as the last time. 

With a prefix argument or no last time, this acts like M-x compile, 
and you can reconfigure the compile args." 
    (interactive "p") 
    ;; the following two lines create bug: split a new window every time 
    ;; (if (not (get-buffer-window "*compilation*")) 
    ;;  (split-window-below)) 
    (if (and (eq ARG 1) compilation-last-buffer) 
     (recompile) 
    (call-interactively 'smart-compile))) 
(bind-key* "C-x C-m" 'compile-again) 
;; create a new small frame to show the compilation info 
;; will be auto closed if no error 
(setq special-display-buffer-names 
     `(("*compilation*" . ((name . "*compilation*") 
          ,@default-frame-alist 
          (left . (- 1)) 
          (top . 0))))) 
(setq compilation-finish-functions 
     (lambda (buf str) 
     (if (null (string-match ".*exited abnormally.*" str)) 
      ;;no errors, make the compilation window go away in a few seconds 
      (progn 
       (run-at-time 
       "1 sec" nil 'delete-windows-on 
       (get-buffer-create "*compilation*")) 
       (message "No Compilation Errors!"))))) 

사용 C-x C-m에이를 추가). 그렇지 않으면 직접 컴파일하는 데 사용한 명령이 실행되고 원하는 경우 명령을 변경하려면 C-u C-x C-m을 사용해야합니다. 현재 디렉토리 안에 Makefile이 있으면 사용 여부를 묻는 메시지가 표시됩니다.

어쩌면이 답변은 귀하의 질문에 너무 많이 들지만 시도해보십시오.

관련 문제