abo-abo / lispy

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

paredit mode emulation: delete/backspace quirks #68

Open immerrr opened 9 years ago

immerrr commented 9 years ago

I have encountered some quirks in lispy's paredit emulation of delete/backspace.

In paredit AFAIR backspace logic is pretty straightforward, it doesn't get in the way while maintaining the structure of the document:

For <delete> the logic is inverted, but the idea is the same.

In lispy the following weird things happen:

abo-abo commented 9 years ago

in "|" situation empty quotes are not deleted (same issue for delete) in "|foobar" situation point jumps to the end of the string in (|foobar) situation the sexp is deleted (same issue for delete and the other side of sexp) in (|) situation sexp is deleted (which is correct), but an extra space is left instead, so foo(|) becomes foo|

That's quite a few things. Could you make a couple failing tests for this? Just have a look at lispy-test.el, it's pretty straightforward. Then I could repair the behavior much faster.

curly braces seem utterly broken (trying to delete in either direction {|} situation removes external sexps)

This is the issue with emacs-lisp-mode, not lispy. emacs-lisp-mode doesn't define { and } as pairs, but as symbol parts. The braces work fine for Clojure and Scheme, but don't work for Elisp and CL.

immerrr commented 9 years ago

This is the issue with emacs-lisp-mode, not lispy. emacs-lisp-mode doesn't define { and } as pairs, but as symbol parts. The braces work fine for Clojure and Scheme, but don't work for Elisp and CL.

Then probably lispy could treat them as symbol parts, not as special characters.

abo-abo commented 9 years ago

Then probably lispy could treat them as symbol parts, not as special characters.

I tried this at some point, it doesn't work because of a bug in setq-mode-local. Basically lispy-left needs to be "[([]" in emacs-lisp-mode and "[([{]" in clojure-mode.

So currently it's just "[([{]" everywhere. Not really a big deal, since { has no place in Elisp anyway, it's usually entered by mistyping.

immerrr commented 9 years ago

it's usually entered by mistyping.

Exactly. And when I try to correct the typo with backspace -- boom -- it deletes the whole sexp around it.

abo-abo commented 9 years ago

Until I figure out setq-mode-local, you can add this to your config:

(setq-local lispy-left "[([]")
(setq-local lispy-right "[])]")
sooheon commented 9 years ago

I wanted to take a stab at writing some of those failing tests, first time using ert so I have a couple questions.

If I download lisps-test.el and M-x ert-run-tests-buffer, should all of the current ones be passing regardless of my personal lispy configuration and keybindings? Over half are failing.

Selector: t
Passed:  53
Failed:  63 (63 unexpected)
Skipped: 0
Total:   116/116

Started at:   2015-08-01 05:42:58+0900
Finished.
Finished at:  2015-08-01 05:43:39+0900

F...F....FFFF.FF.FFFFFFF.FFFF.FF.FFFF.F.....F.FFF.F.FF.FFFFF..F..F.F.F..F......FF.F.....FFFFFFFFFFF..FFFF....FF.....
abo-abo commented 9 years ago

If I download lisps-test.el and M-x ert-run-tests-buffer, should all of the current ones be passing regardless of my personal lispy configuration and keybindings? Over half are failing.

I recommend to do:

git clone https://github.com/abo-abo/lispy/
cd lispy/
make test

The make test command will start a fresh Emacs instance, with zero customization. In that case, all tests should pass. This command is run on Travis CI each time I commit (or anyone opens a PR), for Emacs 24 and 25.

abo-abo commented 9 years ago

Even more convenient is to run M-x compile and enter make test. In that case, you see the results in a *compilation* window.

sooheon commented 9 years ago

Following your directions I get:

Using /usr/local/bin/emacs...
emacs -batch -l elpa.el -l lispy-test.el -l lispy-inline.el -l lispy.el -f ert-run-tests-batch-and-exit
Cannot open load file: no such file or directory, avy
make: *** [test] Error 255

So I guess it expects avy as well? In what relative directory does it look for it?

abo-abo commented 9 years ago

So I guess it expects avy as well? In what relative directory does it look for it?

Oh, you need to issue make cask to install all dependencies into the current directory. Then make test.