Racket packages in Racket Mode for Emacs

FYI, I just added to Racket Mode a UX for Racket packages. Roughly the same spirit as the Emacs UX for Emacs packages (with its list-packages and describe-package).

So M-x list-racket-packages gives you a summary of all available and installed packages. The standard tabulated-list-view commands for sorting, etc.

Press RET on one, or use M-x describe-racket-package to view details.

Most detail values are live links to URLs, paths, module docs, other packages' details, etc. When dogfooding this, I actually learned a lot by following these around.

Buttons for install/update/remove cover only the simple, common cases, like raco pkg install --auto. (I didn't go down the rabbit hole of a whole magit transient style UX with all the flags. If you need something more specific, raco pkg on the command line is still your friend.)

Package operations run on each Racket Mode back end (e.g. different versions of Racket, local vs remote hosts) so should do the right thing for each one.

p.s. As I post this, it's merged to the github main branch, but the resulting update probably hasn't quite yet made it through to MELPA or NonGNU Elpa Emacs package repos.

9 Likes

Thanks a lot for this addition @greghendershott! I will definitely give it a try in the nearest future, very useful!

Thanks for this Greg! On my list of Racket packages, the status is "manual" for every one. Is this because I'm building from source?

Hmm, that sounds wrong. FWIW I also build from source.

  • The manual status should be ~= what raco pkg show lists -- packages you manually, explicitly installed.

  • The dependency status should be ~= what raco pkg show --all lists, with a * prefix (meaning "auto").

The above come from installed-pkg-table for both the user and installation scopes. It might be interesting if you run this function locally; is the list very long there, too?

  • The available status should be everything else that's available from one of the package catalogs.

Someone more knowledgeable can correct me if I'm wrong, but I think one has to run pkg-catalog-update-local before the local cache is populated with packages from the configured catalogs. I had to do that (I used DrRacket "File" -> "Package Manager..." -> "Available from Catalog" -> "Update Package List" (I was surprised that there's no raco command to do this), which I assume calls that procedure) before I could see the full list in Emacs.

@bogdan Thanks! That probably explains why there were no available catalog packages for @badkins.

However for me, when building from source, the local catalog is already in the source directory, so I didn't notice this. Not yet sure why different for @badkins.

Mystery 2 is why all of the packages are manual; I'm not yet sure why none are shown as dependency. But I'll dig into that, too.

OK it looks like lack of local catalog info affects pkg-info-auto? (which is how I distinguish "manual" vs. "dependency"), even though that's about an installed package. Presumably the installation leaves behind no dependency info, and so the catalog is consulted for deps... or something like that? I'll explore.

Something like Update local cache of package catalog · greghendershott/racket-mode@675f966 · GitHub might suffice -- testing some scenarios here, "it works".

But I'll think a bit more before merging (and welcome any feedback).

Although I merged that commit yesterday, it was nagging me -- probably too automagical and "aggressive" to update on every startup of the Racket Mode back end. Also what if people lack a connection, or don't want one made.

So I just merged a commit that instead adds an explicit racket-package-refresh command. You need to do that at least once, for good results... and thereafter, it's up to you, when. At least it's like package-refresh-contents for Emacs packages, so consistent with the overall idea of largely mirroring the Emacs UX for packages.