Subject: bug#7513: 24.0.50; shell-command-default-error-buffer should always append to the bottom

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 21 Aug 2019 15:05:36 -0700

[email-masked] writes:

> (info "(emacs) Single Shell") and
> (describe-variable 'shell-command-default-error-buffer)
> should mention that the errors accumulate in that buffer, and are not
> wiped clean at each new command. Also mention they are separate by
> form-feeds (^L).
>
> Also the main reason I'm writing this bug report is currently
>      `M-!' and `M-|' insert error output before point in that buffer.
> But that often leads to jumbled output. They should always append to the
> bottom! Like the view-echo-area-messages *Message* buffer.

Yes, the output in that buffer as it stands isn't very useful, I think.
However, great care has been taken to try to insert the error message
wherever point is, and restoring the buffer:

                (with-current-buffer (get-buffer-create error-buffer)
                  (let ((pos-from-end (- (point-max) (point))))
                    (or (bobp)
                        (insert "\f\n"))
                    ;; Do no formatting while reading error file,
                    ;; because that can run a shell command, and we
                    ;; don't want that to cause an infinite recursion.
                    (format-insert-file error-file nil)
                    ;; Put point after the inserted errors.
                    (goto-char (- (point-max) pos-from-end)))
                  (display-buffer (current-buffer))))

I looked at the commit history, and it doesn't seem to explain why we
don't just append:

commit cc039f78e544719115e277364378c217156c958f
Author: Karl Heuer <[email-masked]>
Date:   Mon Mar 1 03:19:32 1999 +0000

    (shell-command-default-error-buffer): Renamed from
    shell-command-on-region-default-error-buffer.
    (shell-command-on-region): Mention in echo area when there
    is some error output.  Mention success or failure, too.
    Accumulate multiple error outputs
    going forward, with formfeed in between.  Display the error buffer
    when we have put something in it.

Does anybody object to rewriting it to just append the error messages to
the end of the buffer?

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