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

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

[nongnu] elpa/inf-ruby 1f69ae4baf 157/265: Automatically entering inf-ru


From: ELPA Syncer
Subject: [nongnu] elpa/inf-ruby 1f69ae4baf 157/265: Automatically entering inf-ruby on pry
Date: Sat, 9 Jul 2022 21:59:22 -0400 (EDT)

branch: elpa/inf-ruby
commit 1f69ae4baf9eb0d59c8d3a498e7cdbd2972a5fa3
Author: Daniel Luna <dancluna@gmail.com>
Commit: Daniel Luna <dancluna@gmail.com>

    Automatically entering inf-ruby on pry
---
 README.md   |  4 ++--
 inf-ruby.el | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index bf1f4ede86..21a92732c9 100644
--- a/README.md
+++ b/README.md
@@ -60,10 +60,10 @@ automatically.
 Additionally, consider adding
 
 ```lisp
-(add-hook 'after-init-hook 'inf-ruby-switch-setup)
+(add-hook 'compilation-filter-hook 'inf-ruby-auto-enter)
 ```
 
-to your init file to easily switch from common Ruby compilation
+to your init file to automatically switch from common Ruby compilation
 modes to interact with a debugger.
 
 ### Emacs Prelude
diff --git a/inf-ruby.el b/inf-ruby.el
index 06eeb0af4b..1f632010dc 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -634,6 +634,9 @@ keymaps to bind `inf-ruby-switch-from-compilation' to `ะก-x 
C-q'."
 one of the predicates matches, then calls `inf-ruby-console-NAME',
 passing it the found directory.")
 
+(defvar inf-ruby-breakpoint-pattern "\\[1\\] pry(" "Pattern to check if the
+current line indicates the current compilation mode entered a breakpoint")
+
 (defun inf-ruby-console-match (dir)
   "Find matching console command for DIR, if any."
   (catch 'type
@@ -731,6 +734,13 @@ Gemfile, it should use the `gemspec' instruction."
   (let ((default-directory (file-name-as-directory dir)))
     (run-ruby "bundle exec racksh" "racksh")))
 
+(defun inf-ruby-auto-enter ()
+  "Automatically enters inf-ruby mode when it sees a breakpoint-indicating 
pattern."
+  (when (member major-mode '(rspec-compilation-mode ruby-compilation-mode 
projectile-rails-server-mode))
+    (beginning-of-line)
+    (when (re-search-forward inf-ruby-breakpoint-pattern (line-end-position) t)
+      (inf-ruby-switch-from-compilation))))
+
 ;;;###autoload
 (defun inf-ruby-console-default (dir)
   "Run custom console.rb, Pry, or bundle console, in DIR."



reply via email to

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