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

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

[nongnu] elpa/geiser fb8439a7fd 2/4: Improve geiser-repl-autoeval-mode b


From: ELPA Syncer
Subject: [nongnu] elpa/geiser fb8439a7fd 2/4: Improve geiser-repl-autoeval-mode behavior
Date: Sat, 7 Sep 2024 19:00:04 -0400 (EDT)

branch: elpa/geiser
commit fb8439a7fdb81566873e69564438d2e82dc3f8a9
Author: Antero Mejr <mail@antr.me>
Commit: jao <jao@gnu.org>

    Improve geiser-repl-autoeval-mode behavior
    
    Don't autoeval lines that have already been evaluated.
    Don't keep highlighting parens after the line is auto-evaluated.
    Don't highlight if show-paren-mode is not enabled.
---
 elisp/geiser-repl.el | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 23d8828049..3bde43e44a 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -803,17 +803,21 @@ If SAVE-HISTORY is non-nil, save CMD in the REPL history."
 
 ;;; geiser-repl-autoeval-mode minor mode:
 
-(defun geiser-repl--autoeval-paren-function ()
-  (let* ((data (show-paren--default))
-         (here (nth 0 data))
-         (there (nth 2 data))
-         (mismatch (nth 4 data)))
-    (if (and here
-             (eq 0 (geiser-repl--nesting-level))
-             (not mismatch)
-             (> here there))
-        (geiser-repl--send-input))
-    data))
+(defun geiser-repl--autoeval-paren-function (show-paren-enabled)
+  (lambda ()
+    (let* ((data (show-paren--default))
+           (here (nth 0 data))
+           (there (nth 2 data))
+           (mismatch (nth 4 data)))
+      (if (and (= (point) (point-max))
+               here
+               (eq 0 (geiser-repl--nesting-level))
+               (not mismatch)
+               (> here there))
+          (progn (geiser-repl--send-input)
+                 ;; Don't highlight if we're doing an autoeval.
+                 nil)
+        (and show-paren-enabled data)))))
 
 (defvar-local geiser-repl-autoeval-mode-string " E"
   "Modeline indicator for geiser-repl-autoeval-mode")
@@ -825,20 +829,19 @@ Non-null prefix argument turns on the mode.
 Null prefix argument turns off the mode.
 
 When Autoeval mode is enabled, balanced S-expressions are automatically
-evaluated without having to press ENTER.
-
-This mode may cause issues with structural editing modes such as paredit."
+evaluated without having to press ENTER."
   :init-value nil
   :lighter geiser-repl-autoeval-mode-string
   :group 'geiser-repl
 
-  (if (boundp 'show-paren-data-function)
-      (if geiser-repl-autoeval-mode
-          (progn (show-paren-local-mode 1)
-                 (setq-local show-paren-delay geiser-repl-autoeval-mode-delay)
-                 (setq-local show-paren-data-function
-                             'geiser-repl--autoeval-paren-function))
-        (setq-local show-paren-data-function 'show-paren--default)))
+  (if geiser-repl-autoeval-mode
+      (let ((show-paren-enabled show-paren-mode))
+        (progn (show-paren-local-mode 1)
+               (setq-local show-paren-delay geiser-repl-autoeval-mode-delay)
+               (setq-local show-paren-data-function
+                           (geiser-repl--autoeval-paren-function
+                            show-paren-enabled))))
+    (setq-local show-paren-data-function 'show-paren--default))
   (when (called-interactively-p nil)
     (message "Geiser Autoeval %s"
              (if geiser-repl-autoeval-mode "enabled" "disabled"))))



reply via email to

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