I've been trying to create a command that, when run, calls another function (my-function
) which reads from the minibuffer and does some processing on the input. I want the command history for this command (my-command
) to be buffer-local, so that each buffer will have a separate input history.
The input history is supposed to be stored in variable my-hist
. Here's a summarized version of my code:
;; -*- lexical-binding: t; -*-
(defun my-function (hist)
(read-from-minibuffer "> " nil nil nil 'hist))
(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)
(defun my-command ()
(interactive)
(add-to-history 'my-hist (my-function 'my-hist)))
I've found that after executing my-command
from two different buffers, their input history is shared, for some reason. Using M-p
and M-n
I can go back and forwards through all the inputs I've entered from any of the two buffers. However, if I inspect my-hist
using M-:
, the input history appears to be correct for each buffer.
Could this be related to how read-from-minibuffer
looks up the value pointed at by symbol 'hist
?