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

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

[nongnu] elpa/inf-ruby f484fa82cc 247/265: ruby-send-last-stmt: New comm


From: ELPA Syncer
Subject: [nongnu] elpa/inf-ruby f484fa82cc 247/265: ruby-send-last-stmt: New command
Date: Sat, 9 Jul 2022 21:59:30 -0400 (EDT)

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

    ruby-send-last-stmt: New command
    
    #148
---
 inf-ruby.el | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/inf-ruby.el b/inf-ruby.el
index e920af9dd8..b5a73f390a 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -559,6 +559,26 @@ Must not contain ruby meta characters.")
   (ruby-send-region (save-excursion (ruby-backward-sexp) (point)) (point))
   (when print (ruby-print-result)))
 
+(defun ruby-send-last-stmt (&optional print)
+  "Send the preceding statement to the inferior Ruby process."
+  (interactive "P")
+  (let (beg)
+    (save-excursion
+      (cond
+       ((and (derived-mode-p 'ruby-mode)
+             (bound-and-true-p smie-rules-function))
+        (or (member (nth 2 (smie-backward-sexp ";")) '(";" "#" nil))
+            (error "Preceding statement not found"))
+        (setq beg (point)))
+       (t ; enh-ruby-mode?
+        (back-to-indentation)
+        (while (and (eq (char-after) ?.)
+                    (zerop (forward-line -1)))
+          (back-to-indentation))
+        (setq beg (point)))))
+    (ruby-send-region beg (point)))
+  (when print (ruby-print-result)))
+
 (defun ruby-send-block (&optional print)
   "Send the current block to the inferior Ruby process."
   (interactive "P")



reply via email to

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