From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Liu Newsgroups: gmane.emacs.bugs Subject: bug#13594: 24.2.92; [PATCH] compilation-start doesn't consider nil OUTWIN Date: Tue, 05 Feb 2013 18:58:18 +0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1360061941 31820 80.91.229.3 (5 Feb 2013 10:59:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Feb 2013 10:59:01 +0000 (UTC) Cc: 13594@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 05 11:59:20 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U2gFC-0005Qc-M0 for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Feb 2013 11:59:18 +0100 Original-Received: from localhost ([::1]:57394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2gEu-0004kn-5J for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Feb 2013 05:59:00 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2gEp-0004kU-8H for bug-gnu-emacs@gnu.org; Tue, 05 Feb 2013 05:58:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U2gEn-0005Uj-6N for bug-gnu-emacs@gnu.org; Tue, 05 Feb 2013 05:58:55 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2gEn-0005UZ-07 for bug-gnu-emacs@gnu.org; Tue, 05 Feb 2013 05:58:53 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1U2gFu-0003qb-Ho for bug-gnu-emacs@gnu.org; Tue, 05 Feb 2013 06:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Leo Liu Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Feb 2013 11:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13594 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 13594-submit@debbugs.gnu.org id=B13594.136006198214736 (code B ref 13594); Tue, 05 Feb 2013 11:00:02 +0000 Original-Received: (at 13594) by debbugs.gnu.org; 5 Feb 2013 10:59:42 +0000 Original-Received: from localhost ([127.0.0.1]:37182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U2gFZ-0003pc-EV for submit@debbugs.gnu.org; Tue, 05 Feb 2013 05:59:42 -0500 Original-Received: from mail-pa0-f42.google.com ([209.85.220.42]:56952) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U2gFX-0003pV-89 for 13594@debbugs.gnu.org; Tue, 05 Feb 2013 05:59:40 -0500 Original-Received: by mail-pa0-f42.google.com with SMTP id kq12so78725pab.1 for <13594@debbugs.gnu.org>; Tue, 05 Feb 2013 02:58:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:references:face:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=j+NclRSohvvamKtkWNFDd/BzSdrqYz3Gb998I0mZFeQ=; b=KMPjP/6UnFNXkqp5lm66oqL0PlmXT/tgUU6D8COpu+lbdhV+5djBBSzxIdcEyFt5js 1wbe1Card4mDiGKOOg25ReiZckrhEDFmGiQRJZUdBl9SSfq58rG7bKshxV/DbW7d9RC1 MuWC6R5hTtVlyx2giIuhaWqEDQbAiZpOm9DXxauctYqkxSM24YRClWeBjezKTNEff7yY xz4pzen/mnvdgXKjK5TnGdBhCqp7tOyOxReNiFK2plSisO7A0dG7EdeXattK+rLORCYM NXe8hqahfpXCCW5RBbb4ZE4YnrwQylFmA97tUCPDdqOlQ1gMYimYUasFhvMPumnoVp1D A9Hw== X-Received: by 10.66.84.232 with SMTP id c8mr63428313paz.8.1360061908647; Tue, 05 Feb 2013 02:58:28 -0800 (PST) Original-Received: from Shidais-iMac.local ([119.255.41.66]) by mx.google.com with ESMTPS id m3sm28521882pav.4.2013.02.05.02.58.24 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 05 Feb 2013 02:58:26 -0800 (PST) Face: iVBORw0KGgoAAAANSUhEUgAAACgAAAAoBAMAAAB+0KVeAAAAGFBMVEUzRVhbQj4eZqO6SjnT eWpxnMetm5b6/PmidmqrAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1F B9cBBwMLBfKABCMAAAFoSURBVCjPtZI9a8MwEIaFoc7aYDdelQMna0Em3tsSr0XUeE2Q6a22a+v+ fk8fSSBkbDUI6dHpfe9OEvRgiD+ApqKPJgJeB6iUUXWESjUe/ig38AJrhqqvaU2nTIXbNvOQ40fe qdry4kyGoVWsfCQalXpHnJGM01wjWdYbMlXNFdsZDO69m9aqNqxEJqTEgbM5OF7wlEfIoll1Ked4 LbM5X2EdILLokEdmI8z7g5cKED0cuTC930TYhy7ZDekkXVGw/L60TguJePPxcJF48lpsSUWEA/Ju jGFNgJOXc4Hz7TmAdBeu5Ve4AEjOi2/2jfd3cAJZ+IbNrvdjgBZY01b+HTuG3cLws6BJZqVOj/pp T0OqVwx3rFq+QmJwx3loK5JSLEhDIt62+mtC2C+SrAUxEbV6C6v2BRbd6pILBKFpepKZJHgGgrKF sptSUUoczpwg2pQ7ZH1tgs0ou/917mzz6Cs2//C978cv5l07L02orIEAAAAASUVORK5CYII= In-Reply-To: (Stefan Monnier's message of "Thu, 31 Jan 2013 10:14:13 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.92 (OS X 10.8.2) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:70712 Archived-At: --=-=-= Content-Type: text/plain Hi Stefan, On 2013-01-31 23:14 +0800, Stefan Monnier wrote: > So maybe the best approach is to extend compile.el such that it can be > told to do its job without displaying the compilation buffer. If you do > that, try to take into account that this usage pattern could be useful > in other contexts than ggtags.el, for example users might prefer to not > see the compilation buffer and just be moved to the first error > automatically, and have C-x ` output the error message in the echo area > (maybe, accompanied by the number of errors left). The attached two patches (against emacs-24) implement: 1. A new variable compilation-dont-display-buffer to prevent calling display-buffer. 2. Display a message when calling compilation-next-error like this: Error: 2/623 Thanks for comments. Leo --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-variable-compilation-dont-display-buffer.patch >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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-Display-current-error-rank-total.patch >From 014240765570257fd5c8499d78d1eae8149df756 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Tue, 5 Feb 2013 18:48:28 +0800 Subject: [PATCH 2/2] Display current error rank/total --- lisp/progmodes/compile.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 8b5e3a81..0c3265ce 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -136,7 +136,7 @@ (defvar compilation-error "error" (defvar compilation-arguments nil "Arguments that were given to `compilation-start'.") -(defvar compilation-num-errors-found) +(defvar compilation-num-errors-found 0) ;; If you make any changes to `compilation-error-regexp-alist-alist', ;; be sure to run the ERT test in test/automated/compile-tests.el. @@ -895,9 +895,9 @@ (cl-defstruct (compilation--message (:constructor nil) (:copier nil) ;; (:type list) ;Old representation. - (:constructor compilation--make-message (loc type end-loc)) + (:constructor compilation--make-message (loc type end-loc &optional rank)) (:conc-name compilation--message->)) - loc type end-loc) + loc type end-loc rank) (defvar compilation--previous-directory-cache nil "A pair (POS . RES) caching the result of previous directory search. @@ -1181,8 +1181,11 @@ (defun compilation-internal-error-properties (file line end-line col end-col typ end-marker)))) ;; Must start with face + (setq-local compilation-num-errors-found + (1+ compilation-num-errors-found)) `(font-lock-face ,compilation-message-face - compilation-message ,(compilation--make-message loc type end-loc) + compilation-message ,(compilation--make-message + loc type end-loc compilation-num-errors-found) help-echo ,(if col "mouse-2: visit this file, line and column" (if line @@ -2281,8 +2284,12 @@ (defun compilation-next-error (n &optional different-file pt) (compilation-loop < previous-single-property-change 1+ "Moved back before first %s" (point-min)))) (goto-char pt) - (or msg - (error "No %s here" compilation-error)))) + (when msg + (message "%s: %s of %s" + (capitalize compilation-error) + (compilation--message->rank msg) + compilation-num-errors-found)) + (or msg (error "No %s here" compilation-error)))) (defun compilation-previous-error (n) "Move point to the previous error in the compilation buffer. -- 1.8.1.1 --=-=-=--