Subject: 26.0.50; isearch-query-replace from regexp isearch doesn't add to replace-regexp history list

From: Richard Copley <[email-masked]>
Date: Fri, 4 Nov 2016 10:54:00 +0000

Recipe from emacs -Q:

 M-<            ;; beginning-of-buffer
 C-M-s text     ;; isearch-forward-regexp
 M-% xxx RET !  ;; isearch-query-replace
 C-M-%          ;; query-replace-regexp
 M-p            ;; previous-history-element

Expected result: selects the previous replace operation "text -> xxx"
from the history list.

Actual result: signals "user-error: Beginning of history; no preceding
item".

The bug affects isearch-query replace when invoked during
isearch-forward-regexp but not when invoked during isearch-forward.

The bug was introduced in the master branch between these two revisions
(not tight bounds, just builds I have lying around):

GOOD:
commit 7fa96cb5ef8c8464496688e88c1b97211a820d79
Author: Paul Eggert <[email-masked]>
Date:   Sat Sep 17 15:06:24 2016 -0700

BAD:
commit 9640e9f4e95cd95c04875e90a4ff638e1e51f977
Author: Tino Calancha <[email-masked]>
Date:   Tue Oct 11 11:47:32 2016 +0900

In GNU Emacs 26.0.50.1 (x86_64-w64-mingw32)
 of 2016-10-11 built on 60678UHB
Repository revision: 9640e9f4e95cd95c04875e90a4ff638e1e51f977
Windowing system distributor 'Microsoft Corp.', version 6.1.7601
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set [2 times]
Replaced 2 occurrences
user-error: Beginning of history; no preceding item
Quit
Configured using:
 'configure --prefix /C/emacs/emacs-20161011-024732 --with-modules
 --without-imagemagick --disable-dependency-tracking
 --enable-locallisppath=%emacs_dir%/../site-lisp CFLAGS=-O3
 CPPFLAGS=-D_WIN32_WINNT=_WIN32_WINNT_WIN7'

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

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

Major mode: Lisp Interaction

Minor modes in effect:
  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
  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:
None found.

Features:
(shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv
bytecomp byte-compile cl-extra help-mode cconv cl-loaddefs pcase cl-lib
dired dired-loaddefs format-spec rfc822 mml easymenu mml-sec
password-cache epa derived epg epg-config 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 thingatpt misearch multi-isearch 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 newcomment
elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow 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 charscript 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 dbusbind w32 multi-tty make-network-process emacs)

Memory information:
((conses 16 99599 14680)
 (symbols 56 20290 0)
 (miscs 48 45 149)
 (strings 32 19347 4182)
 (string-bytes 1 591428)
 (vectors 16 13522)
 (vector-slots 8 442624 4747)
 (floats 8 181 146)
 (intervals 56 247 16)
 (buffers 976 11))