Subject: bug#38317: Buffer-local variables don't work as history for read-from-minibuffer

From: Federico Tedin <[email-masked]>
Date: Sat, 23 Nov 2019 21:36:10 +0100

I've been looking into the problem, what I found so far is:

`read-from-minibuffer' works normally if HIST is not buffer-local.

If HIST is buffer-local, then the history variable doesn't seem to be
updated correctly after returning (so using M-p and M-n doesn't do
anything).

My test was:

(setq test-history nil)
(make-variable-buffer-local 'test-history)

(read-from-minibuffer "" nil nil nil 'test-history)

After running that and inputting "hello", I checked:

(buffer-local-value 'test-history (current-buffer))            ;; -> nil
(buffer-local-value 'test-history (get-buffer " *Minibuf-0*")) ;; -> nil
(buffer-local-value 'test-history (get-buffer " *Minibuf-1*")) ;; -> nil

So although `read_minibuf' does call `add-to-history' before returning
(and after setting the current buffer to be the minibuffer's), my input
wasn't added to any list (that I know of). This is strange, since
`add-to-history' seemed to work correctly with buffer-local variables
when I tested it separately. I would've expected the new history item to
be added to one of the minibuffer's `test-history' local variable.

So I think the first step would be to make `read_minibuf' add the new
history item into the right place when HIST is buffer-local.