Skip to content

Commit

Permalink
Auto-disable racket-xp-mode when racket-pdb-mode enabled
Browse files Browse the repository at this point in the history
Write some pros and cons in the doc string for racket-pdb-mode.
  • Loading branch information
greghendershott committed Mar 25, 2023
1 parent 94ae5a4 commit a2ea314
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions racket-pdb.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
(require 'xref)

(declare-function racket-complete-at-point "racket-edit" ())
(declare-function racket-xp-mode "racket-xp" (&optional arg))

(defvar racket-pdb-control-c-hash-keymap
(racket--easy-keymap-define
Expand Down Expand Up @@ -58,8 +59,45 @@
(define-minor-mode racket-pdb-mode
"Like `racket-xp-mode' but using the pdb package, which must be installed.
For now, please refer to the documentation for `racket-xp-mode',
most of which is relevant to this mode."
There are several advantages of `racket-pdb-mode':
- The `racket-pdb-rename' command works across mulitple (known,
analyzed) files, and is smarter about what should be named than
a grep (text search) approach. Similarly `xref-find-references'
yields better, non-grep results.
- The pdb database is queried only as needed to present things on
screen or to run commands like `xref-find-definition'.
Performance is much better for larger files. Although the
underlying drracket/check-syntax analysis can still take a long
time (e.g. ~10 seconds for something like
private/class-internal.rkt), Emacs is never blocked by
re-propertizing the entire buffer. Also, if the file hasn't
changed since being last visited and analyzed, the previous
results can be reused, even if the buffer has been closed in
Emacs or Emacs has been restarted.
The disadvantages:
- The pdb Racket package must be installed.
- The pdb Racket package requires very new versions of the
drracket-tool-text-lib package as wellas Racket itself. The
newer versions improve the ability to analyze code especially
to understand the graph of sites that must all be renamed
together.
- The pdb \"database\" uses some disk space, on the order of 100
MB for an analysis of about 8,000 files in the Racket main
distribution. On the other hand you can limit the analysis to
projects you're actively working on, if that is the extent of
the scope for which you expect renaming to work. In other
words, you won't need such a large database unless you want
to rename something like \"define\" in racket/base. :)
Until this doc string is further rewritten, please refer to the
documentation for `racket-xp-mode', most of which is relevant to
this mode."
:lighter racket-pdb-mode-lighter
:keymap racket-pdb-mode-map
(unless (eq major-mode 'racket-mode)
Expand All @@ -68,6 +106,10 @@ most of which is relevant to this mode."
(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)
(racket-xp-mode -1))
(cond
(racket-pdb-mode
(add-hook 'after-change-functions
Expand Down

0 comments on commit a2ea314

Please sign in to comment.