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

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

[nongnu] elpa/tuareg 8152aee 2/6: Repair `tuareg-eval-region`


From: ELPA Syncer
Subject: [nongnu] elpa/tuareg 8152aee 2/6: Repair `tuareg-eval-region`
Date: Fri, 10 Sep 2021 15:57:48 -0400 (EDT)

branch: elpa/tuareg
commit 8152aee976d786da589e827f8e103f6f55f3b8b3
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Mattias EngdegÄrd <mattiase@acm.org>

    Repair `tuareg-eval-region`
    
    Set `tuareg-interactive-last-phrase-pos-in-source` to the actual start
    of the region sent to the REPL. Previously, the incorrect position
    caused error locations to be off, causing
    `tuareg-interactive-next-error-source` to fail (see #273, #231).
    
    Rewrite to follow the spirit of the original code: extend the region
    to contain all phrases it intersects.
---
 tuareg.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/tuareg.el b/tuareg.el
index 52c9896..2d35dbc 100644
--- a/tuareg.el
+++ b/tuareg.el
@@ -3683,15 +3683,16 @@ It is assumed that the range START-END delimit valid 
OCaml phrases."
 (defun tuareg-eval-region (start end)
   "Eval the current region in the OCaml REPL."
   (interactive "r")
+  ;; Use the smallest region containing the phrase(s) at either endpoint.
+  (dolist (pos (list start end))
+    (save-excursion
+      (goto-char pos)
+      (let ((phrase (tuareg-discover-phrase)))
+        (when phrase
+          (setq start (min start (car phrase)))
+          (setq end (max end (cadr phrase)))))))
   (setq tuareg-interactive-last-phrase-pos-in-source start)
-  (save-excursion
-    (goto-char start)
-    (tuareg-backward-beginning-of-defun)
-    (setq start (point))
-    (setq end (cdr (tuareg-region-of-defun end)))
-    (if end
-        (tuareg-interactive--send-region start end)
-      (message "The expression after the point is not well braced."))))
+  (tuareg-interactive--send-region start end))
 
 (define-obsolete-function-alias 'tuareg-narrow-to-phrase #'narrow-to-defun
   "Apr 10, 2019")



reply via email to

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