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

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

[nongnu] elpa/inf-ruby 58568b6f7e 1/6: Add custom variable to specify a


From: ELPA Syncer
Subject: [nongnu] elpa/inf-ruby 58568b6f7e 1/6: Add custom variable to specify a wrapper for the determined commands to launch a console
Date: Sun, 15 Dec 2024 22:01:49 -0500 (EST)

branch: elpa/inf-ruby
commit 58568b6f7e20d5c6a0a54b5653ecd81bd0f5a572
Author: Hugo Sales <hugo@hsal.es>
Commit: Hugo Sales <hugo@hsal.es>

    Add custom variable to specify a wrapper for the determined commands to 
launch a console
    
    This allows running the console inside a Docker container
---
 inf-ruby.el | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/inf-ruby.el b/inf-ruby.el
index 09adbda087..09533d3cb8 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -103,6 +103,12 @@ returns a string."
                            inf-ruby-implementations))
   :group 'inf-ruby)
 
+(defcustom inf-ruby-wrapper-command ""
+  "Launcher command pattern to format the auto-detected command.
+Useful for running the shell in another host or a container (such as Docker). 
Must include %s."
+  :type 'string
+  :group 'inf-ruby)
+
 (defun inf-ruby--irb-command ()
   (let ((command "irb --prompt default -r irb/completion --noreadline"))
     (when (inf-ruby--irb-needs-nomultiline-p)
@@ -110,10 +116,11 @@ returns a string."
     command))
 
 (defun inf-ruby--irb-needs-nomultiline-p (&optional with-bundler)
-  (let* ((output (car (last (apply #'process-lines
-                                   (append
-                                    (when with-bundler '("bundle" "exec"))
-                                    '("irb" "-v"))))))
+  "Check if IRB needs the --nomultiline argument.
+WITH-BUNDLER, the command is wrapped with `bundle exec'."
+  (let* ((command (format (or inf-ruby-wrapper-command "%s")
+                          (concat (when with-bundler "bundle exec ") "irb 
-v")))
+         (output (car (last (apply #'process-lines (split-string-and-unquote 
command)))))
          (fields (split-string output "[ (]")))
     (if (equal (car fields) "irb")
         (version<= "1.2.0" (nth 1 fields))
@@ -1152,7 +1159,8 @@ contains the configuration for the known project types."
           (capitalize (symbol-name type)))))
 
 (defun inf-ruby-console-run (command name)
-  (run-ruby-or-pop-to-buffer command name
+  "Ensure a buffer named NAME running the given COMMAND exists."
+  (run-ruby-or-pop-to-buffer (format inf-ruby-wrapper-command command) name
                              (inf-ruby-buffer-in-directory default-directory)))
 
 ;;;###autoload



reply via email to

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