The file you mention is where Eshell saves the directory ring, which is basically a list of the directories that you've visited. Just like in most shells, you can use cd -
to go back to the previous directory. cd =
will display the contents, and so on (see the Eshell manual for all the details). Eshell saves this list to a file so that you'll still have it in your next session, and Emacs will always prompt the user when it things the coding system might be incorrect. I can see how it would be frustrating that it asks you all the time about a file you're not specifically editing. One way to control the coding system that Emacs uses is by setting a file-local variable, which is why the error message mentions them. (I think "cookie" is an older term for it, which adds to the confusion.)
The code that saves the list is eshell-write-last-dir-ring
in em-dirs.el. As you can imagine, all it does is open a temporary buffer, insert every item in the list into the buffer, followed by a newline character, then write the buffer to the file. The error message itself comes from select-safe-coding-system
in mule-cmds.el, which is horrible. Seriously, don't look at it. I don't know why this function is so complex, but I assume that it "gradually got so" (to coin a phrase).
I don't know what the best way to fix this will be, but the first thing that select-safe-coding-system
does is compare the filename with the contents of the variable auto-coding-alist
. You could add an entry for this specific file, which sets the desired coding system to 'utf-8
. As you can see from the error message, the contents look to Emacs like utf-8, but it thought for some other reason that it should be saved in latin1. Editing auto-coding-alist
should fix that.
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)