Closed bhrgunatha closed 6 months ago
I could not reproduce this on emacs 25. I think E26 redefined some of the syntax properties of these characters and it breaks the code.
Can you confirm this only happens when there are quotes in the sexp and not at other times so we can narrow this down as much as possible? Thanks!
I haven't noticed problems with no quoted symbols but obviously I can't prove it. In fact experimenting I think it's when there are 2 (or maybe more quotes).
I called sp-clone-exp
at every position on the line and recorded the results.
The result remains the same up to a certain position, then the result changes and that changed result is consistent up to the next position where another change occurs. That seems correct to me as the cursor moves along the structure of the sexp.
This seems correct to me. I get the same behaviour with more complex examples (foo (bar) baz qux)
- (foo (bar (baz qux)) quux)
- (foo (bar) "baz" qux)
Before:
|(foo (bar) baz)
After:
(foo (bar) baz)
|(foo (bar) baz)
.. same results until:
Before:
(foo| (bar) baz)
After:
(foo (bar)
|(bar) baz)
.. same results until:
Before:
(foo (bar)| baz)
After:
(foo (bar) baz)
(foo (bar)| baz)
.. same results until:
Before:
(foo (bar)| baz)|
After:
(foo (bar) baz)|
(foo (bar) 'baz qux)
This also seems correct to me.
It seems to go wrong when there are 2 or more quoted symbols. I get the same incorrect result whether the sexp is one one line or split up onto 2.
Before:
(foo (bar)| 'baz 'qux)
After:
(foo (bar) 'baz '
| 'baz 'qux)
.. same results until:
Before:
(foo (bar) 'baz '|qux)
After:
(foo (bar) 'baz 'qux)
(foo (bar) 'baz '|qux)
which now seems correct.
Thanks for the detailed report, this will be useful!
I have added test cases from the OP and the later post (7 in total) and they all pass now. We will have them there for future regressions. As I can't reproduce this now I will close this since I can't do anything more at this moment.
Expected behavior
sp-clone-sexp
should recognise quoted and sharp-quoted identifiers within an sexp and clone that sexp.Actual behavior
The clone operation leaves a malformed sexp split up over 2 lines and sometimes clones the "grandparent" sexp instead of the "parent".
Steps to reproduce the problem
Entire buffer contents:
Cursor is represented by "|"
First example:
Place cursor inside the first define-key sexp e.g.
(define-key smartparens-|mode-map (kbd "C-, C-y") #'sp-clone-sexp)
M-x sp-clone-sexp
Result:
Note the #' to end the line and on the next line 'paredit
Second example: Same starting buffer state as above:
Place cursor inside the first setq sexp e.g.
(setq |sp-base-key-bindings 'paredit)
M-x sp-clone-sexp
Result:
Backtraces if necessary (
M-x toggle-debug-on-error
)None
Environment & version information
In recent enough
smartparens
you can callM-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: 20181007.1501major-mode
:emacs-lisp-mode
M-x emacs-version
): GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2018-07-05