Search code examples
clojureclojurescriptread-eval-print-loopcidershadow-cljs

Is there a way to store and retrieve the history of shadow-cljs' REPL over different sessions? How to use commands used in previous sessions?


I am using Emacs, CIDER, and shadow-clj/shadow-cljs to develop a project in Clojure/ClojureScript. All this in a macOS Monterey 12.5.

Before that, I was used to programming with Emacs, Slime, Common Lisp, and SBCL. Sometimes, I want to have a similar UX in this new lisp environment similar to my previous experience on the other lisp land.

I am having multiple hassles (as expected) and pains with the new environment. One thing, in particular, has been quite annoying.

After executing cider-jack-in-cljs, shadow-cljs, shadow (REPL), and app (for the build), the REPL does not "remember" the previous session. I can't access the commands that I executed before quitting. It only remembers the commands executed on the current session. This is hindering my interactive programming productivity.

In Slime, this was possible! And quite handy.

Moreover, after executing describe-mode in Emacs, I have:

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
Column-Number Counsel-Projectile Delete-Selection Display-Line-Numbers
Doom-Modeline Eldoc Electric-Indent File-Name-Shadow Font-Lock
Global-Auto-Revert Global-Display-Line-Numbers Global-Eldoc
Global-Font-Lock Ivy-Prescient Ivy-Rich Line-Number Override-Global
Paredit Projectile Rainbow-Delimiters Recentf Save-Place Savehist
Shell-Dirtrack Show-Paren Transient-Mark Which-Key Wrap-Region
Wrap-Region-Global

(Information about these minor modes follows the major mode info.)

REPL[cljs] mode defined in ‘cider-repl.el’:
Major mode for Clojure REPL interactions.

Inside Cider Major mode, I have the command bellow fully working:

C-c M-p cider-repl-history

But, it works only for current session.

In addition, an user suggested that maybe cider-repl-history-mode was not enabled. Indeed, it seems that it has not been enabled - since I can't see it.

If I try to execute the command cider-repl-history-mode a weird thing happens ParEdit appears indicating a problem in parenthesis and the mini buffer echoes:

paredit-mode: Unmatched bracket or quote

This is really weird because although ParEdit is related to Clojure, it seems unrelated to Cider for the case in hand.

Is there some way to preserve CIDER's REPL's history over sessions?


Solution

  • Use cider-repl-backward-input and cider-repl-forward-input to go forward and backward in command history over sessions.

    See CIDER // docs - REPL history browser.