unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48609: Eglot and tab-always-indent conflict in python-mode
@ 2021-05-23 14:55 Pankaj Jangid
  2021-05-23 20:41 ` João Távora
  0 siblings, 1 reply; 11+ messages in thread
From: Pankaj Jangid @ 2021-05-23 14:55 UTC (permalink / raw)
  To: 48609; +Cc: joaotavora

If ‘eglot’ is running and ‘tab-always-indent’ is set to ’complete. Then
in python-mode, TAB doesn’t cycle point column positions. For example,
in the following code if you are at end of line 2 and then you press RET
then TAB doesn’t move the point to left margin. Without ‘eglot’ this
works fine.

#+begin_src python
def greet(s):
    print(f"Hello {s}!")
#+end_src





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-23 14:55 bug#48609: Eglot and tab-always-indent conflict in python-mode Pankaj Jangid
@ 2021-05-23 20:41 ` João Távora
  2021-05-23 21:02   ` Doug Davis
  0 siblings, 1 reply; 11+ messages in thread
From: João Távora @ 2021-05-23 20:41 UTC (permalink / raw)
  To: 48609

Pankaj Jangid <pankaj@codeisgreat.org> writes:

> If ‘eglot’ is running and ‘tab-always-indent’ is set to ’complete. Then
> in python-mode, TAB doesn’t cycle point column positions. For example,
> in the following code if you are at end of line 2 and then you press RET
> then TAB doesn’t move the point to left margin. Without ‘eglot’ this
> works fine.
>
> #+begin_src python
> def greet(s):
>     print(f"Hello {s}!")
> #+end_src

Hello Pankaj,

I cannot reproduce this.  Here's what I ran:

  $ emacs --version | head -1
  GNU Emacs 26.3
  $ emacs -Q -f package-initialize -L ~/path/to/eglot/eglot -l eglot \
    ~/path/to/a/python/file.py -f eglot

This opens the file which has your example contents, and starts up
eglot.  I move point to the end of line 2, press RET and press TAB
twice.  Point is at the left margin.

Without Eglot, the result is exactly the same.

I would find it odd that Eglot messes with TAB behaviour, but I'm
waiting for a more complete reproduction recipe from your part so we can
understand what's going on.

João









^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-23 20:41 ` João Távora
@ 2021-05-23 21:02   ` Doug Davis
  2021-05-23 21:17     ` João Távora
  0 siblings, 1 reply; 11+ messages in thread
From: Doug Davis @ 2021-05-23 21:02 UTC (permalink / raw)
  To: João Távora; +Cc: 48609

Hi João & Pankaj,

João Távora <joaotavora@gmail.com> writes:

> Pankaj Jangid <pankaj@codeisgreat.org> writes:
>
>> If ‘eglot’ is running and ‘tab-always-indent’ is set to ’complete. Then
>> in python-mode, TAB doesn’t cycle point column positions. For example,
>> in the following code if you are at end of line 2 and then you press RET
>> then TAB doesn’t move the point to left margin. Without ‘eglot’ this
>> works fine.
>>
>> #+begin_src python
>> def greet(s):
>>     print(f"Hello {s}!")
>> #+end_src
>
> Hello Pankaj,
>
> I cannot reproduce this.  Here's what I ran:
>
>   $ emacs --version | head -1
>   GNU Emacs 26.3
>   $ emacs -Q -f package-initialize -L ~/path/to/eglot/eglot -l eglot \
>     ~/path/to/a/python/file.py -f eglot

Just driving by, hopefully this is helpful; it looks like company may be
the missing ingredient. If I follow these steps but add:
`-L ~/path/to/company -l company`, run both

M-x company-mode
and
M-x eglot

with `tab-always-indent' set to 'complete I'm able to reproduce the
issue described by Pankaj. If I skip loading Eglot but only use company
the issue doesn't surface.

Cheers,
Doug





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-23 21:02   ` Doug Davis
@ 2021-05-23 21:17     ` João Távora
  2021-05-23 21:38       ` João Távora
  0 siblings, 1 reply; 11+ messages in thread
From: João Távora @ 2021-05-23 21:17 UTC (permalink / raw)
  To: Doug Davis; +Cc: 48609

Doug Davis <ddavis@ddavis.io> writes:

