Question

I have a finite list of symbols and I want to make an ido based user interface to select among them, but i also want this to be able to remember. What I came up with is this:

(defvar hist nil)
(ido-completing-read "What, ... is your favorite color? " '("red" "green" "blue") nil t nil 'hist)

But no matter how many times i choose green the colors seem to come up in the same order and hist remains nil. Can anyone help?

Was it helpful?

Solution

Elisp uses dynamic scoping, which means that variable names really matter. More specifically, in your case you have a naming conflict between your hist and the hist variable used by ido. Always use a <prefix>- thingy on global variables to avoid such problems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top