Skip to content

Commit

Permalink
racket-pdb-mode: Don't await pdb-available? response
Browse files Browse the repository at this point in the history
This can take a few seconds on first load.

Instead, optimistically enable racket-pdb-mode and run pdb-available?
async. When the response arrives, if false, then we can disable
racket-pdb-mode and give show user-error.

This definitely fixes a delay I was able to experience (although only
for the first racket-pdb-mode after restarting Emacs; not thereafter).
Will wait to hear from samth if it fixes the delay they are
experiencing.
  • Loading branch information
greghendershott committed Apr 28, 2023
1 parent 8263069 commit aadf1bf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions racket-pdb.el
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ this mode."
(unless (eq major-mode 'racket-mode)
(setq racket-pdb-mode nil)
(user-error "racket-pdb-mode only works with racket-mode buffers"))
(unless (racket--cmd/await nil '(pdb-available?))
(setq racket-pdb-mode nil)
(user-error "The `pdb` package is not available so racket-pdb-mode cannot be used; use racket-xp-mode instead"))
;; Enabling both `racket-pdb-mode' and `racket-xp-mode' isn't
;; supported so automatically disable latter.
(when (bound-and-true-p racket-xp-mode)
Expand All @@ -128,7 +125,13 @@ this mode."
(add-hook 'pre-redisplay-functions
#'racket-pdb-pre-redisplay
nil t)
(racket-pdb-analyze))
(racket--cmd/async
nil '(pdb-available?)
(lambda (response)
(unless response
(racket-pdb-mode -1)
(user-error "The `pdb` package is not available so racket-pdb-mode cannot be used; use racket-xp-mode instead"))
(racket-pdb-analyze))))
(t
(racket-show nil)
(racket--pdb-remove-all-face-overlays)
Expand Down

0 comments on commit aadf1bf

Please sign in to comment.