From 6970ee7ecb5d1e1dd8f089b1de0c57cd2ba99323 Mon Sep 17 00:00:00 2001 From: Greg Hendershott Date: Thu, 11 Apr 2024 14:30:09 -0400 Subject: [PATCH] Abandon automagical envrc-mode-hook; instead recommend dir-locals Although a neat idea it can't reliably run soon enough. Effectively this commit reverts a chunk of the previous commit concerning that hook. However it preserves the change where we make sure REPLs are per-back-end. --- doc/racket-mode.texi | 16 ++++++++++++++-- racket-back-end.el | 39 +++++++++++---------------------------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/doc/racket-mode.texi b/doc/racket-mode.texi index 753b4320..4ade15cc 100644 --- a/doc/racket-mode.texi +++ b/doc/racket-mode.texi @@ -3092,6 +3092,9 @@ The following values will @emph{not} work: Function to call to browse a URL@. +Defaults to @ref{racket-browse-url-using-temporary-file} on macOS and +@code{browse-url} on other platforms. + @node racket-xp-after-change-refresh-delay @subsection racket-xp-after-change-refresh-delay @@ -3713,7 +3716,7 @@ A value for the variable @ref{racket-show-functions}. @code{(racket-repl-buffer-name-shared)} -All @ref{racket-mode} edit buffers share one @ref{racket-repl-mode} buffer per back end. +Share one @ref{racket-repl-mode} buffer per back end. A value for the variable @ref{racket-repl-buffer-name-function}. @@ -3733,7 +3736,7 @@ A value for the variable @ref{racket-repl-buffer-name-function}. @code{(racket-repl-buffer-name-project)} -All @ref{racket-mode} buffers in a project share a @ref{racket-repl-mode} buffer. +Share a @ref{racket-repl-mode} buffer per back end and per project. A value for the variable @ref{racket-repl-buffer-name-function}. @@ -3932,6 +3935,15 @@ are a few examples. :racket-program "xvfb-run racket") @end lisp +Tip: If you use various versions of Racket via .envrc files and +@code{envrc-global-mode}, then in each such directory with a .envrc +file you should have a .dir-locals.el file to force the use of a +distinct back end: + +@lisp + ((nil . ((eval . (racket-add-back-end default-directory))))) +@end lisp + @node Running racket and raco commands in a shell or terminal (1) @section Running racket and raco commands in a shell or terminal diff --git a/racket-back-end.el b/racket-back-end.el index 2e97117b..6317477b 100644 --- a/racket-back-end.el +++ b/racket-back-end.el @@ -200,6 +200,15 @@ are a few examples. (racket-add-back-end \"/ssh:headless:~/gui-project/\" :racket-program \"xvfb-run racket\") #+END_SRC + +Tip: If you use various versions of Racket via .envrc files and +`envrc-global-mode', then in each such directory with a .envrc +file you should have a .dir-locals.el file to force the use of a +distinct back end: + +#+BEGIN_SRC lisp + ((nil . ((eval . (racket-add-back-end default-directory))))) +#+END_SRC " (unless (and (stringp directory) (file-name-absolute-p directory)) (error "racket-add-back-end: directory must be file-name-absolute-p")) @@ -257,32 +266,6 @@ are a few examples. (unless no-refresh-watches-p (racket--back-end-refresh-watches))) -;; Avoid user needing to use dir-locals.el to manually create a -;; distinct back end for each envrc directory; see issue #706. -(eval-after-load 'envrc - '(progn - (defvar envrc--status) - (declare-function envrc--find-env-dir "ext:envrc" ()) - (defun racket-back-end-envrc-mode-hook () - "A value for `envrc-mode-hook'. - -Automatically configures a distinct back end for the directory of -the dominating envrc file, if any. As a result, each such back -end uses appropriate `exec-path' and `process-environment' -values." - (when-let ((env-dir (and (eq 'on envrc--status) - (envrc--find-env-dir)))) - (unless (cl-find env-dir - racket-back-end-configurations - :test - (lambda (dir back-end) - (equal dir (plist-get back-end :directory)))) - (when-let ((path-to-racket (executable-find (if racket--winp "Racket.exe" "racket")))) - (message "racket-back-end-envrc-mode-hook configuring back end for %S to use %S" - env-dir path-to-racket) - (racket-add-back-end env-dir :racket-program path-to-racket))))) - (add-hook 'envrc-mode-hook 'racket-back-end-envrc-mode-hook))) - (defun racket-back-end-name (&optional back-end) "Return the \"name\" of a back end. @@ -471,8 +454,8 @@ a possibly slow remote connection." (if (racket--back-end-local-p back-end) (cons (or (executable-find (or (plist-get back-end :racket-program) racket-program)) - (user-error - "Cannot find Racket executable\nracket-program: %S\nexec-path: %S" + (error + "Cannot executable-find Racket:\n racket-program: %S\n exec-path: %S" racket-program exec-path)) racket-command-args)