abo-abo / lispy

Short and sweet LISP editing
http://oremacs.com/lispy/
1.2k stars 130 forks source link

lispy-pair breaks after truncated output in cider-repl #612

Open lycheese opened 2 years ago

lycheese commented 2 years ago

After an output has been truncated in the cider-repl lispy-pair jumps before the prompt with "Text is read-only" in the echo area, but no pair is inserted. Writing at least 2 characters before the prompt, then moving behind the prompt and calling lispy-pair again causes the pair to be inserted and the two first characters to be deleted. Upon calling lispy-pair once more 2 spaces are inserted at the beginning of the line.

To reproduce:

  1. Open a cider-repl
  2. M-x lispy-mode
  3. Eval:
    (for [x (range 2000) y (range 2000)]
    [(* x y)])
  4. Try lispy-parens or another lispy-pair-based command

Are others able to reproduce this?

I'm using Doom Emacs with lispy commit e9731aa95581, cider commit 2b8bde358063 and Emacs28 (repository-version fc8df2561b8e37089463d0d4d008d73e23cb2dc5).

joshcho commented 1 year ago

Same. Also an issue with lispy-delete-backward and special-lispy-raise. I am using the following as workaround, just default to paredit for commands with issues:

(define-key
 lispy-mode-map
 (kbd "(") (lambda ()
             (interactive)
             (if (equal major-mode 'cider-repl-mode)
                 (call-interactively
                  #'paredit-open-round)
               (call-interactively
                #'lispy-parens))))
(define-key
 lispy-mode-map
 (kbd "DEL") (lambda ()
               (interactive)
               (if (and (equal major-mode 'cider-repl-mode)
                        (eql (char-before)
                             ?\)
                             ))
                   (call-interactively
                    #'backward-delete-sexp)
                 (call-interactively
                  #'lispy-delete-backward))))
(define-key
 lispy-mode-map
 (kbd "r") (lambda ()
             (interactive)
             (cond ((and (equal major-mode 'cider-repl-mode)
                         (eql (char-after)
                              ?\(
                              ))
                    (call-interactively
                     #'paredit-raise-sexp))
                   ((and (equal major-mode 'cider-repl-mode)
                         (eql (char-before)
                              ?\)
                              ))
                    (call-interactively
                     #'lispy-different)
                    (call-interactively
                     #'paredit-raise-sexp)
                    (call-interactively
                     #'lispy-different))
                   (t
                    (call-interactively
                     #'special-lispy-raise)))))

A more persistent solution might be doing (what I assume is) internal parsing from after the prompt.