Skip to content

Commit 6a911b1

Browse files
Add check-syntax buffer-size limit; see issue #522
1 parent 75ea8f6 commit 6a911b1

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

racket-xp.el

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ everything. If you find that too \"noisy\", set this to nil.")
9797
"---"
9898
["Annotate Now" racket-xp-annotate]))
9999

100+
(defvar racket-xp-buffer-size-limit 128000
101+
"When `buffer-size' is at least this amount, disable auto refresh.
102+
103+
Also show yes/no warning for manual `racket-xp-annotate'.
104+
105+
See issue #522.
106+
107+
The default value is of course arbitrary. For comparison it is
108+
about half the size of the largest handwritten file I know in the
109+
Racket sources, drracket/private/unit.rkt.")
110+
100111
;;;###autoload
101112
(define-minor-mode racket-xp-mode
102113
"A minor mode that analyzes expanded code to explain and explore.
@@ -258,7 +269,10 @@ commands directly to whatever keys you prefer.
258269
(racket-xp-visit . t)
259270
(racket-xp-doc . t))))
260271
(cond (racket-xp-mode
261-
(racket--xp-annotate)
272+
(if (< (buffer-size) racket-xp-buffer-size-limit)
273+
(racket--xp-annotate)
274+
(setq racket-xp-after-change-refresh-delay nil)
275+
(message "Extremely large buffer; setting racket-xp-after-change-refresh-delay set to nil"))
262276
(add-hook 'after-change-functions
263277
#'racket--xp-after-change-hook
264278
t t)
@@ -881,7 +895,9 @@ If you have set `racket-xp-after-change-refresh-delay' to nil --
881895
or to a very large amount -- you can use this command to annotate
882896
manually."
883897
(interactive)
884-
(when racket-xp-mode
898+
(when (and racket-xp-mode
899+
(or (< (buffer-size) racket-xp-buffer-size-limit)
900+
(yes-or-no-p "The buffer is so large Emacs will probably 'freeze'! Are you sure you want to continue? ")))
885901
(racket--xp-annotate
886902
(let ((windows (get-buffer-window-list (current-buffer) nil t)))
887903
(lambda ()

0 commit comments

Comments
 (0)