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

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

[nongnu] elpa/inf-ruby 6f1df882ab: Add inf-ruby-auto-enter-and-focus


From: ELPA Syncer
Subject: [nongnu] elpa/inf-ruby 6f1df882ab: Add inf-ruby-auto-enter-and-focus
Date: Sat, 4 Mar 2023 11:00:04 -0500 (EST)

branch: elpa/inf-ruby
commit 6f1df882ab319758af43877fa20465f6566efbf3
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Add inf-ruby-auto-enter-and-focus
    
    Resolves #170
---
 README.md   |  9 ++++++++-
 inf-ruby.el | 29 +++++++++++++++++++++--------
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md
index 541294e425..d0580435c2 100644
--- a/README.md
+++ b/README.md
@@ -63,8 +63,15 @@ Additionally, consider adding
 (add-hook 'compilation-filter-hook 'inf-ruby-auto-enter)
 ```
 
+or
+
+```lisp
+(add-hook 'compilation-filter-hook 'inf-ruby-auto-enter-and-focus)
+```
+
 to your init file to automatically switch from common Ruby compilation
-modes to interact with a debugger.
+modes to interact with a debugger. The latter snippet will also select
+the compilation window and move point to the breakpoint prompt.
 
 ### Custom Prompts
 
diff --git a/inf-ruby.el b/inf-ruby.el
index c65129db51..3fb7b9d785 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -1211,14 +1211,27 @@ Gemfile, it should use the `gemspec' instruction."
 
 ;;;###autoload
 (defun inf-ruby-auto-enter ()
-  "Switch to `inf-ruby-mode' if the breakpoint pattern matches the current 
line."
-  (when (and (inf-ruby-in-ruby-compilation-modes major-mode)
-             (save-excursion
-               (beginning-of-line)
-               (re-search-forward inf-ruby-breakpoint-pattern nil t)))
-    ;; Exiting excursion before this call to get the prompt fontified.
-    (inf-ruby-switch-from-compilation)
-    (add-hook 'comint-input-filter-functions 'inf-ruby-auto-exit nil t)))
+  "Switch to `inf-ruby-mode' if the breakpoint pattern matches the current 
line.
+Return the end position of the breakpoint prompt."
+  (let (pt)
+    (when (and (inf-ruby-in-ruby-compilation-modes major-mode)
+               (save-excursion
+                 (beginning-of-line)
+                 (setq pt
+                       (re-search-forward inf-ruby-breakpoint-pattern nil t))))
+      ;; Exiting excursion before this call to get the prompt fontified.
+      (inf-ruby-switch-from-compilation)
+      (add-hook 'comint-input-filter-functions 'inf-ruby-auto-exit nil t))
+    pt))
+
+;;;###autoload
+(defun inf-ruby-auto-enter-and-focus ()
+  "Switch to `inf-ruby-mode' on a breakpoint, select that window and set 
point."
+  (let ((window (get-buffer-window))
+        (pt (inf-ruby-auto-enter)))
+    (when (and pt window)
+      (select-window window)
+      (goto-char pt))))
 
 ;;;###autoload
 (defun inf-ruby-auto-exit (input)



reply via email to

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