diff options
| author | Antero Mejr <mail@antr.me> | 2024-09-07 21:26:00 +0000 | 
|---|---|---|
| committer | jao <jao@gnu.org> | 2024-09-07 23:30:10 +0100 | 
| commit | fb8439a7fdb81566873e69564438d2e82dc3f8a9 (patch) | |
| tree | 081307f61dc6f9e9ac6581ec6bfad6fd85623c9d /elisp | |
| parent | 3eafde36a23a681348749d4eabf239edb9ffa6ae (diff) | |
| download | geiser-fb8439a7fdb81566873e69564438d2e82dc3f8a9.tar.gz geiser-fb8439a7fdb81566873e69564438d2e82dc3f8a9.tar.bz2 | |
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.
Diffstat (limited to 'elisp')
| -rw-r--r-- | elisp/geiser-repl.el | 45 | 
1 files changed, 24 insertions, 21 deletions
| diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el index 23d8828..3bde43e 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")))) | 
