[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-ruby 91424afd17 192/265: inf-ruby-console-*: Make sure
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-ruby 91424afd17 192/265: inf-ruby-console-*: Make sure default-directory is set to the project root |
Date: |
Sat, 9 Jul 2022 21:59:25 -0400 (EDT) |
branch: elpa/inf-ruby
commit 91424afd17bbacebd8165c0aff5de95a98c3ccaa
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
inf-ruby-console-*: Make sure default-directory is set to the project root
---
inf-ruby.el | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/inf-ruby.el b/inf-ruby.el
index 7e9c73a95b..7cc35dc844 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -678,9 +678,9 @@ keymaps to bind `inf-ruby-switch-from-compilation' to `ะก-x
C-q'."
("*.gemspec" . gem)
(inf-ruby-console-racksh-p . racksh)
("Gemfile" . default))
- "Mapping from predicates (wildcard patterns or functions) to name symbols.
+ "Mapping from predicates (wildcard patterns or functions) to type symbols.
`inf-ruby-console-auto' walks up from the current directory until
-one of the predicates matches, then calls `inf-ruby-console-NAME',
+one of the predicates matches, then calls `inf-ruby-console-TYPE',
passing it the found directory.")
(defvar inf-ruby-breakpoint-pattern "\\(\\[1\\]
pry(\\)\\|\\((rdb:1)\\)\\|\\((byebug)\\)"
@@ -718,10 +718,22 @@ automatically."
(inf-ruby-file-contents-match "config/application.rb"
"\\_<Rails::Application\\_>")))
+(defun inf-ruby-console-read-directory (type)
+ (or
+ (let ((predicate (car (rassq type inf-ruby-console-patterns-alist))))
+ (locate-dominating-file (read-directory-name "" nil nil t)
+ (if (stringp predicate)
+ predicate
+ (lambda (dir)
+ (let ((default-directory dir))
+ (funcall predicate))))))
+ (error "No matching directory for %s console found"
+ (capitalize (symbol-name type)))))
+
;;;###autoload
(defun inf-ruby-console-zeus (dir)
"Run Rails console in DIR using Zeus."
- (interactive "D")
+ (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")))
@@ -729,7 +741,7 @@ automatically."
;;;###autoload
(defun inf-ruby-console-rails (dir)
"Run Rails console in DIR."
- (interactive "D")
+ (interactive (list (inf-ruby-console-read-directory 'rails)))
(let* ((default-directory (file-name-as-directory dir))
(envs (inf-ruby-console-rails-envs))
(env (completing-read "Rails environment: " envs nil t
@@ -751,7 +763,7 @@ automatically."
"Run IRB console for the gem in DIR.
The main module should be loaded automatically. If DIR contains a
Gemfile, it should use the `gemspec' instruction."
- (interactive "D")
+ (interactive (list (inf-ruby-console-read-directory 'gem)))
(let* ((default-directory (file-name-as-directory dir))
(gemspec (car (file-expand-wildcards "*.gemspec")))
(base-command
@@ -789,7 +801,7 @@ Gemfile, it should use the `gemspec' instruction."
(defun inf-ruby-console-racksh (dir)
"Run racksh in DIR."
- (interactive "D")
+ (interactive (list (inf-ruby-console-read-directory 'racksh)))
(let ((default-directory (file-name-as-directory dir)))
(run-ruby "bundle exec racksh" "racksh")))
@@ -830,7 +842,7 @@ Gemfile, it should use the `gemspec' instruction."
;;;###autoload
(defun inf-ruby-console-default (dir)
"Run custom console.rb, Pry, or bundle console, in DIR."
- (interactive "D")
+ (interactive (list (inf-ruby-console-read-directory 'default)))
(let ((default-directory (file-name-as-directory dir)))
(unless (file-exists-p "Gemfile")
(error "The directory must contain a Gemfile"))
- [nongnu] elpa/inf-ruby 55559dfaac 144/265: fix OpenStruct.new syntax to work with ruby 1.8.7, (continued)
- [nongnu] elpa/inf-ruby 55559dfaac 144/265: fix OpenStruct.new syntax to work with ruby 1.8.7, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 488fc1b129 147/265: Refine the previous change, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby aad537f010 156/265: Merge pull request #82 from mkaschenko/ruby-send-buffer, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 3968234eed 150/265: Merge pull request #77 from syohex/update-url, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby a2a6434bb3 163/265: Reverting to re-search-forward, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 9f02c4a1c8 158/265: Adding ruby-debug pattern, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 2598a06923 164/265: Updating docstrings to follow Emacs' conventions, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 8c8819f84a 167/265: Improve docs, add autoloads, rename and make interactive the setup/remove functions, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby e4337ff378 182/265: inf-ruby-console-default: Support executable "console" script as well, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby ac80ea9fd3 188/265: Make run-ruby do one thing only, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 91424afd17 192/265: inf-ruby-console-*: Make sure default-directory is set to the project root,
ELPA Syncer <=
- [nongnu] elpa/inf-ruby 1dd007201a 197/265: Do not overwrite inf-ruby-buffer if it's still live, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 9bd6d24aca 202/265: inf-ruby-console-gem: Enable completion, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 81adadf0f9 203/265: Bump the version, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby fd8d392fef 224/265: ruby-print-result: Fallback to inf-ruby-buffer, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 03dd9c9d4e 246/265: Avoid creating duplicates in inf-ruby-buffers, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 3cdf30dc73 251/265: Apply code review - remove cl-lib and optional args, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 3e16215cb2 128/265: Document changing C-c C-s to call inf-ruby-console-auto, ELPA Syncer, 2022/07/09
- [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