Closed aldanor closed 4 years ago
Looks like adding
(add-hook 'ein:notebook-multilang-mode-hook 'smartparens-mode)
to post-init-ein
should be sufficient to address the first problem.
The second problem (closing parenthesis on one line erroneously duplicates it and closes it on the next line) seems to also be present in python-mode
which is quite frustrating.
@StreakyCobra Does this have something to do with your trick?
Unless dotspacemacs-smart-closing-parenthesis
is set to t
(what shouldn't be the case by default), it shouldn't have any effect on Spacemacs, buuut…
I can indeed reproduce the Python bug when it's activated, it's related to the use of sp-navigate-close-if-unbalanced t
in the function, turning it off makes this bug disappear. So I would say it's a bug between smartparens and python as I don't notice this behaviour in other modes, like in sh-mode
for instance.
@aldanor I suppose you also have dotspacemacs-smart-closing-parenthesis
set to t
, it's what is causing your bug, try turning it off.
Keeping sp-navigate-close-if-unbalanced
set to t
is useful for this kind of case:
Starting with the following text (not in the last line of the file, this is a limitation of smartparens, no idea why…):
([auie
And pressing two times a closing parenthesis ())
):
When set to t
:
([auie])
When set to nil
:
([auie))
@StreakyCobra Indeed turning dotspacemacs-smart-closing-parenthesis
off fixes the second problem. I was actually using it for another feature: in the following example
(auie
navigate the cursor between au
and ie
. and press )
:
(auie)
and the cursor jumps to the end.(au)ie
.
Kind of sad to have to disable it in Python. Btw I couldn't find any matching issues in smartparens
repo upstream.Yes I added this feature recently because it was really useful for dealing with closing parenthesis (bracket, quote, etc.) in a lot of ways. The implementation is more like a hack on top of smartparens, but it's an elegant hack (from my point of view at least, but I'm probably biased :wink:)
I am able to reproduce this with a minimum configuration:
SPC q D
, enter smartparens
and validatesmartparens
loadedC-x C-f test.py
to open a python fileM-x smartparens-mode
sp-navigate-close-if-unbalanced
with M-: (setq sp-navigate-close-if-unbalanced t)
Enter the following content:
foo(
bar()
sp-up-sexp
with M-x sp-up-sexp
You can observe the wrong behaviour giving this:
foo(
bar)()
So it seems to be a smartparens
bug (if it is a bug at all, maybe it's the expected behaviour?).
I don't have a lot of time these days, so I encourage you to report it upstream to smartparens
:smiley: You can give them the reproduction steps and eventually point them to this link if you do it.
@StreakyCobra Yea, looks like it happens in all prog modes, not just Python (e.g. fire a scratch buffer with prog-mode and the error is the same).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!
Description
Smart parentheses are not behaving well in
ipython-notebook
(proper modes not enabled?).Reproduction guide
SPC a i n
print()
in a new cell, observe the error; you may or may not be able to close the parenthesisThen, delete the closing parenthesis of
foo()
and type it again. You then end up with something like this:foo('bar')
. You will end up withObserved behaviour:
smartparens-mode
andsmartparens-global-mode
are enabled in Python buffers but not enabled inipython-notebook
layer. This leads to some weird behaviour when trying to close parentheses, sometimes extra parens are inserted or it won't let you close them at all. In any case, the error message is: "Search failed. This means there is an unmatched expression somewhere or we are at the beginning/end of file.", which seems to be an:unmatched-expression
error thrown insp-get-paired-expression
.Enabling
smartparens-mode
andsmartparens-global-mode
seems to fix it, but I'm not sure how it should be fixed properly.System Info