> Hi João & Pankaj,
>
> João Távora <joaotavora@gmail.com> writes:
>
>> Pankaj Jangid <pankaj@codeisgreat.org> writes:
>>
>>> If ‘eglot’ is running and ‘tab-always-indent’ is set to ’complete. Then
>>> in python-mode, TAB doesn’t cycle point column positions. For example,
>>> in the following code if you are at end of line 2 and then you press RET
>>> then TAB doesn’t move the point to left margin. Without ‘eglot’ this
>>> works fine.
>>>
>>> #+begin_src python
>>> def greet(s):
>>>     print(f"Hello {s}!")
>>> #+end_src
>>
>> Hello Pankaj,
>>
>> I cannot reproduce this.  Here's what I ran:
>>
>>   $ emacs --version | head -1
>>   GNU Emacs 26.3
>>   $ emacs -Q -f package-initialize -L ~/path/to/eglot/eglot -l eglot \
>>     ~/path/to/a/python/file.py -f eglot
>
> Just driving by, hopefully this is helpful; it looks like company may be
> the missing ingredient.

No, it wasn't, but indeed, there was a missing ingredient.  I had
forgotten to set tab-always-indent to 'complete.

With this recipe, I can reproduce the bug:

   $ emacs -Q -f package-initialize -L ~/path/to/eglot/eglot -l eglot  \
     ~/path/to/a/python/file.py                                        \
     --eval '(setq tab-always-indent (quote complete))' -f eglot

Don't know what's up, though.  Going to have a better look.

João






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-23 21:17     ` João Távora
@ 2021-05-23 21:38       ` João Távora
  2021-05-24  8:17         ` Andrii Kolomoiets
  2021-05-25  6:47         ` Pankaj Jangid
  0 siblings, 2 replies; 11+ messages in thread
From: João Távora @ 2021-05-23 21:38 UTC (permalink / raw)
  To: Doug Davis, pankaj; +Cc: 48609

João Távora <joaotavora@gmail.com> writes:

> Doug Davis <ddavis@ddavis.io> writes:
>
>> Hi João & Pankaj,
>>
>> João Távora <joaotavora@gmail.com> writes:
>>
>>> Pankaj Jangid <pankaj@codeisgreat.org> writes:
>>>
>>>> If ‘eglot’ is running and ‘tab-always-indent’ is set to ’complete. Then
>>>> in python-mode, TAB doesn’t cycle point column positions. For example,
>>>> in the following code if you are at end of line 2 and then you press RET
>>>> then TAB doesn’t move the point to left margin. Without ‘eglot’ this
>>>> works fine.
>>>>
>>>> #+begin_src python
>>>> def greet(s):
>>>>     print(f"Hello {s}!")
>>>> #+end_src
>>>
>>> Hello Pankaj,
>>>
>>> I cannot reproduce this.  Here's what I ran:
>>>
>>>   $ emacs --version | head -1
>>>   GNU Emacs 26.3
>>>   $ emacs -Q -f package-initialize -L ~/path/to/eglot/eglot -l eglot \
>>>     ~/path/to/a/python/file.py -f eglot
>>
>> Just driving by, hopefully this is helpful; it looks like company may be
>> the missing ingredient.
>
> No, it wasn't, but indeed, there was a missing ingredient.  I had
> forgotten to set tab-always-indent to 'complete.
>
> With this recipe, I can reproduce the bug:
>
>    $ emacs -Q -f package-initialize -L ~/path/to/eglot/eglot -l eglot  \
>      ~/path/to/a/python/file.py                                        \
>      --eval '(setq tab-always-indent (quote complete))' -f eglot
>
> Don't know what's up, though.  Going to have a better look.

I see what's up.  When Eglot is turned on, having tab-always-indent set
to 'complete means that the first TAB press after pressing RET will
actually try to complete things.

When Eglot is active, the completion system can find a large number of
completions available for that empty line.  Since you have selected
tab-always-indent to be 'complete, Eglot will request and present those
completions in the *Completions* buffer.

The only way to cancel that operation is by C-g or clicking somewhere
else.  This in turn makes it so that the "last" command issued isn't
indent-for-tab-command anymore, and so there aren't two
indent-for-tab-command commands in a row.  And that is the criteria
consulted by python.el's indentation function to decide to cycle the
indentation.

