Subject: bug#17432: 24.4.50; minibuffer history forgets the first entry

From: BONSOFT Jaroslaw Czekalski <[email-masked]>
Date: Wed, 07 May 2014 10:56:08 +0200

Steps:
1. (read-from-minibuffer "pro: " nil nil nil 'hist)
2. type sth
3. check hist: M-S-: hist

Expected: sth, Actual: nil

The value is not properly initialized. Seems like r87775 introduced a
regression, because histval is not set to nil in minibuf.c.

Stefan, would you review the patch before I commit to emacs-24?

In GNU Emacs 24.4.50.9 (i686-pc-mingw32)
of 2014-05-07 on BONSOFTW7
Repository revision: 117068 [email-masked]
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
`configure --prefix=d:/program_files/emacs-master'

Configured features:
PNG NOTIFY ACL GNUTLS LIBXML2 ZLIB

Important settings:
value of $LANG: pl
locale-coding-system: cp1250

Major mode: Text

Minor modes in effect:
global-hl-line-mode: t
recentf-mode: t
tooltip-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
size-indication-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t

Recent input:
M-x r e p o r t <return> C-g C-x r l <C-end> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <return>
M-x r e p o r t <return>

Recent messages:
[yas] Loading compiled snippets from c:/Users/Jarek/AppData/Roaming/.emacs.d/snippets/text-mode
Loading c:/Users/Jarek/AppData/Roaming/.emacs.d/snippets/text-mode/.yas-compiled-snippets.el (source)...done
[yas] Loading snippet files from c:/Users/Jarek/AppData/Roaming/.emacs.d/snippets/text-mode
[yas] Loaded ~/.emacs.d/snippets
[yas] Reloaded everything....
Loading hl-line...done
Loading whitespace...done
Loading grep...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils grep compile comint ansi-color ring
whitespace hl-line cus-start cus-load xml-parse yasnippet derived
easy-mmode edmacro kmacro help-mode folding-isearch folding cl-macs
advice help-fns cl gv bookmark pp recentf tree-widget wid-edit
cl-loaddefs cl-lib easymenu server time-date tooltip electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp
w32-common-fns disp-table w32-win w32-vars tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer 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 make-network-process w32notify w32
multi-tty emacs)

Memory information:
((conses 8 157835 15374)
(symbols 24 22946 0)
(miscs 20 97 187)
(strings 16 24145 3764)
(string-bytes 1 696442)
(vectors 8 14513)
(vector-slots 4 435779 11182)
(floats 8 134 170)
(intervals 28 697 1027)
(buffers 508 15))

--

Jarosław Czekalski
www.BONSOFT.pl
tel. kom. 0 606 16 26 36 - osiągalny najpewniej w godzinach 8:00 - 9:00

BONSOFT Jarosław Czekalski - NIP 643-133-05-73 - REGON 277747017

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2014-05-06 21:13:37 +0000
+++ src/ChangeLog	2014-05-07 08:54:40 +0000
@@ -1,3 +1,8 @@
+2014-05-07  Jarek Czekalski  <[email-masked]>
+
+	Fix initialization of minibuffer history variable (Bug#xxxxx).
+	* minibuf.c (read_minibuf): Initialize histval to Qnil if unbound.
+
 2014-05-06  Paul Eggert  <[email-masked]>
 
 	* image.c: Do not use libpng if HAVE_NS, as NS does its own thing.

=== modified file 'src/minibuf.c'
--- src/minibuf.c	2014-03-21 17:04:50 +0000
+++ src/minibuf.c	2014-05-07 08:54:21 +0000
@@ -708,8 +708,10 @@
       /* If variable is unbound, make it nil.  */
 
       histval = find_symbol_value (Vminibuffer_history_variable);
-      if (EQ (histval, Qunbound))
-	Fset (Vminibuffer_history_variable, Qnil);
+      if (EQ (histval, Qunbound)) {
+        Fset (Vminibuffer_history_variable, Qnil);
+        histval = Qnil;
+      }
 
       /* The value of the history variable must be a cons or nil.  Other
 	 values are unacceptable.  We silently ignore these values.  */