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