emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/geiser-chez 73d1671 1/2: add support for Tramp remote file


From: ELPA Syncer
Subject: [nongnu] elpa/geiser-chez 73d1671 1/2: add support for Tramp remote files
Date: Thu, 16 Dec 2021 18:58:03 -0500 (EST)

branch: elpa/geiser-chez
commit 73d1671d69aec54ce81bedac8c55976900e0b945
Author: Felipe Lema <felipelema@mortemale.org>
Commit: Felipe Lema <felipelema@mortemale.org>

    add support for Tramp remote files
    
    - Treat files loaded at start as process-local files
    - `geiser-chez-init-file` won't be added to command-line arguments if it
    does not exist
    - if process is remote, copy "geiser.ss" to remote host and tell chez to
    load the remote copy
---
 geiser-chez.el | 44 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 38 insertions(+), 6 deletions(-)

diff --git a/geiser-chez.el b/geiser-chez.el
index 8c1c178..622acfe 100644
--- a/geiser-chez.el
+++ b/geiser-chez.el
@@ -46,7 +46,10 @@
   :group 'geiser-chez)
 
 (geiser-custom--defcustom geiser-chez-init-file "~/.chez-geiser"
-  "Initialization file with user code for the Chez REPL."
+  "Initialization file with user code for the Chez REPL.
+
+Do mind that this file is local to running process, so remote process will use
+init file at this location in remote host."
   :type 'string
   :group 'geiser-chez)
 
@@ -81,11 +84,40 @@
 (defun geiser-chez--parameters ()
   "Return a list with all parameters needed to start Chez Scheme.
 This function uses `geiser-chez-init-file' if it exists."
-  (let ((init-file (and (stringp geiser-chez-init-file)
-                        (expand-file-name geiser-chez-init-file))))
-    `(,@(and init-file (file-readable-p init-file) (list init-file))
-      ,(expand-file-name "geiser/geiser.ss" geiser-chez-scheme-dir)
-      ,@geiser-chez-extra-command-line-parameters)))
+  (append
+   (when-let ((init-file (and (stringp geiser-chez-init-file)
+                              (expand-file-name geiser-chez-init-file))))
+     (if (file-exists-p
+          (concat
+           (file-remote-p default-directory)
+           init-file))
+         (list init-file)
+       (geiser-log--warn
+        "File %s does not exist, so it's not added to CLI args"
+        init-file)))
+   (let* ((local-geiser-module-file
+           (expand-file-name "geiser/geiser.ss" geiser-chez-scheme-dir))
+          (geiser-module-file
+           (if (file-remote-p default-directory)
+               ;; copy the content to remote file
+               (let* ((temporary-file-directory (temporary-file-directory))
+                      (temp-dir
+                       (make-temp-file "geiser" t))
+                      (remote-geiser-module-file
+                       (concat
+                        (file-name-as-directory
+                         temp-dir)
+                        "geiser.ss")))
+                 ;; write to file
+                 (with-temp-buffer
+                   (insert-file-contents local-geiser-module-file)
+                   (write-file remote-geiser-module-file))
+                 (file-local-name
+                  remote-geiser-module-file))
+             ;; else, process and file are local
+             local-geiser-module-file)))
+     (list geiser-module-file))
+   geiser-chez-extra-command-line-parameters))
 
 (defconst geiser-chez--prompt-regexp "> ")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]