Subject: 24.4: read-from-minibuffer improperly setting hist parameter

From: Boruch Baum <[email-masked]>
Date: Sun, 08 Mar 2015 18:25:39 -0400

This started out as a bug report for function `toggle-option' in file
toggle-option.el. That function takes a user-defined list of options
through which the user can scroll in the minibuffer. However, the
scrolling only operates in the forward direction (using the down-arrow
key); When scrolling in the reverse direction (using the up-arrow key),
one gets elements from some other history list, which are mostly items
invalid for the function called, and in fact are correctly rejected by
the function (toggle-option) if one selects them.

Function `toggle-option' calls `completing-read', without providing
parameters REQUIRE-MATCH or HIST. `completing-read' calls
`completing-read-default' in `minibuffer.el'. `completing-read-default'
calls `read-from-minibuffer' in `minibuf.c'. There, on line 974 of
`minibuf.c:'

     if (NILP (histvar))
       histvar = Qminibuffer_history;

If I understand this correctly, this says that even if the caller
explicitly says that there should be no history used (condition nil),
the Qminibuffer_history should be used anyway.

Correcting this looks like it would solve other bugs reported (eg. bug
#19877).

BTW, I fiddled with function `toggle-option', and even when all the
optional parameters are explicitly passed with nil values, the behavior
remains the same.

BTBTW, `read-from-minibuffer' calls `read-minibuf' which calls
`read_minibuf_noninteractive' (line 223 in minibuf.c), which asks for
parameters it does not use: map, initial, backup_n, histvar, histpos,
allow_props, and inherit_input_method (BTBTBTW, courtesy of the spelling
police, unless 'default' is a reserved word, parameter 'defalt' might
properly be refactored `default').

Finally, my two cents are that when functions ask for parameter
COLLECTION to scroll through, that scrolling should wrap-around, and not
report an error when reaching the first or final entry.

-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0