So I'm not sure what needs to be fixed here, if anything, or how you
would like this to behave.

João.






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-23 21:38       ` João Távora
@ 2021-05-24  8:17         ` Andrii Kolomoiets
  2021-05-25  6:41           ` Pankaj Jangid
  2021-05-25  6:47         ` Pankaj Jangid
  1 sibling, 1 reply; 11+ messages in thread
From: Andrii Kolomoiets @ 2021-05-24  8:17 UTC (permalink / raw)
  To: João Távora; +Cc: Doug Davis, 48609, pankaj

João Távora <joaotavora@gmail.com> writes:

> So I'm not sure what needs to be fixed here, if anything, or how you
> would like this to behave.

IMO works as described in the `tab-always-indent` docstring:

If ‘complete’, TAB first tries to indent the current line, and if the line
was already indented, then try to complete the thing at point.

One can reproduce this without Eglot:

1. emacs -Q
2. C-x C-f test.py
3. M-: (setq tab-always-indent 'complete)
4. C-c C-p

After step 4 the `python-completion-at-point` function starts producing
completions and each TAB key will lead to "No match" message.

Pankaj, take a look at the `tab-first-completion` variable.


--
Andrii





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-24  8:17         ` Andrii Kolomoiets
@ 2021-05-25  6:41           ` Pankaj Jangid
  2021-05-25  9:32             ` João Távora
  0 siblings, 1 reply; 11+ messages in thread
From: Pankaj Jangid @ 2021-05-25  6:41 UTC (permalink / raw)
  To: Andrii Kolomoiets; +Cc: Doug Davis, 48609, João Távora

Andrii Kolomoiets <andreyk.mad@gmail.com> writes:

> IMO works as described in the `tab-always-indent` docstring:
>
> If ‘complete’, TAB first tries to indent the current line, and if the line
> was already indented, then try to complete the thing at point.

Thanks for sharing this. I think I should have been more specific. The
bug is more related to python-mode then to ‘tab-always-indent’.

In ‘python’ buffers, TABs cycle position of point. But as described in
my original report and reproduced by João, bringing Eglot, inhibits this
behavior. 






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-23 21:38       ` João Távora
  2021-05-24  8:17         ` Andrii Kolomoiets
@ 2021-05-25  6:47         ` Pankaj Jangid
  2021-05-25  9:36           ` João Távora
  1 sibling, 1 reply; 11+ messages in thread
From: Pankaj Jangid @ 2021-05-25  6:47 UTC (permalink / raw)
  To: João Távora; +Cc: Doug Davis, 48609

João Távora <joaotavora@gmail.com> writes:

> When Eglot is active, the completion system can find a large number of
> completions available for that empty line.  Since you have selected
> tab-always-indent to be 'complete, Eglot will request and present those
> completions in the *Completions* buffer.
>
> The only way to cancel that operation is by C-g or clicking somewhere
> else.  This in turn makes it so that the "last" command issued isn't
> indent-for-tab-command anymore, and so there aren't two
> indent-for-tab-command commands in a row.  And that is the criteria
> consulted by python.el's indentation function to decide to cycle the
> indentation.
>
> So I'm not sure what needs to be fixed here, if anything, or how you
> would like this to behave.

I think that the best place should be python.el then. A variable
‘python-completion-on-empty-line’ or some better name. I don’t know if
such a variable already exist or not. Need to check.

Since the point-position is cycled by python.el, that is the place where
it should be configured.






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-25  6:41           ` Pankaj Jangid
@ 2021-05-25  9:32             ` João Távora
  0 siblings, 0 replies; 11+ messages in thread
From: João Távora @ 2021-05-25  9:32 UTC (permalink / raw)
  To: Pankaj Jangid; +Cc: Doug Davis, 48609, Andrii Kolomoiets

Pankaj Jangid <pankaj@codeisgreat.org> writes:

> Andrii Kolomoiets <andreyk.mad@gmail.com> writes:
>
>> IMO works as described in the `tab-always-indent` docstring:
>>
>> If ‘complete’, TAB first tries to indent the current line, and if the line
>> was already indented, then try to complete the thing at point.
>
> Thanks for sharing this. I think I should have been more specific. The
> bug is more related to python-mode then to ‘tab-always-indent’.
>
> In ‘python’ buffers, TABs cycle position of point. But as described in
> my original report and reproduced by João, bringing Eglot, inhibits this
> behavior.

Yes, but what actually happened is that the one of those tabs was
waiting for completions to come in, so the system was indeed behaving as
intended.  It's just that when you don't have Eglot, you also don't have
completions.

João





^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-25  6:47         ` Pankaj Jangid
@ 2021-05-25  9:36           ` João Távora
  2021-05-25 14:08             ` Pankaj Jangid
  0 siblings, 1 reply; 11+ messages in thread
From: João Távora @ 2021-05-25  9:36 UTC (permalink / raw)
  To: Pankaj Jangid; +Cc: Doug Davis, 48609

Pankaj Jangid <pankaj@codeisgreat.org> writes:

> João Távora <joaotavora@gmail.com> writes:
>
>> When Eglot is active, the completion system can find a large number of
>> completions available for that empty line.  Since you have selected
>> tab-always-indent to be 'complete, Eglot will request and present those
>> completions in the *Completions* buffer.
>>
>> The only way to cancel that operation is by C-g or clicking somewhere
>> else.  This in turn makes it so that the "last" command issued isn't
>> indent-for-tab-command anymore, and so there aren't two
>> indent-for-tab-command commands in a row.  And that is the criteria
>> consulted by python.el's indentation function to decide to cycle the
>> indentation.
>>
>> So I'm not sure what needs to be fixed here, if anything, or how you
>> would like this to behave.
>
> I think that the best place should be python.el then. A variable
> ‘python-completion-on-empty-line’ or some better name. I don’t know if
> such a variable already exist or not. Need to check.

Yes, I agree, python.el.  I wonder if instead of that variale the
cycling logic could be changed to account for this case where there may
be completions at point (Eglot is only one possible provider of such
completions, btw.)

João






^ permalink raw reply	[flat|nested] 11+ messages in thread

* bug#48609: Eglot and tab-always-indent conflict in python-mode
  2021-05-25  9:36           ` João Távora
@ 2021-05-25 14:08             ` Pankaj Jangid
  0 siblings, 0 replies; 11+ messages in thread
From: Pankaj Jangid @ 2021-05-25 14:08 UTC (permalink / raw)
  To: João Távora; +Cc: Doug Davis, 48609

João Távora <joaotavora@gmail.com> writes:

>>> When Eglot is active, the completion system can find a large number of
>>> completions available for that empty line.  Since you have selected
>>> tab-always-indent to be 'complete, Eglot will request and present those
>>> completions in the *Completions* buffer.
>>>
>>> The only way to cancel that operation is by C-g or clicking somewhere
>>> else.  This in turn makes it so that the "last" command issued isn't
>>> indent-for-tab-command anymore, and so there aren't two
>>> indent-for-tab-command commands in a row.  And that is the criteria
>>> consulted by python.el's indentation function to decide to cycle the
>>> indentation.
>>>
>>> So I'm not sure what needs to be fixed here, if anything, or how you
>>> would like this to behave.
>>
>> I think that the best place should be python.el then. A variable
>> ‘python-completion-on-empty-line’ or some better name. I don’t know if
>> such a variable already exist or not. Need to check.
>
> Yes, I agree, python.el.  I wonder if instead of that variale the
> cycling logic could be changed to account for this case where there may
> be completions at point (Eglot is only one possible provider of such
> completions, btw.)

CC’ing Fabián.






^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-05-25 14:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-23 14:55 bug#48609: Eglot and tab-always-indent conflict in python-mode Pankaj Jangid
2021-05-23 20:41 ` João Távora
2021-05-23 21:02   ` Doug Davis
2021-05-23 21:17     ` João Távora
2021-05-23 21:38       ` João Távora
2021-05-24  8:17         ` Andrii Kolomoiets
2021-05-25  6:41           ` Pankaj Jangid
2021-05-25  9:32             ` João Távora
2021-05-25  6:47         ` Pankaj Jangid
2021-05-25  9:36           ` João Távora
2021-05-25 14:08             ` Pankaj Jangid

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).