[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-ruby 12f7f0750c 159/265: Automatically returning to th
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-ruby 12f7f0750c 159/265: Automatically returning to the previous compilation mode after typing |
Date: |
Sat, 9 Jul 2022 21:59:22 -0400 (EDT) |
branch: elpa/inf-ruby
commit 12f7f0750c1ee65da35c2cfa3b6eb180a59e1913
Author: Daniel Luna <dancluna@gmail.com>
Commit: Daniel Luna <dancluna@gmail.com>
Automatically returning to the previous compilation mode after typing
'quit' or 'exit' in the debugger prompt.
---
README.md | 2 +-
inf-ruby.el | 32 ++++++++++++++++++++++++++++----
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 21a92732c9..e430e2150a 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ automatically.
Additionally, consider adding
```lisp
-(add-hook 'compilation-filter-hook 'inf-ruby-auto-enter)
+(inf-ruby-setup-auto-breakpoint)
```
to your init file to automatically switch from common Ruby compilation
diff --git a/inf-ruby.el b/inf-ruby.el
index 1ade40fa7b..1cff6b211c 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -735,12 +735,36 @@ Gemfile, it should use the `gemspec' instruction."
(let ((default-directory (file-name-as-directory dir)))
(run-ruby "bundle exec racksh" "racksh")))
+(defmacro in-ruby-compilation-modes (mode-var &rest body)
+ "Checks if we're in a ruby compilation mode, and runs BODY in an
+implicit progn if t."
+ `(when (member ,mode-var '(rspec-compilation-mode
+ ruby-compilation-mode
+ projectile-rails-server-mode))
+ (progn ,@body)))
+
(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))))
+ (in-ruby-compilation-modes major-mode
+ (save-excursion
+ (beginning-of-line)
+ (when (looking-at inf-ruby-breakpoint-pattern)
+ (inf-ruby-switch-from-compilation)))))
+
+(defun inf-ruby-auto-exit (input)
+ "Checks if the current input is a debugger exit command and returns
+to the previous compilation mode if t."
+ (in-ruby-compilation-modes inf-ruby-orig-compilation-mode
+ (if (member input '("quit" "exit"))
+ (inf-ruby-maybe-switch-to-compilation))))
+
+(defun inf-ruby-setup-auto-breakpoint ()
+ (add-hook 'compilation-filter-hook 'inf-ruby-auto-enter)
+ (add-hook 'comint-input-filter-functions 'inf-ruby-auto-exit))
+
+(defun inf-ruby-remove-auto-breakpoint ()
+ (remove-hook 'compilation-filter-hook 'inf-ruby-auto-enter)
+ (remove-hook 'comint-input-filter-functions 'inf-ruby-auto-exit))
;;;###autoload
(defun inf-ruby-console-default (dir)
- [nongnu] elpa/inf-ruby 03dd9c9d4e 246/265: Avoid creating duplicates in inf-ruby-buffers, (continued)
- [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
- [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 <=
- [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, 2022/07/09
- [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