[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-ruby 5aaa7e879c 193/265: Only launch one console per p
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-ruby 5aaa7e879c 193/265: Only launch one console per project |
Date: |
Sat, 9 Jul 2022 21:59:25 -0400 (EDT) |
branch: elpa/inf-ruby
commit 5aaa7e879ce4f900cac9ac4be8d67a127c232566
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Only launch one console per project
---
inf-ruby.el | 50 +++++++++++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 21 deletions(-)
diff --git a/inf-ruby.el b/inf-ruby.el
index 7cc35dc844..2962b84398 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -292,16 +292,19 @@ The following commands are available:
(defun inf-ruby-buffer ()
"Return inf-ruby buffer for the current buffer or project."
+ (let ((current-dir (locate-dominating-file default-directory
+ #'inf-ruby-console-match)))
+ (and current-dir
+ (inf-ruby-buffer-in-directory current-dir))))
+
+(defun inf-ruby-buffer-in-directory (dir)
+ (setq dir (expand-file-name dir))
(catch 'buffer
- (let ((current-dir (locate-dominating-file default-directory
- #'inf-ruby-console-match)))
- (unless current-dir (throw 'buffer nil))
- (setq current-dir (expand-file-name current-dir))
- (dolist (buffer inf-ruby-buffers)
- (when (buffer-live-p buffer)
- (with-current-buffer buffer
- (when (string= (expand-file-name default-directory) current-dir)
- (throw 'buffer buffer))))))))
+ (dolist (buffer inf-ruby-buffers)
+ (when (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (when (string= (expand-file-name default-directory) dir)
+ (throw 'buffer buffer)))))))
;;;###autoload
(defun inf-ruby (&optional impl)
@@ -362,7 +365,7 @@ Runs the hooks `comint-mode-hook' and `inf-ruby-mode-hook'.
(unless (and (string= inf-ruby-buffer-impl-name name)
(string= inf-ruby-buffer-command command))
(error (concat "Found inf-ruby buffer, but it was created using "
- "a different NAME-COMMAND combination: %s %s")
+ "a different NAME-COMMAND combination: %s, `%s'")
inf-ruby-buffer-impl-name
inf-ruby-buffer-command))))
@@ -730,13 +733,17 @@ automatically."
(error "No matching directory for %s console found"
(capitalize (symbol-name type)))))
+(defun inf-ruby-console-run (command name)
+ (run-ruby-or-pop-to-buffer command name
+ (inf-ruby-buffer-in-directory default-directory)))
+
;;;###autoload
(defun inf-ruby-console-zeus (dir)
"Run Rails console in DIR using Zeus."
(interactive (list (inf-ruby-console-read-directory 'zeus)))
(let ((default-directory (file-name-as-directory dir))
(exec-prefix (if (executable-find "zeus") "" "bundle exec ")))
- (run-ruby (concat exec-prefix "zeus console") "zeus")))
+ (inf-ruby-console-run (concat exec-prefix "zeus console") "zeus")))
;;;###autoload
(defun inf-ruby-console-rails (dir)
@@ -747,10 +754,11 @@ automatically."
(env (completing-read "Rails environment: " envs nil t
nil nil (car (member "development" envs))))
(with-bundler (file-exists-p "Gemfile")))
- (run-ruby (concat (when with-bundler "bundle exec ")
- "rails console "
- env)
- "rails")))
+ (inf-ruby-console-run
+ (concat (when with-bundler "bundle exec ")
+ "rails console "
+ env)
+ "rails")))
(defun inf-ruby-console-rails-envs ()
(let ((files (file-expand-wildcards "config/environments/*.rb")))
@@ -793,7 +801,7 @@ Gemfile, it should use the `gemspec' instruction."
(concat " -r " (file-name-sans-extension file)))
files
""))))
- (run-ruby (concat base-command args) "gem")))
+ (inf-ruby-console-run (concat base-command args) "gem")))
(defun inf-ruby-console-racksh-p ()
(and (file-exists-p "Gemfile.lock")
@@ -803,7 +811,7 @@ Gemfile, it should use the `gemspec' instruction."
"Run racksh in DIR."
(interactive (list (inf-ruby-console-read-directory 'racksh)))
(let ((default-directory (file-name-as-directory dir)))
- (run-ruby "bundle exec racksh" "racksh")))
+ (inf-ruby-console-run "bundle exec racksh" "racksh")))
(defun inf-ruby-in-ruby-compilation-modes (mode)
"Check if MODE is a Ruby compilation mode."
@@ -848,13 +856,13 @@ Gemfile, it should use the `gemspec' instruction."
(error "The directory must contain a Gemfile"))
(cond
((file-exists-p "console.rb")
- (run-ruby "bundle exec ruby console.rb" "console.rb"))
+ (inf-ruby-console-run "bundle exec ruby console.rb" "console.rb"))
((file-executable-p "console")
- (run-ruby "bundle exec console" "console.rb"))
+ (inf-ruby-console-run "bundle exec console" "console.rb"))
((inf-ruby-file-contents-match "Gemfile" "[\"']pry[\"']")
- (run-ruby "bundle exec pry" "pry"))
+ (inf-ruby-console-run "bundle exec pry" "pry"))
(t
- (run-ruby "bundle console")))))
+ (inf-ruby-console-run "bundle console" "bundle console")))))
;;;###autoload
(defun inf-ruby-file-contents-match (file regexp &optional match-group)
- [nongnu] elpa/inf-ruby b3ee3093b5 105/265: Autoloading inf-ruby-minor-mode is more important, (continued)
- [nongnu] elpa/inf-ruby b3ee3093b5 105/265: Autoloading inf-ruby-minor-mode is more important, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby c5bfcf59eb 112/265: Turn string into a choice, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby f1ea8f8a69 103/265: Restore compatibility with Emacs < 24.4, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 6d7f1dc10a 085/265: Merge remote-tracking branch 'bbatsov/style', ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 409fd736d4 104/265: Complete on an empty line, too, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 5759a9187c 132/265: Recommend setting Pry.config.correct_indent to false, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 1d6fef6eba 171/265: Wrap SMIE tokenizer functions to bind inhibit-field-text-motion, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 12f7f0750c 159/265: Automatically returning to the previous compilation mode after typing, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby df014b0717 177/265: Merge pull request #90 from codeasone/support-single-quoted-gemspec-name, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 74ca3a7f97 191/265: in a{, new} buffer, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 5aaa7e879c 193/265: Only launch one console per project,
ELPA Syncer <=
- [nongnu] elpa/inf-ruby 62c1c72d8e 205/265: Add autoload, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 86db14c315 022/265: Rename: inf-ruby-keys -> inf-ruby-setup-keybindings, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby dfc1d4f19f 033/265: Delete obsolete TODO comment, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 6aba85ea70 042/265: inf-ruby-fix-completions-on-windows: Fix free variable compilation warning, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 5cf94a2dd1 010/265: Fix completion string insertion so that it doesn't swallow newlines when used outside of inf-ruby buffers., ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 0f0eb184f0 088/265: Bump the version, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby f062b7eb0b 075/265: Merge remote-tracking branch 'bbatsov/readme', ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 8fa68039c8 160/265: Improving inf-ruby-breakpoint-pattern and in-ruby-compilation-modes, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 5bb2919691 155/265: Keep the buffer's restrictions, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby e18c8c3624 162/265: Considering ^D as a valid exit command, ELPA Syncer, 2022/07/09