开发者

How can I tell emacs to not split the window on M-x compile or elisp compilation error?

开发者 https://www.devze.com 2023-03-17 23:26 出处:网络
When I perform M-x compile or get an elisp compilation error, my emacs splits the window vertically, and displays the compile output/error message in the new window. I prefer to work with my buffers i

When I perform M-x compile or get an elisp compilation error, my emacs splits the window vertically, and displays the compile output/error message in the new window. I prefer to work with my buffers in a full screen window, because the vertically split window is too narrow for me. Can I tell emacs to not split the window and do a M-x switch-buffer to the compilation/error buffer?

Edit: Trey's suggestion works for com开发者_开发知识库pilation. Is there a way to set it for all the commands which split the window? The three I have in mind are elisp compiling, M-x apropos and M-x occur.


Try this:

(setq compilation-window-height 1000)

You could get fancy and actually calculate the number of lines of text in the frame... (/ (frame-pixel-height) (frame-char-height)), but that seems silly.

Io control how Emacs generally displays buffers, you can configure the variable same-window-regexps to match all buffer names, and then all commands that display buffers using display-buffer will use the same window:

(setq same-window-regexps '("."))

See Choosing a Window for more details.


my guess is that you want to customize the split-window-preferred-function variable. the default value is split-window-sensibly. you should change it to a custom version which just switches the current buffer.

this seems to work:

(defun no-split-window ()
  (interactive)
  nil)

(setq split-window-preferred-function 'no-split-window)


This is what I use for compilation windows. If there are no errors or warnings, it will display the compilation output buffer for a second and then kill it. Otherwise the buffer stays because you probably want find the errors and fix them. I got this from a newsgroup.

(defun kill-compile-buffer-if-successful (buffer string) 
  " kill a compilation buffer if succeeded without warnings " 
  (if (and 
       (string-match "compilation" (buffer-name buffer)) 
       (string-match "finished" string) 
       (not 
        (with-current-buffer buffer 
          (search-forward "warning" nil t)))) 
      (run-with-timer 1 nil 
                      'kill-buffer 
                      buffer)))
(add-hook 'compilation-finish-functions 'kill-compile-buffer-if-successful)
0

精彩评论

暂无评论...
验证码 换一张
取 消