>From 021d45a602ef63bfd14a98a6d622cc107f75e2e7 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Tue, 5 Feb 2013 15:05:18 +0800 Subject: [PATCH 1/2] New variable compilation-dont-display-buffer --- lisp/progmodes/compile.el | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index f383e02b..8b5e3a81 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -58,6 +58,12 @@ (defcustom compilation-start-hook nil :group 'compilation) ;;;###autoload +(defcustom compilation-dont-display-buffer nil + "Non-nil to inhibit display the compilation buffer." + :type 'boolean + :group 'compilation) + +;;;###autoload (defcustom compilation-window-height nil "Number of lines in a compilation window. If nil, use Emacs default." :type '(choice (const :tag "Default" nil) @@ -1616,7 +1622,8 @@ (defun compilation-start (command &optional mode name-function highlight-regexp) (set-buffer-modified-p nil)) ;; Pop up the compilation buffer. ;; http://lists.gnu.org/archive/html/emacs-devel/2007-11/msg01638.html - (setq outwin (display-buffer outbuf)) + (unless (buffer-local-value 'compilation-dont-display-buffer outbuf) + (setq outwin (display-buffer outbuf))) (with-current-buffer outbuf (let ((process-environment (append @@ -1638,7 +1645,7 @@ (defun compilation-start (command &optional mode name-function highlight-regexp) (list command mode name-function highlight-regexp)) (set (make-local-variable 'revert-buffer-function) 'compilation-revert-buffer) - (set-window-start outwin (point-min)) + (and outwin (set-window-start outwin (point-min))) ;; Position point as the user will see it. (let ((desired-visible-point @@ -1647,15 +1654,16 @@ (defun compilation-start (command &optional mode name-function highlight-regexp) (point-max) ;; Normally put it at the top. (point-min)))) - (if (eq outwin (selected-window)) - (goto-char desired-visible-point) - (set-window-point outwin desired-visible-point))) + (when outwin + (if (eq outwin (selected-window)) + (goto-char desired-visible-point) + (set-window-point outwin desired-visible-point)))) ;; The setup function is called before compilation-set-window-height ;; so it can set the compilation-window-height buffer locally. (if compilation-process-setup-function (funcall compilation-process-setup-function)) - (compilation-set-window-height outwin) + (and outwin (compilation-set-window-height outwin)) ;; Start the compilation. (if (fboundp 'start-process) (let ((proc @@ -1977,6 +1985,7 @@ (defmacro define-compilation-mode (mode name doc &rest body) compilation-scroll-output compilation-search-path compilation-skip-threshold + compilation-dont-display-buffer compilation-window-height)) ,@body))) @@ -2487,14 +2496,16 @@ (defun compilation-goto-locus (msg mk end-mk) ;; the error location if the two buffers are in two ;; different frames. So don't do it if it's not necessary. pre-existing - (display-buffer (marker-buffer msg)))) + (unless compilation-dont-display-buffer + (display-buffer (marker-buffer msg))))) (highlight-regexp (with-current-buffer (marker-buffer msg) ;; also do this while we change buffer - (compilation-set-window w msg) + (and w (compilation-set-window w msg)) compilation-highlight-regexp))) ;; Ideally, the window-size should be passed to `display-buffer' ;; so it's only used when creating a new window. - (unless pre-existing (compilation-set-window-height w)) + (unless pre-existing + (and w (compilation-set-window-height w))) (if from-compilation-buffer ;; If the compilation buffer window was selected, @@ -2606,8 +2617,9 @@ (defun compilation-find-file (marker filename directory &rest formats) ;; The file doesn't exist. Ask the user where to find it. (save-excursion ;This save-excursion is probably not right. (let ((pop-up-windows t)) - (compilation-set-window (display-buffer (marker-buffer marker)) - marker) + (unless compilation-dont-display-buffer + (compilation-set-window (display-buffer (marker-buffer marker)) + marker)) (let* ((name (read-file-name (format "Find this %s in (default %s): " compilation-error filename) -- 1.8.1.1