greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
682 stars 93 forks source link

Intermittent delays when inserting text when Racket-Mode is Enabled #707

Closed chebert closed 7 months ago

chebert commented 7 months ago

Package

metadata
(#s(package-desc racket-mode
         (20240319 2002)
         "Racket editing, REPL, and more"
         ((emacs
           (25 1)))
         nil nil "c:/Users/Chebert/AppData/Roaming/.emacs.d/elpa/racket-mode-20240319.2002"
         ((:url . "https://www.racket-mode.com/")
          (:maintainer "Greg Hendershott")
          (:maintainers
           ("Greg Hendershott"))
          (:authors
           ("Greg Hendershott" . "racket-mode-author@greghendershott.com"))
          (:commit . "fd3e3ddf12aef6d7661b5a2c0f70afc7107b7fd9"))
         nil))
package-archives
(("gnu" . "http://elpa.gnu.org/packages/")
 ("melpa" . "https://melpa.org/packages/"))
racket--el-source-dir
"c:/Users/Chebert/AppData/Roaming/.emacs.d/elpa/racket-mode-20240319.2002/"
racket--rkt-source-dir
"c:/Users/Chebert/AppData/Roaming/.emacs.d/elpa/racket-mode-20240319.2002/racket/"

System values

emacs-version
"29.1"
major-mode
help-mode
system-type
windows-nt
display-graphic-p
t

Buffer values

after-change-functions
nil
before-change-functions
nil
completion-at-point-functions
(tags-completion-at-point-function)
eldoc-documentation-function
eldoc-documentation-default
font-lock-defaults
nil
pre-command-hook
(delete-selection-pre-hook tooltip-hide)
post-command-hook
(global-font-lock-mode-check-buffers global-eldoc-mode-check-buffers global-undo-tree-mode-check-buffers global-diff-hl-mode-check-buffers global-flycheck-mode-check-buffers clean-aindent--check-last-point global-hl-line-highlight mode-local-post-major-mode-change)
post-self-insert-hook
(helm-find-files--reset-level-tree electric-pair-post-self-insert-function electric-pair-open-newline-between-pairs-psif electric-indent-post-self-insert-function blink-paren-post-self-insert-function)
xref-backend-functions
(etags--xref-backend)

Racket Mode values

racket--cmd-open-p
t
racket-after-run-hook
nil
racket-back-end-configurations
((:directory "/" :racket-program nil :remote-source-dir nil :restart-watch-directories nil :windows t))
racket-before-run-hook
(racket-ansi-color-context-reset)
racket-browse-url-function
browse-url
racket-command-timeout
10
racket-documentation-search-location
"https://docs.racket-lang.org/search/index.html?q=%s"
racket-error-context
medium
racket-expand-hiding
standard
racket-hash-lang-mode-hook
nil
racket-hash-lang-module-language-hook
nil
racket-hash-lang-token-face-alist
((constant . font-lock-constant-face)
 (error . error)
 (other . font-lock-doc-face)
 (keyword . font-lock-keyword-face)
 (hash-colon-keyword . racket-keyword-argument-face)
 (at . font-lock-doc-face))
racket-history-filter-regexp
"\\`\\s *\\'"
racket-imagemagick-props
nil
racket-images-inline
t
racket-images-keep-last
100
racket-images-system-viewer
"display"
racket-indent-curly-as-sequence
t
racket-indent-sequence-depth
0
racket-logger-config
((cm-accomplice . warning)
 (GC . info)
 (module-prefetch . warning)
 (optimizer . info)
 (racket/contract . error)
 (racket-mode-debugger . info)
 (sequence-specialization . info)
 (* . fatal))
