From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: gmane.emacs.bugs Subject: bug#28892: 24.5; Allow multiple compilations to append to an existing compilation buffer Date: Wed, 18 Oct 2017 17:24:02 +0100 Message-ID: <50fef6222795c046dd7754a79d3508ac@ludovic-brenta.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1508347046 10716 195.159.176.226 (18 Oct 2017 17:17:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 18 Oct 2017 17:17:26 +0000 (UTC) User-Agent: Roundcube Webmail/0.5.3 To: 28892@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 18 19:17:21 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4rxw-0000xr-Qb for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Oct 2017 19:17:13 +0200 Original-Received: from localhost ([::1]:45715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4ry2-0007JU-Cr for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Oct 2017 13:17:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4rxs-0007H4-6t for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2017 13:17:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4rxm-0008Mo-W3 for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2017 13:17:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39860) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4rxm-0008Mf-Rv for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2017 13:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e4rxm-0000YQ-Il for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2017 13:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ludovic Brenta Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Oct 2017 17:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28892 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: Original-Received: via spool by submit@debbugs.gnu.org id=B.15083470112103 (code B ref -1); Wed, 18 Oct 2017 17:17:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Oct 2017 17:16:51 +0000 Original-Received: from localhost ([127.0.0.1]:48540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4rxa-0000Xq-Oh for submit@debbugs.gnu.org; Wed, 18 Oct 2017 13:16:51 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:48415) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4r8m-0007YP-Bv for submit@debbugs.gnu.org; Wed, 18 Oct 2017 12:24:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4r8g-0000sU-AI for submit@debbugs.gnu.org; Wed, 18 Oct 2017 12:24:15 -0400 Original-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 ) id 1e4r8g-0000sO-6g for submit@debbugs.gnu.org; Wed, 18 Oct 2017 12:24:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4r8e-00046q-Qc for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2017 12:24:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4r8Y-0000ph-Np for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2017 12:24:12 -0400 Original-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 ) id 1e4r8Y-0000n9-D2 for bug-gnu-emacs@gnu.org; Wed, 18 Oct 2017 12:24:06 -0400 Original-Received: by webmail.free.org (Postfix, from userid 5000) id C8CF4507A58C; Wed, 18 Oct 2017 18:24:02 +0200 (CEST) X-Sender: ludovic@ludovic-brenta.org Original-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-Mailman-Approved-At: Wed, 18 Oct 2017 13:16:49 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:138677 Archived-At: 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.