smartparens
smartparens copied to clipboard
sp-(forward|backward)-symbol issues in clojure
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)
_
For some reason the cursor stops before
#
which is not a symbol in clojure but a part of function definition macro #()
_
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)
_
Now the cursor moved to the closing bracket which is not a symbol and there is no symbol after a bracket
_
I keep calling
sp-forward-symbol
now the cursor is between :a
and 1
. Is :a
skipped for some reason?
_
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
_
sp-backward-symbol
works better but is stuck on #(
Etc....
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.
I skimmed through the code and it seems to me that the #()
also affects evil-cleverparens
that relies on smartparens for primitives definitions.
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.
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.