racket-memory-limit
2048
racket-mode-hook
((lambda nil
   (define-key racket-mode-map
           (kbd "C-c C-j")
           'racket-send-last-sexp)
   (define-key racket-mode-map
           (kbd "C-c C-c")
           'racket-send-definition)))
racket-module-forms
"\\s(\\(?:module[*+]?\\|library\\)"
racket-pretty-lambda
nil
racket-pretty-print
t
racket-program
"Racket.exe"
racket-repl-buffer-name-function
nil
racket-repl-command-file
"c:/Users/Chebert/AppData/Roaming/.emacs.d/racket-mode/repl.rkt"
racket-repl-history-directory
"~/.emacs.d/racket-mode/"
racket-repl-mode-hook
nil
racket-sexp-comment-fade
0.5
racket-shell-or-terminal-function
racket-shell
racket-show-functions
(racket-show-pseudo-tooltip)
racket-smart-open-bracket-enable
nil
racket-submodules-to-run
((test)
 (main))
racket-use-repl-submit-predicate
nil
racket-xp-add-binding-faces
nil
racket-xp-after-change-refresh-delay
1
racket-xp-highlight-unused-regexp
"^[^_]"
racket-xp-mode-lighter
(:eval
 (racket--xp-mode-lighter))

Minor modes

enabled
((async-bytecomp-package-mode)
 (auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (buffer-read-only)
 (clean-aindent-mode)
 (column-number-mode)
 (delete-selection-mode)
 (electric-indent-mode)
 (electric-pair-mode)
 (file-name-shadow-mode)
 (font-lock-mode)
 (global-auto-revert-mode)
 (global-diff-hl-mode)
 (global-eldoc-mode)
 (global-flycheck-mode)
 (global-font-lock-mode)
 (global-hl-line-mode)
 (global-undo-tree-mode)
 (indent-tabs-mode)
 (isearch-fold-quotes-mode)
 (line-number-mode)
 (menu-bar-mode)
 (mouse-wheel-mode)
 (save-place-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (size-indication-mode)
 (tooltip-mode)
 (transient-mark-mode)
 (undo-tree-mode)
 (volatile-highlights-mode)
 (windmove-mode))
Disabled minor modes
disabled
((abbrev-mode)
 (aggressive-indent-mode)
 (archive-subfile-mode)
 (auto-fill-function)
 (auto-fill-mode)
 (auto-revert-mode)
 (auto-revert-tail-mode)
 (auto-save-mode)
 (auto-save-visited-mode)
 (avy-linum-mode)
 (blink-cursor-mode)
 (buffer-face-mode)
 (button-mode)
 (cl-old-struct-compat-mode)
 (comint-fontify-input-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (context-menu-mode)
 (cursor-face-highlight-mode)
 (defining-kbd-macro)
 (diff-auto-refine-mode)
 (diff-hl-dir-mode)
 (diff-hl-mode)
 (diff-minor-mode)
 (dired-hide-details-mode)
 (edebug-backtrace-mode)
 (edebug-mode)
 (eldoc-mode)
 (electric-layout-mode)
 (electric-quote-mode)
 (elisp-slime-nav-mode)
 (eshell-arg-mode)
 (eshell-command-mode)
 (eshell-proc-mode)
 (flycheck-mode)
 (flyspell-mode)
 (global-aggressive-indent-mode)
 (global-prettify-symbols-mode)
 (global-semantic-highlight-edits-mode)
 (global-semantic-highlight-func-mode)
 (global-semantic-show-parser-state-mode)
 (global-semantic-show-unmatched-syntax-mode)
 (global-semantic-stickyfunc-mode)
 (global-visual-line-mode)
 (gud-tooltip-mode)
 (helm--minor-mode)
 (helm--remap-mouse-mode)
 (helm-autoresize-mode)
 (helm-display-line-numbers-mode)
 (helm-ff--compress-async-modeline-mode)
 (helm-ff--delete-async-modeline-mode)
 (helm-ff-icon-mode)
 (helm-migemo-mode)
 (helm-minibuffer-history-mode)
 (helm-mode)
 (helm-popup-tip-mode)
 (hl-line-mode)
 (horizontal-scroll-bar-mode)
 (hs-minor-mode)
 (ibuffer-auto-mode)
 (ido-everywhere)
 (image-minor-mode)
 (isearch-mode)
 (ispell-minor-mode)
 (ivy-mode)
 (jit-lock-debug-mode)
 (lispy-goto-mode)
 (lispy-mode)
 (lispy-other-mode)
 (lock-file-mode)
 (lost-selection-mode)
 (macrostep-mode)
 (mc-hide-unmatched-lines-mode)
 (multiple-cursors-mode)
 (next-error-follow-minor-mode)
 (outline-minor-mode)
 (overwrite-mode)
 (paragraph-indent-minor-mode)
 (paredit-mode)
 (prettify-symbols-mode)
 (racket-hash-lang-repl-mode)
 (racket-smart-open-bracket-mode)
 (racket-xp-mode)
 (read-extended-command-mode)
 (rectangle-mark-mode)
 (rectangular-region-mode)
 (semantic-highlight-edits-mode)
 (semantic-highlight-func-mode)
 (semantic-mode)
 (semantic-show-parser-state-mode)
 (semantic-show-unmatched-syntax-mode)
 (semantic-stickyfunc-mode)
 (sh-electric-here-document-mode)
 (shell-highlight-undef-mode)
 (slime-autodoc-mode)
 (slime-edit-value-mode)
 (slime-editing-mode)
 (slime-fuzzy-target-buffer-completions-mode)
 (slime-macroexpansion-minor-mode)
 (slime-mode)
 (slime-popup-buffer-mode)
 (slime-repl-map-mode)
 (slime-repl-read-mode)
 (slime-trace-dialog-autofollow-mode)
 (slime-trace-dialog-hide-details-mode)
 (slime-trace-dialog-minor-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (tool-bar-mode)
 (treesit-explore-mode)
 (treesit-inspect-mode)
 (undelete-frame-mode)
 (undo-tree-visualizer-selection-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (vc-parent-buffer)
 (view-mode)
 (visible-mode)
 (visual-line-mode)
 (window-divider-mode)
 (winner-mode)
 (xref-etags-mode))

Steps to reproduce: Open a Racket file and start typing. I don't have any racket minor modes open and the repl is not open either. When I type for a bit there's a noticeable delay (hundreds of milliseconds) every couple of seconds. I only experience this when the racket-mode is enabled. The file I'm using is empty (except for the "#lang racket" at the top).

I think this is brilliant work and I just wanted to say thanks. Probably this is an interaction with another minor mode I'm using. I'm going to play around with disabling some of the minor modes and if I find anything else I'll update this issue.

chebert commented 7 months ago

I disabled flycheck-mode and that solved the slowdown.

greghendershott commented 7 months ago

From the "Details" info it looks like you ran M-x racket-bug-report from a buffer that's using help-mode --- not racket-mode.

As a result, it's difficult for me to know what variables or minor modes might be causing this problem for you.

Would it be possible for you to re-run racket-bug-report from a racket-mode buffer, and paste that here?

chebert commented 7 months ago

Would it be possible for you to re-run racket-bug-report from a racket-mode buffer, and paste that here?

Package

metadata
(#s(package-desc racket-mode
         (20240319 2002)
         "Racket editing, REPL, and more"
         ((emacs
           (25 1)))
         nil nil "c:/Users/Chebert/AppData/Roaming/.emacs.d/elpa/racket-mode-20240319.2002"
         ((:url . "https://www.racket-mode.com/")
          (:maintainer "Greg Hendershott")
          (:maintainers
           ("Greg Hendershott"))
          (:authors
           ("Greg Hendershott" . "racket-mode-author@greghendershott.com"))
          (:commit . "fd3e3ddf12aef6d7661b5a2c0f70afc7107b7fd9"))
         nil))
package-archives
(("gnu" . "http://elpa.gnu.org/packages/")
 ("melpa" . "https://melpa.org/packages/"))
racket--el-source-dir
"c:/Users/Chebert/AppData/Roaming/.emacs.d/elpa/racket-mode-20240319.2002/"
racket--rkt-source-dir
"c:/Users/Chebert/AppData/Roaming/.emacs.d/elpa/racket-mode-20240319.2002/racket/"

System values

emacs-version
"29.1"
major-mode
help-mode
system-type
windows-nt
display-graphic-p
t

Buffer values

after-change-functions
nil
before-change-functions
nil
completion-at-point-functions
(tags-completion-at-point-function)
eldoc-documentation-function
eldoc-documentation-default
font-lock-defaults
nil
pre-command-hook
(delete-selection-pre-hook tooltip-hide)
post-command-hook
(global-font-lock-mode-check-buffers global-eldoc-mode-check-buffers global-diff-hl-mode-check-buffers global-flycheck-mode-check-buffers clean-aindent--check-last-point global-hl-line-highlight mode-local-post-major-mode-change)
post-self-insert-hook
(helm-find-files--reset-level-tree blink-paren-post-self-insert-function)
xref-backend-functions
(etags--xref-backend)

Racket Mode values

racket--cmd-open-p
nil
racket-after-run-hook
nil
racket-back-end-configurations
((:directory "/" :racket-program nil :remote-source-dir nil :restart-watch-directories nil :windows t))
racket-before-run-hook
(racket-ansi-color-context-reset)
racket-browse-url-function
browse-url
racket-command-timeout
10
racket-documentation-search-location
"https://docs.racket-lang.org/search/index.html?q=%s"
racket-error-context
medium
racket-expand-hiding
standard
racket-hash-lang-token-face-alist
((constant . font-lock-constant-face)
 (error . error)
 (other . font-lock-doc-face)
 (keyword . font-lock-keyword-face)
 (hash-colon-keyword . racket-keyword-argument-face)
 (at . font-lock-doc-face))
racket-history-filter-regexp
"\\`\\s *\\'"
racket-imagemagick-props
nil
racket-images-inline
t
racket-images-keep-last
100
racket-images-system-viewer
"display"
racket-indent-curly-as-sequence
t
racket-indent-sequence-depth
0
racket-logger-config
((cm-accomplice . warning)
 (GC . info)
 (module-prefetch . warning)
 (optimizer . info)
 (racket/contract . error)
 (racket-mode-debugger . info)
 (sequence-specialization . info)
 (* . fatal))
racket-memory-limit
2048
racket-mode-hook
((lambda nil
   (define-key racket-mode-map
           (kbd "C-c C-j")
           'racket-send-last-sexp)
   (define-key racket-mode-map
           (kbd "C-c C-c")
           'racket-send-definition)))
racket-module-forms
"\\s(\\(?:module[*+]?\\|library\\)"
racket-pretty-lambda
nil
racket-pretty-print
t
racket-program
"Racket.exe"
racket-repl-buffer-name-function
nil
racket-repl-command-file
"c:/Users/Chebert/AppData/Roaming/.emacs.d/racket-mode/repl.rkt"
racket-repl-history-directory
"~/.emacs.d/racket-mode/"
racket-repl-mode-hook
nil
racket-sexp-comment-fade
0.5
racket-shell-or-terminal-function
racket-shell
racket-show-functions
(racket-show-pseudo-tooltip)
racket-smart-open-bracket-enable
nil
racket-submodules-to-run
((test)
 (main))
racket-use-repl-submit-predicate
nil
racket-xp-add-binding-faces
nil
racket-xp-after-change-refresh-delay
1
racket-xp-highlight-unused-regexp
"^[^_]"
racket-xp-mode-lighter
(:eval
 (racket--xp-mode-lighter))

Minor modes

enabled
((async-bytecomp-package-mode)
 (auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (buffer-read-only)
 (clean-aindent-mode)
 (column-number-mode)
 (delete-selection-mode)
 (file-name-shadow-mode)
 (font-lock-mode)
 (global-diff-hl-mode)
 (global-eldoc-mode)
 (global-flycheck-mode)
 (global-font-lock-mode)
 (global-hl-line-mode)
 (indent-tabs-mode)
 (isearch-fold-quotes-mode)
 (line-number-mode)
 (menu-bar-mode)
 (mouse-wheel-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (size-indication-mode)
 (tooltip-mode)
 (transient-mark-mode)
 (windmove-mode))
Disabled minor modes
disabled
((abbrev-mode)
 (aggressive-indent-mode)
 (archive-subfile-mode)
 (auto-fill-function)
 (auto-fill-mode)
 (auto-revert-mode)
 (auto-revert-tail-mode)
 (auto-save-mode)
 (auto-save-visited-mode)
 (avy-linum-mode)
 (blink-cursor-mode)
 (buffer-face-mode)
 (button-mode)
 (cl-old-struct-compat-mode)
 (comint-fontify-input-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (context-menu-mode)
 (cursor-face-highlight-mode)
 (defining-kbd-macro)
 (diff-auto-refine-mode)
 (diff-hl-dir-mode)
 (diff-hl-mode)
 (diff-minor-mode)
 (dired-hide-details-mode)
 (edebug-backtrace-mode)
 (edebug-mode)
 (eldoc-mode)
 (electric-indent-mode)
 (electric-layout-mode)
 (electric-pair-mode)
 (electric-quote-mode)
 (elisp-slime-nav-mode)
 (eshell-arg-mode)
 (eshell-command-mode)
 (eshell-proc-mode)
 (flycheck-mode)
 (flyspell-mode)
 (global-aggressive-indent-mode)
 (global-auto-revert-mode)
 (global-prettify-symbols-mode)
 (global-semantic-highlight-edits-mode)
 (global-semantic-highlight-func-mode)
 (global-semantic-show-parser-state-mode)
 (global-semantic-show-unmatched-syntax-mode)
 (global-semantic-stickyfunc-mode)
 (global-undo-tree-mode)
 (global-visual-line-mode)
 (gud-tooltip-mode)
 (helm--minor-mode)
 (helm--remap-mouse-mode)
 (helm-autoresize-mode)
 (helm-display-line-numbers-mode)
 (helm-ff--compress-async-modeline-mode)
 (helm-ff--delete-async-modeline-mode)
 (helm-ff-icon-mode)
 (helm-migemo-mode)
 (helm-minibuffer-history-mode)
 (helm-mode)
 (helm-popup-tip-mode)
 (hl-line-mode)
 (horizontal-scroll-bar-mode)
 (hs-minor-mode)
 (ido-everywhere)
 (image-minor-mode)
 (isearch-mode)
 (ispell-minor-mode)
 (ivy-mode)
 (jit-lock-debug-mode)
 (lispy-goto-mode)
 (lispy-mode)
 (lispy-other-mode)
 (lock-file-mode)
 (lost-selection-mode)
 (macrostep-mode)
 (mc-hide-unmatched-lines-mode)
 (multiple-cursors-mode)
 (next-error-follow-minor-mode)
 (outline-minor-mode)
 (overwrite-mode)
 (paragraph-indent-minor-mode)
 (paredit-mode)
 (prettify-symbols-mode)
 (racket-smart-open-bracket-mode)
 (racket-xp-mode)
 (read-extended-command-mode)
 (rectangle-mark-mode)
 (rectangular-region-mode)
 (save-place-mode)
 (semantic-highlight-edits-mode)
 (semantic-highlight-func-mode)
 (semantic-mode)
 (semantic-show-parser-state-mode)
 (semantic-show-unmatched-syntax-mode)
 (semantic-stickyfunc-mode)
 (sh-electric-here-document-mode)
 (shell-highlight-undef-mode)
 (slime-autodoc-mode)
 (slime-edit-value-mode)
 (slime-editing-mode)
 (slime-fuzzy-target-buffer-completions-mode)
 (slime-macroexpansion-minor-mode)
 (slime-mode)
 (slime-popup-buffer-mode)
 (slime-repl-map-mode)
 (slime-repl-read-mode)
 (slime-trace-dialog-autofollow-mode)
 (slime-trace-dialog-hide-details-mode)
 (slime-trace-dialog-minor-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (tool-bar-mode)
 (treesit-explore-mode)
 (treesit-inspect-mode)
 (undelete-frame-mode)
 (undo-tree-mode)
 (undo-tree-visualizer-selection-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (vc-parent-buffer)
 (view-mode)
 (visible-mode)
 (visual-line-mode)
 (volatile-highlights-mode)
 (window-divider-mode)
 (winner-mode)
 (xref-etags-mode))
greghendershott commented 7 months ago

Oh, while I was typing that you just posted that you'd narrowed it down to flycheck-mode. :smile:

You might find the minor mode racket-xp-mode to work better for that kind of thing: https://www.racket-mode.com/#racket_002dxp_002dmode

chebert commented 7 months ago

Fantastic, thanks so much for your help. For anyone's reference I added the following to my emacs init.el

(add-hook 'racket-mode-hook (lambda () (flycheck-mode -1) (racket-xp-mode)))

(I'll let you close the issue in case you want to do any more with this.)

greghendershott commented 7 months ago

That initialization looks good.

p.s. Just a tiny tip: The only gotcha to giving add-hook an anonymous function from lambda is that it's hard to remove-hook it later (or add-hook it again to replace the old version, as opposed to ending up with both old and new). So often I'll defun a named hook function. Especially when I'm still figuring out what I want the hook to do. But in your case, it probably doesn't matter because you've already got it working and it's simple. :smile: