Subject: bug#30529: 26.0.91; minibuffer errors change standard-output

From: Francis Wright <[email-masked]>
Date: Mon, 19 Feb 2018 16:04:26 +0000

A user-error in the minibuffer can change the value of standard-output
(to t) within the environment that invoked the minibuffer, whereas I
think the minibuffer should rebind standard-output locally and not
change its global value. Here is a simple way to illustrate this
problem. Evaluate the following:

(defun STANDARD-LISP ()
  "Run Standard LISP with input via the minibuffer and output via a buffer."
  (interactive)
  (switch-to-buffer (get-buffer-create "*Standard LISP*"))
  (let (value
		(standard-output (current-buffer)))
	(while t
	  (terpri)
	  (princ "Eval: ")
	  (setq value (read))
	  ;; (read) errors change standard-output to *Messages* buffer,
	  ;; so...
	  ;; (setq standard-output (current-buffer))
	  (prin1 value) (terpri)
	  (setq value (eval value))
	  (terpri)
	  (princ "====> ") (princ value) (terpri))))

Run the command STANDARD-LISP and type 'foo RETURN in the
minibuffer. The input and output related to 'foo appear correctly in the
buffer *Standard LISP*. Now, in the minibuffer, press the down arrow
key, thereby generating an end of history user-error, then type 'bar
RETURN. The input and output related to 'bar appear incorrectly in the
*Messages* buffer. A workaround is to include the assignment (setq
standard-output (current-buffer)) that is commented out in the function
above.

The distributed binary (i.e. not built by me) MS-Windows version of
Emacs 25.2 shows the same behaviour.

In GNU Emacs 26.0.91 (build 1, x86_64-w64-mingw32)
 of 2018-01-23 built on MONOLITH
Windowing system distributor 'Microsoft Corp.', version 10.0.16299
Recent messages:
Loading delsel...done
Loading paren...done
Starting new Ispell process c:/cygwin64/bin/aspell.exe with british dictionary...
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --prefix=/d/emacs/emacs-26.0.91 --without-imagemagick
 --without-dbus'

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS LCMS2

Important settings:
  value of $LANG: ENG
  locale-coding-system: cp1252

Major mode: Fundamental

Minor modes in effect:
  shell-dirtrack-mode: t
  show-paren-mode: t
  delete-selection-mode: t
  electric-pair-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  horizontal-scroll-bar-mode: t
  global-font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg gnus-util rmail rmail-loaddefs
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils flyspell ispell imenu tramp tramp-compat tramp-loaddefs
trampver ucs-normalize shell pcomplete comint ansi-color ring parse-time
format-spec advice paren delsel cus-start cus-load finder-inf info
package easymenu epg-config url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache url-vars seq
byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib elec-pair
server time-date mule-util tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel dos-w32 ls-lisp disp-table term/w32-win
w32-win w32-vars term/common-win tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame 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 minibuffer 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 w32notify w32 lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 247714 13662)
 (symbols 56 24342 1)
 (miscs 48 90 172)
 (strings 32 43228 1567)
 (string-bytes 1 1184180)
 (vectors 16 40381)
 (vector-slots 8 774164 15144)
 (floats 8 70 337)
 (intervals 56 304 39)
 (buffers 992 13))