command-linereadlinechicken-scheme

readline history not working


Okay, so Chicken-scheme has this great readline egg that can be used to add history, tab completion, and other sane features to the csi command-line environment. However, I can't seem to get it to work correctly, that is it only works the first time I start csi up after creating a new history file.

I've checked the documentation for the egg and other similar eggs such as linenoise and parley, but neither of them offer tab-completion or any advice on how to address this shortcoming of readline.

Here's the code I'm working with:

(current-input-port (make-gnu-readline-port))
(gnu-history-install-file-manager
  (string-append (or (get-environment-variable "HOME") ".") "/.csi_history"))

NOTE

While writing this I think I may have figured out the problem or at least part of the problem. The problem, I think, lies in the fact that I'm installing a history file; as in it only works for the first installation?

However, my attempt to cook my own readline file-manager setup makes it so that gnu readline never writes to the history file, however, it will read from it.

(current-input-port (make-gnu-readline-port))
(let ((histfile (string-append (or (get-environment-variable "HOME") ".")
  "/.csi_history")))
  (and (file-exists? histfile) (gnu-readline-read-history histfile))
  (gnu-readline-append-history histfile))

Has anyone else encountered this problem?


Solution

  • Turns out that in my ~/.zshrc file I had an alias for csi that called csi with rlwrap:

    alias csi='rlwrap csi'
    

    Calling rlwrap on csi was causing csi to use rlwrap's history instead of the built-in history provided by the readline egg.