-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple REPL buffers; closes #338
This was fairly short strokes from the work already done in the back end related to REPL sessions now being TCP connections to the back end server, and having it handle multiple such sessions. This just wasn't exposed, yet, in the Emacs front end. After mulling this over, and not wanting to write a whole bunch of ceremonial code for "sessions", I realized that Emacs variable semantics provide a simple, reliable way to handle this. The variable `racket-repl-buffer-name' determines, in a `racket-mode' edit buffer, the name of the `racket-repl-mode' buffer that it is associated with. Like any Emacs variable, this may be global, or, `setq-local' may be used to set a unique value for each buffer. As a result, different strategies for associating one or more edit buffers to one or more REPL buffers, all boil down to setting that `racket-repl-buffer-name' variable as desired. A new customization variable, `racket-repl-buffer-name-function', is called when each `racket-mode' edit buffer is created. - The default function is `racket-repl-buffer-name-shared', which sets the REPL buffer name to "*Racket REPL*". In other words, this is the status quo where all edit buffers share the same REPL. - Another such function is `racket-repl-buffer-name-unique', which sets the REPL buffer name to something like "*Racket REPL: /path/to/foo.rkt*". In other words, somewhat like Dr Racket, each edit buffer gets its own, unique REPL buffer. (Currently there is no UX attempting to position them adjacently.) - Another such function is `racket-repl-buffer-name-project', which names the REPL based on the projectile project name, if any. In other words, edit buffers in the same project share a REPL. You get the idea. The user may supply any such function which sets the desired REPL buffer name, possibly looking at `buffer-file-name' for the `racket-mode' edit buffer as in the last two examples.
- Loading branch information
1 parent
8a6e652
commit d97d665
Showing
8 changed files
with
181 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
;;; racket-repl-buffer-name.el -*- lexical-binding: t; -*- | ||
|
||
;; Copyright (c) 2013-2020 by Greg Hendershott. | ||
;; Portions Copyright (C) 1985-1986, 1999-2013 Free Software Foundation, Inc. | ||
|
||
;; Author: Greg Hendershott | ||
;; URL: https://github.com/greghendershott/racket-mode | ||
|
||
;; License: | ||
;; This is free software; you can redistribute it and/or modify it | ||
;; under the terms of the GNU General Public License as published by | ||
;; the Free Software Foundation; either version 2, or (at your option) | ||
;; any later version. This is distributed in the hope that it will be | ||
;; useful, but without any warranty; without even the implied warranty | ||
;; of merchantability or fitness for a particular purpose. See the GNU | ||
;; General Public License for more details. See | ||
;; http://www.gnu.org/licenses/ for details. | ||
|
||
;;; Some values suitable for `racket-repl-buffer-name-function', | ||
;;; which set the variable `racket-repl-buffer-name'. | ||
|
||
(require 'racket-custom) | ||
(require 'racket-repl) | ||
|
||
;;;###autoload | ||
(defun racket-repl-buffer-name-shared () | ||
"All `racket-mode' edit buffers share one `racket-repl-mode' buffer." | ||
(interactive) | ||
(setq-default racket-repl-buffer-name "*Racket REPL*")) | ||
|
||
;;;###autoload | ||
(defun racket-repl-buffer-name-unique () | ||
"Each `racket-mode' edit buffer gets its own `racket-repl-mode' buffer." | ||
(interactive) | ||
(let ((name (concat "*Racket REPL " | ||
(buffer-file-name) | ||
"*"))) | ||
(setq-local racket-repl-buffer-name name))) | ||
|
||
;;;###autoload | ||
(defun racket-repl-buffer-name-project () | ||
"Files belonging to a projectile project share a `racket-repl-mode' buffer" | ||
(interactive) | ||
(let* ((project (if (fboundp 'projectile-project-name) | ||
(projectile-project-name) | ||
(file-name-directory (buffer-file-name)))) | ||
(name (concat "*Racket REPL project \"" | ||
project | ||
"\"*"))) | ||
(setq-local racket-repl-buffer-name name))) | ||
|
||
(provide 'racket-repl-buffer-name) | ||
|
||
;; racket-repl-buffer-name.el ends here |
Oops, something went wrong.