@@ -97,6 +97,17 @@ everything. If you find that too \"noisy\", set this to nil.")
97
97
" ---"
98
98
[" Annotate Now" racket-xp-annotate]))
99
99
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
+
100
111
;;;### autoload
101
112
(define-minor-mode racket-xp-mode
102
113
" A minor mode that analyzes expanded code to explain and explore.
@@ -258,7 +269,10 @@ commands directly to whatever keys you prefer.
258
269
(racket-xp-visit . t )
259
270
(racket-xp-doc . t ))))
260
271
(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 " ))
262
276
(add-hook 'after-change-functions
263
277
#'racket--xp-after-change-hook
264
278
t t )
@@ -881,7 +895,9 @@ If you have set `racket-xp-after-change-refresh-delay' to nil --
881
895
or to a very large amount -- you can use this command to annotate
882
896
manually."
883
897
(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? " )))
885
901
(racket--xp-annotate
886
902
(let ((windows (get-buffer-window-list (current-buffer ) nil t )))
887
903
(lambda ()
0 commit comments