GNU bug report logs - #28892
24.5; Allow multiple compilations to append to an existing compilation buffer

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Ludovic Brenta <ludovic@HIDDEN>; dated Wed, 18 Oct 2017 17:17:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Oct 2017 17:16:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 18 13:16:51 2017
Received: from localhost ([127.0.0.1]:48540 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e4rxa-0000Xq-Oh
	for submit <at> debbugs.gnu.org; Wed, 18 Oct 2017 13:16:51 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48415)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludovic@HIDDEN>) id 1e4r8m-0007YP-Bv
 for submit <at> debbugs.gnu.org; Wed, 18 Oct 2017 12:24:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludovic@HIDDEN>) id 1e4r8g-0000sU-AI
 for submit <at> debbugs.gnu.org; Wed, 18 Oct 2017 12:24:15 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:46494)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <ludovic@HIDDEN>)
 id 1e4r8g-0000sO-6g
 for submit <at> debbugs.gnu.org; Wed, 18 Oct 2017 12:24:14 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39373)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <ludovic@HIDDEN>) id 1e4r8e-00046q-Qc
 for bug-gnu-emacs@HIDDEN; Wed, 18 Oct 2017 12:24:13 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ludovic@HIDDEN>) id 1e4r8Y-0000ph-Np
 for bug-gnu-emacs@HIDDEN; Wed, 18 Oct 2017 12:24:12 -0400
Received: from rmap1.bookmyname.com ([88.191.249.149]:52530
 helo=webmail.free.org) by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <ludovic@HIDDEN>) id 1e4r8Y-0000n9-D2
 for bug-gnu-emacs@HIDDEN; Wed, 18 Oct 2017 12:24:06 -0400
Received: by webmail.free.org (Postfix, from userid 5000)
 id C8CF4507A58C; Wed, 18 Oct 2017 18:24:02 +0200 (CEST)
To: <bug-gnu-emacs@HIDDEN>
Subject: 24.5; Allow multiple compilations to append to an existing compilation
 buffer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8;
 format=flowed
Content-Transfer-Encoding: 7bit
Date: Wed, 18 Oct 2017 17:24:02 +0100
From: Ludovic Brenta <ludovic@HIDDEN>
Message-ID: <50fef6222795c046dd7754a79d3508ac@HIDDEN>
X-Sender: ludovic@HIDDEN
User-Agent: Roundcube Webmail/0.5.3
X-Complaints-To: abuse_at_bookmyname.com
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Origin-Web-Site: webmail.bookmyname.com
X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 18 Oct 2017 13:16:49 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

Severity: wishlist

There are use cases for compilation-mode that would benefit from an
"append" feature.  For example, M-x grep places results in a *grep*
compilation buffer and it would be nice to be able to start a new grep
command that appends to the same buffer.

We use this for cross-references emitted by gnatfind (part of the GNU 
Ada
compiler suite) in a buffer named *gnatfind*.  We would like to be able 
to
call gnatfind with a prefix argument to append new references to this
buffer, without moving point in the *gnatfind* buffer.

Currently, compilation-start unconditionally empties the compilation
buffer before doing anything.

I have a crude workaround consisting in starting the new gnatfind
compilation in a new temporary buffer (created with
generate-new-buffer-name), waiting for the compilation to finish, and
finally, in a compilation-finished-functions hook, appending the 
contents
of the temporary buffer to the *gnatfind* buffer.  This has drawbacks:

* compilation-start raises the new *gnatfind*<2> buffer before starting
   the compilation, disrupting any browsing the user was doing in
   *gnatfind*;

* the new contents are added to *gnatfind* only after the compilation
   finishes

So I think some adjustments to compilation-start (i.e. a new argument)
would be necessary for a full solution.

For the record here is my current workaround:

(defun ada-gnat-xref-all (identifier file line col local-only append)
   "For `ada-xref-all-function'."
   (let* ((arg (ada-gnat-xref-common-args identifier file line col)))
     (setq arg (cons "-r" arg))
     (when local-only (setq arg (append arg (list file))))

     (with-current-buffer (gnat-run-buffer); for default-directory
       (let* ((compilation-buffer-name "*gnatfind*")
              (compilation-error "reference")
              (command-and-args (mapconcat (lambda (a) (or a ""))
                                           (cons 
(ada-gnat-xref-common-cmd) arg)
                                           " "))
              (gnatfind-buffer (get-buffer-create 
compilation-buffer-name))
              (saved-compilation-finish-functions 
compilation-finish-functions))
	;; compilation-environment is buffer-local; don't set in 'let'
	(setq compilation-environment (ada-prj-get 'proc_env))

	;; WORKAROUND: the 'compilation' API doesn't let us specify "append", 
so we use this.
         (add-hook 'compilation-finish-functions
                   (lambda (compilation-finished-buffer 
compilation-result)
                     (if append
                         (with-current-buffer gnatfind-buffer
                           (let ((inhibit-read-only t)
                                 (prev-pos (point)))
                             (goto-char (point-max))
                             (insert "\n")
                             (insert-buffer-substring 
compilation-finished-buffer)
                             (goto-char prev-pos)
                             (kill-buffer compilation-finished-buffer)))
                       ;; else
                       (progn
                         (kill-buffer gnatfind-buffer)
                         (with-current-buffer 
compilation-finished-buffer
                           (rename-buffer compilation-buffer-name))))
                     (setq compilation-finish-functions
                        saved-compilation-finish-functions)))

         ;; Now start the compilation in a new temporary buffer.
         (compilation-start command-and-args
                            'compilation-mode
                            (lambda (_name)
                              ;; If the result starts with a space, the 
buffer
                              ;; is hidden but no fontification occurs 
in it, so we
                              ;; return a name for a visible buffer.
                              (generate-new-buffer-name 
compilation-buffer-name)))))))


-- 
Ludovic Brenta.




Acknowledgement sent to Ludovic Brenta <ludovic@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#28892; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.