Skip to main content
added 45 characters in body
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

Do this:

(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)

(defun my-function (hist)
  (read-from-minibuffer "> " nil nil nil hist))

(defun my-command ()
  (interactive)
  (add-to-history 'my-hist (my-function 'my-hist)))

Don't quote hist when you pass it to read-from-minibuffer. You want to pass its value, e.g. the symbol my-hist, and not the result of evaluating 'hist, which is the symbol hist.

But I agree with you about using M-p etc. Function read-from-minibuffer apparently doesn't use the buffer-local value of the history variable - either for access or for updating (adding to it).

That would also explain why, to add to the buffer-local value you need to explicitly use add-to-history, passing the value of the input that was read.

Normally (i.e., if the history var is not buffer-local), you would just invoke (my-function 'my-hist) in my-command - read-from-minibuffer automatically adds the read input to the history variable. But doing that when the var is buffer-local doesn't update it.

Seems like a bug. But this is longstanding behavior (I see it back to Emacs 22, and I see the fact that it doesn't work without add-to-history even back to Emacs 20, which doesn't have add-to-history). So I'm probably missing something. Hopefully someone else will enlighten us.

(completing-read behaves the same way.)

Good question.

Do this:

(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)

(defun my-function (hist)
  (read-from-minibuffer "> " nil nil nil hist))

(defun my-command ()
  (interactive)
  (add-to-history 'my-hist (my-function 'my-hist)))

Don't quote hist when you pass it to read-from-minibuffer. You want to pass its value, e.g. the symbol my-hist, and not the result of evaluating 'hist, which is the symbol hist.

But I agree with you about using M-p etc. Function read-from-minibuffer apparently doesn't use the buffer-local value of the history variable - either for access or for updating (adding to it).

That would also explain why, to add to the buffer-local value you need to explicitly use add-to-history, passing the value of the input that was read.

Normally (i.e., if the history var is not buffer-local), you would just invoke (my-function 'my-hist) in my-command - read-from-minibuffer automatically adds the read input to the history variable. But doing that when the var is buffer-local doesn't update it.

Seems like a bug. But this is longstanding behavior (I see it back to Emacs 22, and I see the fact that it doesn't work without add-to-history even back to Emacs 20, which doesn't have add-to-history). So I'm probably missing something. Hopefully someone else will enlighten us.

Good question.

Do this:

(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)

(defun my-function (hist)
  (read-from-minibuffer "> " nil nil nil hist))

(defun my-command ()
  (interactive)
  (add-to-history 'my-hist (my-function 'my-hist)))

Don't quote hist when you pass it to read-from-minibuffer. You want to pass its value, e.g. the symbol my-hist, and not the result of evaluating 'hist, which is the symbol hist.

But I agree with you about using M-p etc. Function read-from-minibuffer apparently doesn't use the buffer-local value of the history variable - either for access or for updating (adding to it).

That would also explain why, to add to the buffer-local value you need to explicitly use add-to-history, passing the value of the input that was read.

Normally (i.e., if the history var is not buffer-local), you would just invoke (my-function 'my-hist) in my-command - read-from-minibuffer automatically adds the read input to the history variable. But doing that when the var is buffer-local doesn't update it.

Seems like a bug. But this is longstanding behavior (I see it back to Emacs 22, and I see the fact that it doesn't work without add-to-history even back to Emacs 20, which doesn't have add-to-history). So I'm probably missing something. Hopefully someone else will enlighten us.

(completing-read behaves the same way.)

Good question.

added 648 characters in body
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

Do this:

(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)

(defun my-function (hist)
  (read-from-minibuffer "> " nil nil nil hist))

(defun my-command ()
  (interactive)
  (add-to-history 'my-hist (my-function 'my-hist)))

Don't quote hist when you pass it to read-from-minibuffer. You want to pass its valuevalue, e.g. the symbol my-hist, and not the result of evaluating 'hist, which is the symbol hist.

But I agree with you about using M-p etc. Function read-from-minibuffer apparently doesn't use the buffer-local value of the history variable - either for access or for updating (adding to it). 

That would also explain why, to add to the buffer-local value you need to explicitly use add-to-history, passing the value of the input that was read. Normally

