# Racket packages in Racket Mode for Emacs

**URL:** <https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027>\
**Category:** Show & Tell\
**Tags:** emacs, racket-mode, announcement\
**Created:** [July 15, 2024, 3:28pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027 "2024-07-15T15:28:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [July 15, 2024, 3:28pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027/1 "2024-07-15T15:28:25Z")

</div>

FYI, I just added to Racket Mode a [UX for Racket packages](https://www.racket-mode.com/#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.

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/4/420d866b3b4d41375ae944b7dd59ce2f15d9de10.png)

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/f/f07149491dde9b5f9c98f03554482f8d729f07be.png)

---

<div class="post-metadata">

**Author:** ![scolobb](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/scolobb/32/108_2.png) [@scolobb](https://racket.discourse.group/u/scolobb)\
**Post date:** [July 15, 2024, 4:22pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027/2 "2024-07-15T16:22:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![badkins](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/badkins/32/99_2.png) [@badkins](https://racket.discourse.group/u/badkins)\
**Post date:** [July 17, 2024, 2:47pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027/3 "2024-07-17T14:47:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [July 17, 2024, 2:56pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027/4 "2024-07-17T14:56:07Z")

</div>

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`](https://docs.racket-lang.org/pkg/lib.html#%28def._%28%28lib._pkg%2Flib..rkt%29._installed-pkg-table%29%29) 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.

---

<div class="post-metadata">

**Author:** ![bogdan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/bogdan/32/8_2.png) [@bogdan](https://racket.discourse.group/u/bogdan)\
**Post date:** [July 17, 2024, 3:25pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027/5 "2024-07-17T15:25:26Z")

</div>

Someone more knowledgeable can correct me if I'm wrong, but I think one has to run [pkg-catalog-update-local](https://docs.racket-lang.org/pkg/lib.html#%28def._%28%28lib._pkg%2Flib..rkt%29._pkg-catalog-update-local%29%29) 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.

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [July 17, 2024, 3:31pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027/6 "2024-07-17T15:31:35Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [July 17, 2024, 3:42pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027/7 "2024-07-17T15:42:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [July 17, 2024, 4:35pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027/8 "2024-07-17T16:35:40Z")

</div>

Something like [Update local cache of package catalog · greghendershott/racket-mode@675f966 · GitHub](https://github.com/greghendershott/racket-mode/commit/675f96672605867b68c7514ba837d43a91700a42) might suffice -- testing some scenarios here, "it works".

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

---

<div class="post-metadata">

**Author:** ![greghendershott](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/greghendershott/32/98_2.png) [@greghendershott](https://racket.discourse.group/u/greghendershott)\
**Post date:** [July 18, 2024, 8:05pm UTC](https://racket.discourse.group/t/racket-packages-in-racket-mode-for-emacs/3027/9 "2024-07-18T20:05:30Z")

</div>

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.
