smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

sp-(forward|backward)-symbol issues in clojure

Open achikin opened this issue 3 years ago • 2 comments

Expected behavior

sp-forward-symbol moves to the next symbol correctly in Clojure Same for backward command

Actual behavior

The behavior of sp-forward-symbol is inconsistent on clojure syntax. Please see detailed explanations below. Same for backward command

Steps to reproduce the problem

If I place cursor on map and call sp-forward-symbol several times I observe the following behavior Captions are above images _ Initial position (the cursor is orange and blue denotes a pairing bracket) image _ For some reason the cursor stops before # which is not a symbol in clojure but a part of function definition macro #() image _ Now cursor is on an open bracket which is not a symbol (it looks like sp-forward-symbol stops on a position right before the symbol but I'm not sure if it is valid behavior because when you do sp-backward-symbol - the cursor stops on the first character of the symbol) image _ Now the cursor moved to the closing bracket which is not a symbol and there is no symbol after a bracket image _ I keep calling sp-forward-symbol now the cursor is between :a and 1. Is :a skipped for some reason? image _ Now the cursor is on 1 and any further calls to sp-forward-symbol does not move the cursor to :b as expected P.S. as suggested in https://github.com/Fuco1/smartparens/issues/1037 setting evil-move-beyond-eol to t fixes this issue image _ sp-backward-symbol works better but is stuck on #( image Screenshot 2020-11-08 at 17 26 52 image Etc.... image image Now the cursor is stuck and further calls to sp-backward-symbol do nothing.

Backtraces if necessary (M-x toggle-debug-on-error)

Environment & version information

In recent enough smartparens you can call M-x sp-describe-system to generate this report. Please fill manually what we could not detect automatically. Edit the output as you see fit to protect your privacy.

- `smartparens` version: 20201007.1753
- Active `major-mode`: `clojurescript-mode`
- Smartparens strict mode: t
- Emacs version (`M-x emacs-version`): GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2020-08-12
- Starterkit/Distribution: Spacemacs
- OS: darwin

Spacemacs is on develop branch.

achikin avatar Nov 08 '20 14:11 achikin

I skimmed through the code and it seems to me that the #() also affects evil-cleverparens that relies on smartparens for primitives definitions.

achikin avatar Nov 08 '20 15:11 achikin

For the first point, ending after map is correct, we end on the first character after the symbol. However, moving by paren is definitely odd.

The situation with :a is the same, we jump after the symbol. Not on the beginning. You can call backward version immediately after and that should jump to the beginning of the symbol.

Fuco1 avatar Dec 24 '20 14:12 Fuco1

Maybe there is a confusion about what is called symbol in clojure syntax and what is called symbol in emacs "buffer syntax". Emacs has its own syntactic naming conventions codified in syntax tables. Basically any word is a symbol, such as identity here is a symbol, because it's a "word". Not only :a is a symbol, which semantically within clojure is a keyword or something but that's not what we mean by saying symbol within smartparens.

The only bug here is that it considers the # prefix as a symbol in itself.

Fuco1 avatar Mar 30 '24 19:03 Fuco1