Normally (i.e., if the history var is not buffer-local), you would just invoke (my-function 'my-hist) in my-command - read-from-minibuffer automatically adds the read input to the history variable. But doing that when the var is buffer-local doesn't update it.

SoundsSeems like a bug, but. But this is longstanding behavior (I see it back to Emacs 22, soand I see the fact that it doesn't work without add-to-history even back to Emacs 20, which doesn't have add-to-history). So I'm probably missing something. Hopefully someone else will enlighten us. 

Good question.

Do this:

(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)

(defun my-function (hist)
  (read-from-minibuffer "> " nil nil nil hist))

(defun my-command ()
  (interactive)
  (add-to-history 'my-hist (my-function 'my-hist)))

Don't quote hist when you pass it to read-from-minibuffer. You want to pass its value, e.g. the symbol my-hist, and not the result of evaluating 'hist, which is the symbol hist.

But I agree with you about using M-p etc. read-from-minibuffer apparently doesn't use the buffer-local value of the history variable. That would also explain why, to add to the buffer-local value you need to explicitly use add-to-history, passing the value of the input that was read. Normally (i.e., if the history var is not buffer-local), you would just invoke (my-function 'my-hist) in my-command - read-from-minibuffer automatically adds the read input to the history variable.

Sounds like a bug, but this is longstanding behavior, so I'm probably missing something. Hopefully someone else will enlighten us. Good question.

Do this:

(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)

(defun my-function (hist)
  (read-from-minibuffer "> " nil nil nil hist))

(defun my-command ()
  (interactive)
  (add-to-history 'my-hist (my-function 'my-hist)))

Don't quote hist when you pass it to read-from-minibuffer. You want to pass its value, e.g. the symbol my-hist, and not the result of evaluating 'hist, which is the symbol hist.

But I agree with you about using M-p etc. Function read-from-minibuffer apparently doesn't use the buffer-local value of the history variable - either for access or for updating (adding to it). 

That would also explain why, to add to the buffer-local value you need to explicitly use add-to-history, passing the value of the input that was read.

Normally (i.e., if the history var is not buffer-local), you would just invoke (my-function 'my-hist) in my-command - read-from-minibuffer automatically adds the read input to the history variable. But doing that when the var is buffer-local doesn't update it.

Seems like a bug. But this is longstanding behavior (I see it back to Emacs 22, and I see the fact that it doesn't work without add-to-history even back to Emacs 20, which doesn't have add-to-history). So I'm probably missing something. Hopefully someone else will enlighten us. 

Good question.

added 648 characters in body
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

Do this:

(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)

(defun my-function (hist)
  (read-from-minibuffer "> " nil nil nil hist))

(defun my-command ()
  (interactive)
  (add-to-history 'my-hist (my-function 'my-hist)))

Don't quote hist when you pass it to read-from-minibuffer. You want to pass its value, e.g. the symbol my-hist, and not the result of evaluating 'hist, which is the symbol hist.

But I agree with you about using M-p etc. read-from-minibuffer apparently doesn't use the buffer-local value of the history variable. That would also explain why, to add to the buffer-local value you need to explicitly use add-to-history, passing the value of the input that was read. Normally (i.e., if the history var is not buffer-local), you would just invoke (my-function 'my-hist) in my-command - read-from-minibuffer automatically adds the read input to the history variable.

Sounds like a bug, but this is longstanding behavior, so I'm probably missing something. Hopefully someone else will enlighten us. Good question.

Do this:

(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)

(defun my-function (hist)
  (read-from-minibuffer "> " nil nil nil hist))

(defun my-command ()
  (interactive)
  (add-to-history 'my-hist (my-function 'my-hist)))

Don't quote hist when you pass it to read-from-minibuffer. You want to pass its value, e.g. the symbol my-hist, and not the result of evaluating 'hist, which is the symbol hist.

Do this:

(defvar my-hist nil)
(make-variable-buffer-local 'my-hist)

(defun my-function (hist)
  (read-from-minibuffer "> " nil nil nil hist))

(defun my-command ()
  (interactive)
  (add-to-history 'my-hist (my-function 'my-hist)))

Don't quote hist when you pass it to read-from-minibuffer. You want to pass its value, e.g. the symbol my-hist, and not the result of evaluating 'hist, which is the symbol hist.

But I agree with you about using M-p etc. read-from-minibuffer apparently doesn't use the buffer-local value of the history variable. That would also explain why, to add to the buffer-local value you need to explicitly use add-to-history, passing the value of the input that was read. Normally (i.e., if the history var is not buffer-local), you would just invoke (my-function 'my-hist) in my-command - read-from-minibuffer automatically adds the read input to the history variable.

Sounds like a bug, but this is longstanding behavior, so I'm probably missing something. Hopefully someone else will enlighten us. Good question.

Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257
Loading