-
-
Notifications
You must be signed in to change notification settings - Fork 197
Description
Expected behavior
If sp-{forward,backward}-sexp (and all their related sister functions) is invoked in a position where there are no more balanced expressions to skip over, it should fail and not move the point. This is what built-in {forward,backward}-sexp does. Ie.
(foo (bar baz|)) → (foo (bar baz|))
=> forward-sexp: Scan error: "Containing expression ends prematurely", 387735, 387736
Admittedly, that's not a particularly helpful message, but the resulting behaviour is exactly as expected.
Actual behavior
It jumps up a level and starts operating on sexps there. This is documented as being so with no way to disable that fallback:
"Move forward across one balanced expression.
[...] If there is no forward expression, jump out of the current one (effectively doingsp-up-sexp).
This seems like it was meant as a convenience, but it effectively means the command will never stop doing things until it hits the end of file. That is a big problem because it means I now have to watch it closely and can't rely on it to tell me when I hit the end of the enclosing sexp, which defeats the purpose of having a structured navigation command do the paren matching for me. It's even more of a problem when writing code that uses it, as the result will silently change to something vastly different than what the promise was. In fact, I discovered the "fallback" when creating a keyboard macro to do some ad-hoc reformatting of a long list, as normally I can just hold F4 till it runs out of things to edit, since macros abort whenever a command fails, but with smartparens commands it just started applying the same commands in unrelated parts of the buffer.
As far as I can tell, the behaviour seems to be baked into sp-get-thing, so unless I'm mistaken, there's no way for any client code to reliably tell when it's at the end of an enclosed sexp?
Environment & version information
smartparensversion: 20200324.2147- Active
major-mode:emacs-lisp-mode - Smartparens strict mode: t
- Emacs version (
M-x emacs-version): GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14) of 2020-03-26, modified by Debian - Starterkit/Distribution: Ubuntu
- OS: gnu/linux