unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* python mode bugs
@ 2018-04-05 19:50 James K. Lowden
  2018-04-05 21:02 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: James K. Lowden @ 2018-04-05 19:50 UTC (permalink / raw)
  To: help-gnu-emacs

I have two problems with python.el.  Maybe three.  

1.  GNU bug report logs - #29717[1]: imenu does not recognize function
definitions with annotations.  

2.  imenu is purportedly bound to C-c C-j, but no "index" I supply
returns anything but errors.  What does it want?  

3.  At 111 days old, it doesn't seem like the known bug is getting any
attention.  What is the polite way to indicate it matters?  

In case you *really* want to help, the offending function appears to be 

	python-imenu--build-tree

and the regex

	python-nav-beginning-of-defun-regexp

The difference in the pattern to be matched is: 

	def f(a, b): #works
vs
	def f(a: int, b: str) -> bool: # fails

FWIW, I don't think the regex need include anything after the leading
parenthesis.  The following awk script is too simple because it doesn't
recognize nested functions and class methods, but otherwise does the
trick: 

	awk -F'[\t ()]' '/^def +/ {print $2}'

Any help much appreciated.  

--jkl
[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29717


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

* Re: python mode bugs
  2018-04-05 19:50 python mode bugs James K. Lowden
@ 2018-04-05 21:02 ` Stefan Monnier
  2018-04-05 22:11 ` Ben Bacarisse
  2018-05-01 18:16 ` James K. Lowden
  2 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2018-04-05 21:02 UTC (permalink / raw)
  To: help-gnu-emacs

> 3.  At 111 days old, it doesn't seem like the known bug is getting any
> attention.  What is the polite way to indicate it matters?  

You can send a new message to that bug-report with a shirt content like
"ping?" or "Is anybody here?  it's been 111 days and I still haven't
heard anything".

Even better, you can add info such as the one you provide below:

> In case you *really* want to help, the offending function appears to be 
>
> 	python-imenu--build-tree
>
> and the regex
>
> 	python-nav-beginning-of-defun-regexp
>
> The difference in the pattern to be matched is: 
>
> 	def f(a, b): #works
> vs
> 	def f(a: int, b: str) -> bool: # fails
>
> FWIW, I don't think the regex need include anything after the leading
> parenthesis.  The following awk script is too simple because it doesn't
> recognize nested functions and class methods, but otherwise does the
> trick: 
>
> 	awk -F'[\t ()]' '/^def +/ {print $2}'

which might allow even Emacs contributors not familiar with Python to
come up with a fix.


        Stefan




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

* Re: python mode bugs
  2018-04-05 19:50 python mode bugs James K. Lowden
  2018-04-05 21:02 ` Stefan Monnier
@ 2018-04-05 22:11 ` Ben Bacarisse
  2018-04-06 10:37   ` Robert Pluim
       [not found]   ` <mailman.11778.1523011049.27995.help-gnu-emacs@gnu.org>
  2018-05-01 18:16 ` James K. Lowden
  2 siblings, 2 replies; 13+ messages in thread
From: Ben Bacarisse @ 2018-04-05 22:11 UTC (permalink / raw)
  To: help-gnu-emacs

"James K. Lowden" <jklowden@speakeasy.net> writes:

> I have two problems with python.el.  Maybe three.  
>
> 1.  GNU bug report logs - #29717[1]: imenu does not recognize function
> definitions with annotations.  
>
> 2.  imenu is purportedly bound to C-c C-j, but no "index" I supply
> returns anything but errors.  What does it want?

It wants the name of a class or a function and will auto-complete but if
imenu is not finding and to start with there will be nothing you enter
here!

> 3.  At 111 days old, it doesn't seem like the known bug is getting any
> attention.  What is the polite way to indicate it matters?

Some people say "Ping?".

> In case you *really* want to help, the offending function appears to be 
>
> 	python-imenu--build-tree
>
> and the regex
>
> 	python-nav-beginning-of-defun-regexp
>
> The difference in the pattern to be matched is: 
>
> 	def f(a, b): #works
> vs
> 	def f(a: int, b: str) -> bool: # fails

The pattern in python-nav-beginning-of-defun-regexp does not seem to be
the culprit.  It matches both of these.

> FWIW, I don't think the regex need include anything after the leading
> parenthesis.

Yes, that's what python-nav-beginning-of-defun-regexp does.  Nothing
after the name is examined.  In fact, it matches a def with no '(' at all.

The problem appears to be somewhere else, most likely in
python-imenu--build-tree as you say.

> [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29717
-- 
Ben.


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

* Re: python mode bugs
  2018-04-05 22:11 ` Ben Bacarisse
@ 2018-04-06 10:37   ` Robert Pluim
       [not found]   ` <mailman.11778.1523011049.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Robert Pluim @ 2018-04-06 10:37 UTC (permalink / raw)
  To: Ben Bacarisse; +Cc: help-gnu-emacs

Ben Bacarisse <ben.lists@bsb.me.uk> writes:

> "James K. Lowden" <jklowden@speakeasy.net> writes:
>
>> I have two problems with python.el.  Maybe three.  
>>
>> 1.  GNU bug report logs - #29717[1]: imenu does not recognize function
>> definitions with annotations.  
>>
>> 2.  imenu is purportedly bound to C-c C-j, but no "index" I supply
>> returns anything but errors.  What does it want?

Which version of emacs are you using? This seems to work fine for me
in Emacs 26 and 27.

Robert



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

* Re: python mode bugs
       [not found]   ` <mailman.11778.1523011049.27995.help-gnu-emacs@gnu.org>
@ 2018-04-06 10:47     ` Ben Bacarisse
  2018-04-06 12:43       ` Robert Pluim
       [not found]       ` <mailman.11780.1523018635.27995.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Ben Bacarisse @ 2018-04-06 10:47 UTC (permalink / raw)
  To: help-gnu-emacs

Robert Pluim <rpluim@gmail.com> writes:

> Ben Bacarisse <ben.lists@bsb.me.uk> writes:
>
>> "James K. Lowden" <jklowden@speakeasy.net> writes:
>>
>>> I have two problems with python.el.  Maybe three.  
>>>
>>> 1.  GNU bug report logs - #29717[1]: imenu does not recognize function
>>> definitions with annotations.  
>>>
>>> 2.  imenu is purportedly bound to C-c C-j, but no "index" I supply
>>> returns anything but errors.  What does it want?
>
> Which version of emacs are you using? This seems to work fine for me
> in Emacs 26 and 27.

You don't quote anything I said but you might be asking me too.  So,
just in case, I'm using 25.1.1.

-- 
Ben.


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

* Re: python mode bugs
  2018-04-06 10:47     ` Ben Bacarisse
@ 2018-04-06 12:43       ` Robert Pluim
       [not found]       ` <mailman.11780.1523018635.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Robert Pluim @ 2018-04-06 12:43 UTC (permalink / raw)
  To: Ben Bacarisse; +Cc: help-gnu-emacs

Ben Bacarisse <ben.lists@bsb.me.uk> writes:

> Robert Pluim <rpluim@gmail.com> writes:
>
>> Ben Bacarisse <ben.lists@bsb.me.uk> writes:
>>
>>> "James K. Lowden" <jklowden@speakeasy.net> writes:
>>>
>>>> I have two problems with python.el.  Maybe three.  
>>>>
>>>> 1.  GNU bug report logs - #29717[1]: imenu does not recognize function
>>>> definitions with annotations.  
>>>>
>>>> 2.  imenu is purportedly bound to C-c C-j, but no "index" I supply
>>>> returns anything but errors.  What does it want?
>>
>> Which version of emacs are you using? This seems to work fine for me
>> in Emacs 26 and 27.
>
> You don't quote anything I said but you might be asking me too.  So,
> just in case, I'm using 25.1.1.

Hmm, C-c C-j doesnʼt have an issue for me in 25.1. This happens from
emacs -Q as well?

Robert



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

* Re: python mode bugs
       [not found]       ` <mailman.11780.1523018635.27995.help-gnu-emacs@gnu.org>
@ 2018-04-06 13:29         ` Ben Bacarisse
  2018-04-08 17:16           ` Andreas Röhler
       [not found]           ` <mailman.11903.1523207780.27995.help-gnu-emacs@gnu.org>
  2018-04-06 16:53         ` James K. Lowden
  1 sibling, 2 replies; 13+ messages in thread
From: Ben Bacarisse @ 2018-04-06 13:29 UTC (permalink / raw)
  To: help-gnu-emacs

Robert Pluim <rpluim@gmail.com> writes:

> Ben Bacarisse <ben.lists@bsb.me.uk> writes:
>
>> Robert Pluim <rpluim@gmail.com> writes:
>>
>>> Ben Bacarisse <ben.lists@bsb.me.uk> writes:
>>>
>>>> "James K. Lowden" <jklowden@speakeasy.net> writes:
>>>>
>>>>> I have two problems with python.el.  Maybe three.  
>>>>>
>>>>> 1.  GNU bug report logs - #29717[1]: imenu does not recognize function
>>>>> definitions with annotations.  
>>>>>
>>>>> 2.  imenu is purportedly bound to C-c C-j, but no "index" I supply
>>>>> returns anything but errors.  What does it want?
>>>
>>> Which version of emacs are you using? This seems to work fine for me
>>> in Emacs 26 and 27.
>>
>> You don't quote anything I said but you might be asking me too.  So,
>> just in case, I'm using 25.1.1.
>
> Hmm, C-c C-j doesnʼt have an issue for me in 25.1. This happens from
> emacs -Q as well?

M-X imenu works both with emacs -Q and with my normal startup.  It
failed to find functions with type annotations when I originally tried
because that was an emacsclient and something must have happened since I
stared the server.

After restarting the server, emacsclient behaves (unsurprisingly) just
like a fresh emacs run: imenu shows all functions in a test Python file,
even those with type annotations.

However, emacs -Q shows me more information!  It indicates if the index
item is a def or a class etc.  It seems I have python-mode installed and
emacs -Q is using python.el.gz and emacs is using python-mode.elc.

So my data point was not useful.

However, the OP should check if they are using python-mode (shown as
"Py") or python.el (shown as "Python").

-- 
Ben.


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

* Re: python mode bugs
       [not found]       ` <mailman.11780.1523018635.27995.help-gnu-emacs@gnu.org>
  2018-04-06 13:29         ` Ben Bacarisse
@ 2018-04-06 16:53         ` James K. Lowden
  1 sibling, 0 replies; 13+ messages in thread
From: James K. Lowden @ 2018-04-06 16:53 UTC (permalink / raw)
  To: help-gnu-emacs

On Fri, 06 Apr 2018 14:43:44 +0200
Robert Pluim <rpluim@gmail.com> wrote:

> >>>> 2.  imenu is purportedly bound to C-c C-j, but no "index" I
> >>>> supply returns anything but errors.  What does it want?
> >>
> >> Which version of emacs are you using? This seems to work fine for
> >> me in Emacs 26 and 27.
> 
> Hmm, C-c C-j doesn?t have an issue for me in 25.1. This happens from
> emacs -Q as well?

Gah, of course!  I'm using 25.1, too and -- I'm sorry and happy to say
-- it turns out I have a local problem, because it works as advertized
with -Q.  

Sorry for the distraction.  I'll spend see if I can find the proximate
cause, and if there's any useful information.  

Thanks for pointing out the obvious, and to everyone else who offered
suggestions.  Hopefully I'll be able to show why the bug should be
closed.  

--jkl


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

* Re: python mode bugs
  2018-04-06 13:29         ` Ben Bacarisse
@ 2018-04-08 17:16           ` Andreas Röhler
       [not found]           ` <mailman.11903.1523207780.27995.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: Andreas Röhler @ 2018-04-08 17:16 UTC (permalink / raw)
  To: help-gnu-emacs

On 06.04.2018 15:29, Ben Bacarisse wrote:

> However, emacs -Q shows me more information!  It indicates if the index
> item is a def or a class etc. 

Hi,

python-mode.el developer here. Indeed left out some advertisement, 
because if at "def" or "class" should be indicated by the given keyword 
already. Case there is some other occasion and info not redundant, it 
might be helpful to learn about.

Best,

Andreas




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

* Re: python mode bugs
       [not found]           ` <mailman.11903.1523207780.27995.help-gnu-emacs@gnu.org>
@ 2018-04-08 20:16             ` Ben Bacarisse
  2018-04-09  5:47               ` Andreas Röhler
  0 siblings, 1 reply; 13+ messages in thread
From: Ben Bacarisse @ 2018-04-08 20:16 UTC (permalink / raw)
  To: help-gnu-emacs

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

> On 06.04.2018 15:29, Ben Bacarisse wrote:
>
>> However, emacs -Q shows me more information!  It indicates if the index
>> item is a def or a class etc. 
>
> python-mode.el developer here. Indeed left out some advertisement,
> because if at "def" or "class" should be indicated by the given
> keyword already. Case there is some other occasion and info not
> redundant, it might be helpful to learn about.

I am only a very occasional Python programmer so I am not a good source
of information.  The ! in my remark was not intended to express any
great pleasure from the extra information, just surprise at the
different behaviour.  As the time I did not know that python-mode.el and
python.el were both present and working slightly differently.

-- 
Ben.


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

* Re: python mode bugs
  2018-04-08 20:16             ` Ben Bacarisse
@ 2018-04-09  5:47               ` Andreas Röhler
  0 siblings, 0 replies; 13+ messages in thread
From: Andreas Röhler @ 2018-04-09  5:47 UTC (permalink / raw)
  To: help-gnu-emacs

On 08.04.2018 22:16, Ben Bacarisse wrote:
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> 
>> On 06.04.2018 15:29, Ben Bacarisse wrote:
>>
>>> However, emacs -Q shows me more information!  It indicates if the index
>>> item is a def or a class etc.
>>
>> python-mode.el developer here. Indeed left out some advertisement,
>> because if at "def" or "class" should be indicated by the given
>> keyword already. Case there is some other occasion and info not
>> redundant, it might be helpful to learn about.
> 
> I am only a very occasional Python programmer so I am not a good source
> of information.  The ! in my remark was not intended to express any
> great pleasure from the extra information, just surprise at the
> different behaviour.  As the time I did not know that python-mode.el and
> python.el were both present and working slightly differently.
> 

Thanks. Might have missed something.

Andreas,
considering which info to display an interesting question



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

* Re: python mode bugs
  2018-04-05 19:50 python mode bugs James K. Lowden
  2018-04-05 21:02 ` Stefan Monnier
  2018-04-05 22:11 ` Ben Bacarisse
@ 2018-05-01 18:16 ` James K. Lowden
  2018-05-02  6:34   ` Colin Baxter
  2 siblings, 1 reply; 13+ messages in thread
From: James K. Lowden @ 2018-05-01 18:16 UTC (permalink / raw)
  To: help-gnu-emacs

On Thu, 5 Apr 2018 15:50:15 -0400
"James K. Lowden" <jklowden@speakeasy.net> wrote:

> 1.  GNU bug report logs - #29717[1]: imenu does not recognize function
> definitions with annotations.  

Just to remind the casual reader, this is a non-issue.  imenu works
just fine by iteself: with "emacs -Q", it annotations do not interefere
with recognizing Python function defintions.  

The source of conflict in my .emacs file is apparently one important
line:

	(semantic-mode 1)

If semantic is never enabled, imenu works as advertised.  After semantic
is enabled, imenu stops working (c-C c-J fails to jump to most
functions).  Turning semantic-mode off after it's been enabled makes no
difference: it's broken, and you get to keep both pieces.  

Now that I know about it, it's not a giant problem.  I can have two
emacs sessions, one for Python without semantic, and the other with
semantic and not for Python.  

However, if someone wants to look into it further, I'm happy to provide
such information as I can to help narrow down the conflict, if that's
what it is.  

--jkl


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

* Re: python mode bugs
  2018-05-01 18:16 ` James K. Lowden
@ 2018-05-02  6:34   ` Colin Baxter
  0 siblings, 0 replies; 13+ messages in thread
From: Colin Baxter @ 2018-05-02  6:34 UTC (permalink / raw)
  To: James K. Lowden; +Cc: help-gnu-emacs

Hello James,

>>>>> James K Lowden <jklowden@speakeasy.net> writes:

    > On Thu, 5 Apr 2018 15:50:15 -0400
    > "James K. Lowden" <jklowden@speakeasy.net> wrote:

    >> 1.  GNU bug report logs - #29717[1]: imenu does not recognize
    >> function definitions with annotations.

    > Just to remind the casual reader, this is a non-issue.  imenu
    > works just fine by iteself: with "emacs -Q", it annotations do not
    > interefere with recognizing Python function defintions.

    > The source of conflict in my .emacs file is apparently one
    > important line:

    > 	(semantic-mode 1)

Imenu works for me (in python, at least) if I enable semantic via M-x
semantic-mode and not from my ~/.emacs file.

Best wishes,



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

end of thread, other threads:[~2018-05-02  6:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-05 19:50 python mode bugs James K. Lowden
2018-04-05 21:02 ` Stefan Monnier
2018-04-05 22:11 ` Ben Bacarisse
2018-04-06 10:37   ` Robert Pluim
     [not found]   ` <mailman.11778.1523011049.27995.help-gnu-emacs@gnu.org>
2018-04-06 10:47     ` Ben Bacarisse
2018-04-06 12:43       ` Robert Pluim
     [not found]       ` <mailman.11780.1523018635.27995.help-gnu-emacs@gnu.org>
2018-04-06 13:29         ` Ben Bacarisse
2018-04-08 17:16           ` Andreas Röhler
     [not found]           ` <mailman.11903.1523207780.27995.help-gnu-emacs@gnu.org>
2018-04-08 20:16             ` Ben Bacarisse
2018-04-09  5:47               ` Andreas Röhler
2018-04-06 16:53         ` James K. Lowden
2018-05-01 18:16 ` James K. Lowden
2018-05-02  6:34   ` Colin Baxter

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).