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

`racket-repl` starts a new REPL even if one exists #655

Closed countvajhula closed 1 year ago

countvajhula commented 1 year ago

When a buffer has a racket-repl-buffer-name already set to some value and that REPL buffer is visible, calling racket-repl causes a new REPL buffer to be created instead of visiting the existing one for that buffer.

It looks like the issue is that calling racket-repl overwrites any existing buffer-local value for racket-repl-buffer-name.

Btw, this is in the context of #628 where we set the REPL buffer name at the time of creation of the scratch buffer, and then, attempting to visit the REPL buffer using racket-repl causes this to happen. I unfortunately haven't had much of a chance to work on this but I've been occasionally chipping away at it and with any luck we'll have something usable in the not-too-distant future 🙂

((alist-get 'racket-mode package-alist))
((emacs-version "27.1")
 (system-type darwin)
 (x-gtk-use-system-tooltips UNDEFINED)
 (major-mode racket-mode)
 (racket--el-source-dir "/Users/siddhartha/.emacs.d/straight/build/racket-mode/")
 (racket--rkt-source-dir "/Users/siddhartha/.emacs.d/straight/build/racket-mode/racket/")
 (racket-program "racket")
 (racket-command-timeout 10)
 (racket-path-from-emacs-to-racket-function UNDEFINED)
 (racket-path-from-racket-to-emacs-function UNDEFINED)
 (racket-browse-url-function racket-browse-url-using-temporary-file)
 (racket-documentation-search-location "https://docs.racket-lang.org/search/index.html?q=%s")
 (racket-xp-after-change-refresh-delay 1)
 (racket-xp-mode-lighter
  (:eval
   (racket--xp-mode-lighter)))
 (racket-xp-highlight-unused-regexp "^[^_]")
 (racket-repl-buffer-name-function nil)
 (racket-submodules-to-run
  ((test)
   (main)))
 (racket-memory-limit 2048)
 (racket-error-context medium)
 (racket-repl-history-directory "~/.emacs.d/racket-mode/")
 (racket-history-filter-regexp "\\`\\s *\\'")
 (racket-images-inline t)
 (racket-imagemagick-props nil)
 (racket-images-keep-last 100)
 (racket-images-system-viewer "open")
 (racket-pretty-print t)
 (racket-use-repl-submit-predicate nil)
 (racket-pretty-print t)
 (racket-indent-curly-as-sequence t)
 (racket-indent-sequence-depth 0)
 (racket-pretty-lambda nil)
 (racket-smart-open-bracket-enable nil)
 (racket-module-forms "\\s(\\(?:module[*+]?\\|library\\)")
 (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-show-functions
  (racket-show-pseudo-tooltip)))
(enabled-minor-modes
 (auto-composition-mode)
 (auto-compression-mode)
 (auto-encryption-mode)
 (auto-fill-mode)
 (auto-save-mode)
 (blink-cursor-mode)
 (buffer-ring-mode)
 (column-number-mode)
 (company-box-mode)
 (company-mode)
 (company-prescient-mode)
 (counsel-mode)
 (display-line-numbers-mode)
 (electric-indent-mode)
 (evil-collection-unimpaired-mode)
 (evil-commentary-mode)
 (evil-goggles-mode)
 (evil-local-mode)
 (evil-matchit-mode)
 (evil-mc-mode)
 (evil-mode)
 (evil-surround-mode)
 (file-name-shadow-mode)
 (font-lock-mode)
 (general-override-mode)
 (global-auto-revert-mode)
 (global-company-mode)
 (global-display-line-numbers-mode)
 (global-eldoc-mode)
 (global-evil-collection-unimpaired-mode)
 (global-evil-matchit-mode)
 (global-evil-mc-mode)
 (global-evil-surround-mode)
 (global-font-lock-mode)
 (global-git-commit-mode)
 (global-tree-sitter-mode)
 (global-undo-tree-mode)
 (global-visual-line-mode)
 (global-whitespace-mode)
 (hs-minor-mode)
 (ivy-mode)
 (ivy-prescient-mode)
 (ivy-rich-mode)
 (mac-mouse-wheel-mode)
 (magit-auto-revert-mode)
 (menu-bar-mode)
 (mindstream-mode)
 (override-global-mode)
 (prescient-persist-mode)
 (projectile-mode)
 (racket-xp-mode)
 (recentf-mode)
 (semantic-minor-modes-format)
 (shell-dirtrack-mode)
 (show-paren-mode)
 (straight-package-neutering-mode)
 (straight-use-package-mode)
 (symex-editing-mode)
 (symex-mode)
 (telephone-line-mode)
 (tooltip-mode)
 (transient-mark-mode)
 (undo-tree-mode)
 (visual-line-mode)
 (winner-mode)
 (yas-global-mode)
 (yas-minor-mode))
(disabled-minor-modes
 (abbrev-mode)
 (ace-window-display-mode)
 (ace-window-mode)
 (adaptive-wrap-prefix-mode)
 (all-the-icons-dired-mode)
 (archive-subfile-mode)
 (auto-fill-function)
 (auto-revert-mode)
 (auto-revert-tail-mode)
 (auto-save-visited-mode)
 (avy-linum-mode)
 (beacon-mode)
 (buffer-face-mode)
 (buffer-read-only)
 (caps-lock-mode)
 (centaur-tabs-local-mode)
 (centaur-tabs-mode)
 (cider--debug-mode)
 (cider-auto-test-mode)
 (cider-enlighten-mode)
 (cider-mode)
 (cider-popup-buffer-mode)
 (cl-old-struct-compat-mode)
 (company-search-mode)
 (compilation-minor-mode)
 (compilation-shell-minor-mode)
 (completion-in-region-mode)
 (dash-fontify-mode)
 (defining-kbd-macro)
 (delete-selection-mode)
 (desktop-save-mode)
 (diff-auto-refine-mode)
 (diff-minor-mode)
 (dired-hide-details-mode)
 (dired-isearch-filenames-mode)
 (dired-omit-mode)
 (doc-view-minor-mode)
 (doc-view-presentation-mode)
 (edebug-mode)
 (edebug-x-mode)
 (eldoc-mode)
 (electric-layout-mode)
 (electric-quote-mode)
 (enriched-mode)
 (erc-irccontrols-mode)
 (erc-keep-place-mode)
 (erc-move-to-prompt-mode)
 (erc-noncommands-mode)
 (erc-readonly-mode)
 (erc-scrolltobottom-mode)
 (erc-smiley-mode)
 (erc-unmorse-mode)
 (evil-collection-magit-toggle-text-minor-mode)
 (evil-tree-edit-mode)
 (flyspell-mode)
 (geiser-autodoc-mode)
 (geiser-mode)
 (geiser-smart-tab-mode)
 (general-override-local-mode)
 (git-commit-mode)
 (git-timemachine-mode)
 (global-dash-fontify-mode)
 (global-hl-line-mode)
 (global-linum-mode)
 (global-prettify-symbols-mode)
 (global-reveal-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-whitespace-newline-mode)
 (gnus-dead-summary-mode)
 (gnus-undo-mode)
 (hl-line-mode)
 (horizontal-scroll-bar-mode)
 (ibuffer-auto-mode)
 (image-minor-mode)
 (isearch-mode)
 (ispell-minor-mode)
 (ivy-rich-project-root-cache-mode)
 (jedi-mode)
 (jit-lock-debug-mode)
 (line-number-mode)
 (linum-mode)
 (mac-auto-ascii-mode)
 (mac-auto-operator-composition-mode)
 (mac-font-panel-mode)
 (macrostep-mode)
 (magit-blame-mode)
 (magit-blame-read-only-mode)
 (magit-blob-mode)
 (magit-wip-after-apply-mode)
 (magit-wip-after-save-local-mode)
 (magit-wip-after-save-mode)
 (magit-wip-before-change-mode)
 (magit-wip-initial-backup-mode)
 (magit-wip-mode)
 (mail-abbrevs-mode)
 (mml-mode)
 (mouse-wheel-mode)
 (next-error-follow-minor-mode)
 (org-cdlatex-mode)
 (org-indent-mode)
 (org-list-checkbox-radio-mode)
 (org-src-mode)
 (org-table-follow-field-mode)
 (org-table-header-line-mode)
 (orgtbl-mode)
 (outline-minor-mode)
 (overwrite-mode)
 (paragraph-indent-minor-mode)
 (paredit-mode)
 (prettify-symbols-mode)
 (racket-smart-open-bracket-mode)
 (rectangle-mark-mode)
 (reveal-mode)
 (rigpa-char-mode)
 (rigpa-line-mode)
 (rigpa-word-mode)
 (semantic-highlight-edits-mode)
 (semantic-highlight-func-mode)
 (semantic-mode)
 (semantic-show-parser-state-mode)
 (semantic-show-unmatched-syntax-mode)
 (semantic-stickyfunc-mode)
 (server-mode)
 (sh-electric-here-document-mode)
 (shell-command-with-editor-mode)
 (size-indication-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)
 (smerge-mode)
 (sr-modeline)
 (sr-popviewer-mode)
 (sr-tabs-mode)
 (sr-term-char-minor-mode)
 (sr-term-line-minor-mode)
 (straight-live-modifications-mode)
 (straight-symlink-emulation-mode)
 (tab-bar-history-mode)
 (tab-bar-mode)
 (tar-subfile-mode)
 (temp-buffer-resize-mode)
 (text-scale-mode)
 (tool-bar-mode)
 (transient-resume-mode)
 (tree-sitter-hl-mode)
 (tree-sitter-mode)
 (undo-tree-visualizer-selection-mode)
 (unify-8859-on-decoding-mode)
 (unify-8859-on-encoding-mode)
 (url-handler-mode)
 (use-hard-newlines)
 (vc-parent-buffer)
 (view-mode)
 (visible-mode)
 (which-function-mode)
 (whitespace-mode)
 (whitespace-newline-mode)
 (window-divider-mode)
 (with-editor-mode)
 (xref-etags-mode))
countvajhula commented 1 year ago

Modifying that line in racket-repl.el to this fixes it for me:

(unless racket-repl-buffer-name
    (racket-call-racket-repl-buffer-name-function))