2012-03-15 3 views
11

Emacs의 컴파일 창을 항상 창의 아래쪽에 나타나게하고 항상 특정 높이로 만들고 싶습니다. 지금까지 나는 내 이맥스 파일에 다음 줄을 넣어 :Emacs의 컴파일 창을 항상 특정 크기로 만들려면 어떻게해야합니까?

(setq split-height-threshold 0) 
(setq compilation-window-height 10) 

... 그리고 않는 내가 수평으로 두 개의 창으로 화면을 분할 나는 즉시 하나 개의 창이 열려 있지만, 경우에 대한 작업 (즉, 중간에있는 구분선이 위쪽에서 아래쪽으로 이동 함) 컴파일 창은 높이 변수를 무시하고 중간에 창을 분할합니다.

어떻게 수정합니까?

+0

[popwin] (https://github.com/m2ym/popwin-el)은 Amardeep에서 제안한대로 유용 할 수 있습니다. – kenorb

답변

13

나는 자유롭게 EmacsWiki에서 적응이 같은 것을 사용할 것 :의 *compilation* 버퍼가 표시되지 않은 경우,이 10 선 높이에 새롭게 문을 연 창 크기를 조정, 수직 창을 분할합니다

(defun my-compilation-hook() 
    (when (not (get-buffer-window "*compilation*")) 
    (save-selected-window 
     (save-excursion 
     (let* ((w (split-window-vertically)) 
       (h (window-height w))) 
      (select-window w) 
      (switch-to-buffer "*compilation*") 
      (shrink-window (- h compilation-window-height))))))) 
(add-hook 'compilation-mode-hook 'my-compilation-hook) 

및 그 안에 *compilation* 버퍼를 엽니 다.

1) :

+2

윈도우를 패치하지 않고 윈도우가 아닌 현재 프레임의 맨 아래에 항상 패치하는 방법을 알고 있습니까? 나는 다음과 같은 경우를 의미합니다. C-x 2를 반으로 분할하고, M-x는 맨 위 창에 머무르면서 컴파일합니다. 귀하의 코드가 상단 승리의 하단 부분에 컴파일을 열어 프레임의 하단에 그것을 열어 좋을 것입니다 ... – Mekk

+1

@Mekk 나는 [gist] (https : // gist)에 수정 된 버전을 게시했습니다. github.com/ffevotte/d7e69cf147c014381003) – Francesco

+0

대단히 감사합니다. 좋은 일이 한가지 더 있습니다.하지만 여기서는 가능한지 확신 할 수 없습니다. 유사한 파생 모드가없는 컴파일 공유 창을 만듭니다 (제 경우에는 대부분 * Ack * 또는 * Ag *입니다. Occur * 또는 * (some) Grep *는 동일해야합니다. 내가 직접 솔루션을 찾아 보려고했지만 "이맥스를 어떻게 말할 지 모르겠다."제발,이 컴파일은 현재 * Ack *로 점령 된 창에서 만든다. (여전히, 현재 코드에 대해 다시 한 번 감사) – Mekk

1

변수 compilation-window-height을 사용자 정의 할 수 있습니다.

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) 
관련 문제