[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-ruby 164f2dda53 065/265: Add commands to launch differ
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-ruby 164f2dda53 065/265: Add commands to launch different types of consoles |
Date: |
Sat, 9 Jul 2022 21:59:14 -0400 (EDT) |
branch: elpa/inf-ruby
commit 164f2dda530d242c0dac91cc9922360ccdbceaa6
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Add commands to launch different types of consoles
Bump the version
Close #16
---
inf-ruby.el | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 78 insertions(+), 1 deletion(-)
diff --git a/inf-ruby.el b/inf-ruby.el
index ec3f9278a7..fbe3510905 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -10,7 +10,7 @@
;; URL: http://github.com/nonsequitur/inf-ruby
;; Created: 8 April 1998
;; Keywords: languages ruby
-;; Version: 2.2.7
+;; Version: 2.3.0
;;; Commentary:
;;
@@ -458,6 +458,83 @@ keymaps to bind `inf-ruby-switch-from-compilation' to `ะก-x
C-q'."
'(define-key ruby-compilation-mode-map (kbd "C-x C-q")
'inf-ruby-switch-from-compilation)))
+(defvar inf-ruby-console-patterns-alist
+ '(("config/application.rb" . rails)
+ ("*.gemspec" . gem)
+ ("Gemfile" . default))
+ "Mapping from file name patterns to name symbols.
+`inf-ruby-console-auto' walks up from the current directory until
+one of the patterns matches, then calls `inf-ruby-console-NAME',
+passing it the found directory.")
+
+(defun inf-ruby-console-match (dir)
+ (catch 'type
+ (dolist (pair inf-ruby-console-patterns-alist)
+ (let ((default-directory dir))
+ (when (file-expand-wildcards (car pair))
+ (throw 'type (cdr pair)))))))
+
+;;;###autoload
+(defun inf-ruby-console-auto ()
+ "Automatically determine the appropriate Ruby console command
+and the directory to run it from."
+ (interactive)
+ (let* ((dir (locate-dominating-file default-directory
+ #'inf-ruby-console-match))
+ (type (inf-ruby-console-match dir))
+ (fun (intern (format "inf-ruby-console-%s" type))))
+ (unless type (error "No matching directory found"))
+ (funcall fun dir)))
+
+;;;###autoload
+(defun inf-ruby-console-rails (dir)
+ "Run Rails console in DIR."
+ (interactive "D")
+ (let ((default-directory dir))
+ (run-ruby "rails console" "rails")))
+
+;;;###autoload
+(defun inf-ruby-console-gem (dir)
+ "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")
+ (let ((default-directory dir))
+ (if (file-exists-p "Gemfile")
+ (run-ruby "bundle exec irb" "gem")
+ (unless (file-exists-p "lib")
+ (error "The directory must contain a 'lib' subdirectory"))
+ (let (files)
+ (dolist (item (directory-files "lib"))
+ (unless (file-directory-p item)
+ (setq files (cons item files))))
+ (run-ruby (concat "irb -I lib"
+ ;; If there are several files under 'lib'
+ ;; (unlikely), load them all.
+ (mapconcat
+ (lambda (file)
+ (concat " -r " (file-name-sans-extension file)))
+ files
+ ""))
+ "gem")))))
+
+;;;###autoload
+(defun inf-ruby-console-default (dir)
+ "Run racksh, custom console.rb, or just IRB, in DIR."
+ (interactive "D")
+ (let ((default-directory dir))
+ (unless (file-exists-p "Gemfile")
+ (error "The directory must contain a Gemfile"))
+ (cond
+ ((with-temp-buffer
+ (insert-file-contents "Gemfile")
+ (re-search-forward "[\"']racksh[\"']" nil t))
+ (run-ruby "bundle exec racksh" "racksh"))
+ ((file-exists-p "console.rb")
+ (run-ruby "ruby console.rb" "console.rb"))
+ (t
+ (run-ruby "bundle exec irb")))))
+
;;;###autoload (inf-ruby-setup-keybindings)
(provide 'inf-ruby)
- [nongnu] elpa/inf-ruby a4c766e605 231/265: Use pry_instance, _pry_ is not in Pry 0.13 anymore, (continued)
- [nongnu] elpa/inf-ruby a4c766e605 231/265: Use pry_instance, _pry_ is not in Pry 0.13 anymore, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 9f0f79ff45 232/265: inf-ruby-console-rails: Try to handle IRB's "multiline" thing here, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby c2a28ef6a1 242/265: Replace toggle-read-only-mode with read-only-mode, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby cd50ce8432 249/265: Creating eval overlay feature, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 57642c27fd 053/265: inf-ruby-completions: support non-"current" inf-ruby-mode buffers and Pry, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 33e17e055f 037/265: Move keys to a new minor mode, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 91bbd7763d 071/265: Avoid error when trying to switch to non-existing inf-ruby buffer, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 54508a9923 011/265: Mac OS: Fix completion output splitting for Ruby 1.8.7 compatibility., ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 74e96360b1 034/265: Added macruby to inf-ruby-implementations, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby a7bb5f99e3 013/265: Pesky header stuff., ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 164f2dda53 065/265: Add commands to launch different types of consoles,
ELPA Syncer <=
- [nongnu] elpa/inf-ruby d776551688 087/265: Add pry to inf-ruby-implementations, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 28b84de084 122/265: Advertise using the .pryrc workaround, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 562fa9a422 094/265: Close #37, ELPA Syncer, 2022/07/09
- [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