-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot correctly detect doc if using single quote in Inferior Python mode. #87
Comments
Hi, thanks for reporting this and for the reproduction details 👍 Unfortunately I think this is due to a bug in inferior python mode's parsing. electric-operator relies on the major mode to tell it if it is currently inside a string or not, and for some reason inferior python mode claims that |
Thank for you for explain. I guess I have to file a issue to Emacs develop group. |
Hi! Maybe we can just add the test like this?
|
Yeah something like that is what I meant, the issue is that in order to
correctly implement my-own-single-quote-test you would need to write a
parser. Here are some examples to think about:
```
>> ' '
>> " ' "
>> '\'
>> ">>> ' "
>> """
' '
>> " ' " '
```
In fact it's even harder than I thought because if the buffer contains
```
>> x = '
Syntax error blah blah blah
>> [point here]
```
then we need to recognise that the unbalanced quote doesn't make the rest
of the buffer into a string.
If you're still interested you could give it a try and send a PR (although
make sure it has tests for all of those cases and all similar ones you can
come up with), but I think it would be much easier to fix the existing
parser. Maybe it's even already fixed in one of the unstable releases of
emacs.
…On Mon, 8 Jul 2019, 08:03 yanghaoxie, ***@***.***> wrote:
Hi!
I wonder is there a simple workaround that we test ' ourself (in
electric-operator-in-docs?) instead using syntax-ppss in inferior python
mode .
Maybe we can just add the test like this?
(defun electric-operator-in-docs? ()
"Check if we are inside a string or comment"
(or (nth 8 (syntax-ppss))
(my-own-single-quote-test-in-inferior-python-mode)))
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#87?email_source=notifications&email_token=AAGCJVEYIJDMCQ7T5LB3RGLP6LRDJA5CNFSM4H5YKM62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZMFGKQ#issuecomment-509104938>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGCJVCPS65DRLAVM3MYPN3P6LRDJANCNFSM4H5YKM6Q>
.
|
Thank you so much for you comprehensive explanation. Sounds like it is much harder than I thought. By the way, I am using the Emacs 27.0.50, it seems like that this is still a issue. Anyway, thank you very much! 👍 |
No problem, glad it helped 🙂
Oh, that's a shame. |
If your issue is a bug, please provide me with some information to help reproduce it. If it's a feature request then
you can ignore this template.
Reproducing
scenario 1.
If I first input
"
, then input/
, it will produce>>> "/
scenario 2.
If I first input
'
, then input/
, it will produce>>> ' /
You see, in scenario 1, there is no extra space, since I trying insert string. However in scenario 2, I use single quote, there is an extra space.
Other useful info
electric-operator-enable-in-docs
isnil
The text was updated successfully, but these errors were encountered: