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

Previous Next

Package: emacs;

Reported by: Ludovic Brenta <ludovic <at> ludovic-brenta.org>

Date: Wed, 18 Oct 2017 17:17:02 UTC

Severity: wishlist

Found in version 24.5

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 28892 in the body.
You can then email your comments to 28892 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#28892; Package emacs. (Wed, 18 Oct 2017 17:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Brenta <ludovic <at> ludovic-brenta.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 18 Oct 2017 17:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Brenta <ludovic <at> ludovic-brenta.org>
To: <bug-gnu-emacs <at> gnu.org>
Subject: 24.5; Allow multiple compilations to append to an existing compilation
 buffer
Date: Wed, 18 Oct 2017 17:24:02 +0100
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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#28892; Package emacs. (Tue, 17 May 2022 20:09:02 GMT) Full text and rfc822 format available.

Message #8 received at 28892 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Ludovic Brenta <ludovic <at> ludovic-brenta.org>
Cc: 28892 <at> debbugs.gnu.org
Subject: Re: bug#28892: 24.5; Allow multiple compilations to append to an
 existing compilation buffer
Date: Tue, 17 May 2022 22:07:57 +0200
Ludovic Brenta <ludovic <at> ludovic-brenta.org> writes:

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

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I've now added this to Emacs 29 -- a new parameter:

+If CONTINUE is non-nil, the buffer won't be emptied before
+compilation is started.  This can be useful if you wish to
+combine the output from several compilation commands in the same
+buffer.  The new output will be at the end of the buffer, and
+point is not changed.


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 28892 <at> debbugs.gnu.org and Ludovic Brenta <ludovic <at> ludovic-brenta.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 17 May 2022 20:09:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 15 Jun 2022 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 313 days ago.

Previous Next


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