Subject: bug#42922: 27.1; shell-command-dont-erase-buffer not honored when the existing shell buffer is remote

From: Sean McAfee <[email-masked]>
Date: Tue, 18 Aug 2020 14:50:14 -0700

Starting from emacs -Q:

Set the variable shell-command-dont-erase-buffer to a true value, say
end-last-out.

Run an asynchronous shell command: M-& echo foo RET

The buffer *Async Shell Command* appears, showing the word "foo".

Run another async command: M-& echo bar RET

The word "bar" is appended on a new line in the existing async shell
command buffer, as expected.

Change to that buffer, and cd to any remote directory:
M-x cd RET /ssh:remote: RET

Run another async command, to be executed in the remote directory:
M-& echo baz RET

Now the word "baz" entirely replaces the contents of the buffer, instead
of being appended on a new line.

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2020-08-18 built on SeanMc
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 18.04.5 LTS

Recent messages:
Loading /home/mcafee/.emacs-custom.el (source)...done
Waiting for git... [2 times]
Iedit default key binding is C-;
Loading /home/mcafee/emacs/laptop.el (source)...done
Package cl is deprecated
Warning: desktop file appears to be in use by PID 15481.
Using it may cause conflicts.  Use it anyway? (y or n) n
Desktop file in use; not loaded.
Turning on magit-auto-revert-mode...done
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY
ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  volatile-highlights-mode: t
  projectile-mode: t
  elisp-slime-nav-mode: t
  global-magit-file-mode: t
  magit-auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  shell-dirtrack-mode: t
  google-this-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  minibuffer-depth-indicate-mode: t
  ido-vertical-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  paredit-mode: t
  override-global-mode: t
  desktop-save-mode: t
  winner-mode: t
  show-paren-mode: t
  electric-pair-mode: t
  savehist-mode: t
  ido-everywhere: t
  cl-old-struct-compat-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-mode: t
  prettify-symbols-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
~/emacs/ack hides /home/mcafee/.emacs.d/elpa/ack-1.10/ack
~/emacs/chinese hides /home/mcafee/emacs-27.1/lisp/language/chinese
~/emacs/japanese hides /home/mcafee/emacs-27.1/lisp/language/japanese
/home/mcafee/.emacs.d/elpa/seq-20151121.1017/seq hides
/home/mcafee/emacs-27.1/lisp/emacs-lisp/seq

Features:
(shadow sort mail-extr emacsbug sendmail vterm vterm-module dired-launch
calfw-cal calfw holidays hol-loaddefs cal-menu calendar cal-loaddefs
xref-js2 vc vc-dispatcher js2-mode-expansions js2-mode
js-mode-expansions js cc-mode-expansions cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
dired-ranger dired-filter f s dired-hacks-utils dired-aux dired-x
shell-pop term disp-table ehelp beginend volatile-highlights iedit
iedit-lib multiple-cursors-core rect dtrt-indent tramp-cache tramp-sh
tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat
parse-time iso8601 ls-lisp projectile grep ibuf-ext ibuffer
ibuffer-loaddefs elisp-slime-nav etags fileloop generator xref project
magit-submodule magit-obsolete magit-popup magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit magit-repos magit-apply magit-wip magit-log
which-func imenu magit-diff smerge-mode diff-mode magit-core
magit-autorevert autorevert filenotify magit-margin magit-transient
magit-process magit-mode git-commit transient magit-git magit-section
magit-utils crm log-edit message rmc puny format-spec rfc822 mml mml-sec
epa epg epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader pcvs-util add-log with-editor
async-bytecomp async shell pcomplete server ido-completing-read+ memoize
cus-edit cus-start cus-load minibuf-eldef google-this flycheck find-func
diminish gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045
ietf-drums text-property-search time-date mail-utils mm-util mail-prsvr
wid-edit pcase autoinsert misc sanityinc-tomorrow-blue-theme
color-theme-sanityinc-tomorrow color mb-depth ido-vertical-mode
dired-details+ dired dired-loaddefs dired-details change-inner
expand-region text-mode-expansions er-basic-expansions
expand-region-core expand-region-custom undo-tree diff ack derived
compile paredit dash cl-extra help-mode use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core desktop frameset finder-inf winner paren
elec-pair savehist url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util mailcap hippie-exp comint
ansi-color ring thingatpt perl-mode ido anchored-transpose-autoloads
apt-utils-autoloads dired-details-autoloads edmacro kmacro fix-word
highlight-tail-autoloads advice rx slime-autoloads cl w3m-load info
package easymenu browse-url url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 590751 25411)
 (symbols 48 39337 5)
 (strings 32 186612 5278)
 (string-bytes 1 5596669)
 (vectors 16 57561)
 (vector-slots 8 684501 36918)
 (floats 8 307 46)
 (intervals 56 447 115)
 (buffers 1000 11))