GNU bug report logs - #73330
31.0.50; Incorrect completions for 'cond' clauses

Previous Next

Package: emacs;

Reported by: Eshel Yaron <me <at> eshelyaron.com>

Date: Wed, 18 Sep 2024 12:37:02 UTC

Severity: normal

Found in version 31.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 73330 in the body.
You can then email your comments to 73330 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#73330; Package emacs. (Wed, 18 Sep 2024 12:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eshel Yaron <me <at> eshelyaron.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 18 Sep 2024 12:37:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eshel Yaron <me <at> eshelyaron.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; Incorrect completions for 'cond' clauses
Date: Wed, 18 Sep 2024 14:36:18 +0200
Hi,

1. emacs -Q
2. Insert "(cond (current-p
3. Hit M-TAB to complete

We're completing a symbol in the condition of a cond clause, so it is
expected to be completed as a variable, to current-prefix-argument.
However, Emacs mistakenly thinks that we're completing a function name,
and completes to current-bidi-paragraph-direction.


Thanks,

Eshel




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73330; Package emacs. (Thu, 19 Sep 2024 10:08:01 GMT) Full text and rfc822 format available.

Message #8 received at 73330 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Eshel Yaron <me <at> eshelyaron.com>
Cc: 73330 <at> debbugs.gnu.org
Subject: Re: bug#73330: 31.0.50; Incorrect completions for 'cond' clauses
Date: Thu, 19 Sep 2024 13:07:13 +0300
> Date: Wed, 18 Sep 2024 14:36:18 +0200
> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> 1. emacs -Q
> 2. Insert "(cond (current-p
> 3. Hit M-TAB to complete
> 
> We're completing a symbol in the condition of a cond clause, so it is
> expected to be completed as a variable, to current-prefix-argument.
> However, Emacs mistakenly thinks that we're completing a function name,
> and completes to current-bidi-paragraph-direction.

Thanks.  Does the patch below give good results?

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 9bf6f92..2471296 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -784,13 +784,14 @@ elisp-completion-at-point
                         (list t (elisp--completion-local-symbols)
                               :predicate (lambda (sym)
                                            (get sym 'error-conditions))))
-                       ((and (or ?\( 'let 'let*)
+                       ((and (or ?\( 'let 'let* 'cond 'cond* 'bind*)
                              (guard (save-excursion
                                       (goto-char (1- beg))
                                       (when (eq parent ?\()
                                         (up-list -1))
                                       (forward-symbol -1)
-                                      (looking-at "\\_<let\\*?\\_>"))))
+                                      (looking-at
+                                       "\\_<\\(let\\|cond\\|bind\\*\\)\\*?\\_>"))))
                         (list t (elisp--completion-local-symbols)
                               :predicate #'elisp--shorthand-aware-boundp
                               :company-kind (lambda (_) 'variable)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73330; Package emacs. (Thu, 19 Sep 2024 12:26:01 GMT) Full text and rfc822 format available.

Message #11 received at 73330 <at> debbugs.gnu.org (full text, mbox):

From: Eshel Yaron <me <at> eshelyaron.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 73330 <at> debbugs.gnu.org
Subject: Re: bug#73330: 31.0.50; Incorrect completions for 'cond' clauses
Date: Thu, 19 Sep 2024 14:25:13 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Wed, 18 Sep 2024 14:36:18 +0200
>> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> 1. emacs -Q
>> 2. Insert "(cond (current-p
>> 3. Hit M-TAB to complete
>> 
>> We're completing a symbol in the condition of a cond clause, so it is
>> expected to be completed as a variable, to current-prefix-argument.
>> However, Emacs mistakenly thinks that we're completing a function name,
>> and completes to current-bidi-paragraph-direction.
>
> Thanks.  Does the patch below give good results?

It helps, but also seems to cause a regression.  With this change I get:

1. emacs -Q
2. Insert "(cond ((current-p"
                  ^note the additional parenthesis
3. Hit M-TAB to complete

This shows an opposite bug: Emacs should complete function names (and
without the change, it does), but with the change we now get variable
name completion.


Thanks,

Eshel




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73330; Package emacs. (Thu, 19 Sep 2024 13:17:02 GMT) Full text and rfc822 format available.

Message #14 received at 73330 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Eshel Yaron <me <at> eshelyaron.com>
Cc: 73330 <at> debbugs.gnu.org
Subject: Re: bug#73330: 31.0.50; Incorrect completions for 'cond' clauses
Date: Thu, 19 Sep 2024 16:15:56 +0300
> From: Eshel Yaron <me <at> eshelyaron.com>
> Cc: 73330 <at> debbugs.gnu.org
> Date: Thu, 19 Sep 2024 14:25:13 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> Date: Wed, 18 Sep 2024 14:36:18 +0200
> >> From:  Eshel Yaron via "Bug reports for GNU Emacs,
> >>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> >> 
> >> 1. emacs -Q
> >> 2. Insert "(cond (current-p
> >> 3. Hit M-TAB to complete
> >> 
> >> We're completing a symbol in the condition of a cond clause, so it is
> >> expected to be completed as a variable, to current-prefix-argument.
> >> However, Emacs mistakenly thinks that we're completing a function name,
> >> and completes to current-bidi-paragraph-direction.
> >
> > Thanks.  Does the patch below give good results?
> 
> It helps

Does "helps" mean the original scenario is fixed? or are there any
leftovers in that scenario?

> but also seems to cause a regression.  With this change I get:
> 
> 1. emacs -Q
> 2. Insert "(cond ((current-p"
>                   ^note the additional parenthesis
> 3. Hit M-TAB to complete
> 
> This shows an opposite bug: Emacs should complete function names (and
> without the change, it does), but with the change we now get variable
> name completion.

How about the patch below?

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 9bf6f92..63bd685 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -784,13 +784,18 @@ elisp-completion-at-point
                         (list t (elisp--completion-local-symbols)
                               :predicate (lambda (sym)
                                            (get sym 'error-conditions))))
-                       ((and (or ?\( 'let 'let*)
+                       ((and (or ?\( 'let 'let* 'cond 'cond* 'bind*)
                              (guard (save-excursion
                                       (goto-char (1- beg))
                                       (when (eq parent ?\()
                                         (up-list -1))
                                       (forward-symbol -1)
-                                      (looking-at "\\_<let\\*?\\_>"))))
+                                      (or
+                                       (looking-at
+                                        "\\_<\\(let\\*?\\|bind\\*\\)\\_>")
+                                       (and (not (eq parent ?\())
+                                            (looking-at
+                                             "\\_<cond\\*?\\_>"))))))
                         (list t (elisp--completion-local-symbols)
                               :predicate #'elisp--shorthand-aware-boundp
                               :company-kind (lambda (_) 'variable)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73330; Package emacs. (Thu, 19 Sep 2024 14:34:01 GMT) Full text and rfc822 format available.

Message #17 received at 73330 <at> debbugs.gnu.org (full text, mbox):

From: Eshel Yaron <me <at> eshelyaron.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 73330 <at> debbugs.gnu.org
Subject: Re: bug#73330: 31.0.50; Incorrect completions for 'cond' clauses
Date: Thu, 19 Sep 2024 16:33:03 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Eshel Yaron <me <at> eshelyaron.com>
>> Cc: 73330 <at> debbugs.gnu.org
>> Date: Thu, 19 Sep 2024 14:25:13 +0200
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> >> Date: Wed, 18 Sep 2024 14:36:18 +0200
>> >> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>> >>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> >> 
>> >> 1. emacs -Q
>> >> 2. Insert "(cond (current-p
>> >> 3. Hit M-TAB to complete
>> >> 
>> >> We're completing a symbol in the condition of a cond clause, so it is
>> >> expected to be completed as a variable, to current-prefix-argument.
>> >> However, Emacs mistakenly thinks that we're completing a function name,
>> >> and completes to current-bidi-paragraph-direction.
>> >
>> > Thanks.  Does the patch below give good results?
>> 
>> It helps
>
> Does "helps" mean the original scenario is fixed? or are there any
> leftovers in that scenario?

Yes, it fixed the original scenario.

>> but also seems to cause a regression.  With this change I get:
>> 
>> 1. emacs -Q
>> 2. Insert "(cond ((current-p"
>>                   ^note the additional parenthesis
>> 3. Hit M-TAB to complete
>> 
>> This shows an opposite bug: Emacs should complete function names (and
>> without the change, it does), but with the change we now get variable
>> name completion.
>
> How about the patch below?

That works well in both the original scenario and the modified one.


Thank!

Eshel





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#73330; Package emacs. (Thu, 19 Sep 2024 14:34:02 GMT) Full text and rfc822 format available.

Message #20 received at 73330 <at> debbugs.gnu.org (full text, mbox):

From: Eshel Yaron <me <at> eshelyaron.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 73330 <at> debbugs.gnu.org
Subject: Re: bug#73330: 31.0.50; Incorrect completions for 'cond' clauses
Date: Thu, 19 Sep 2024 16:33:11 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Eshel Yaron <me <at> eshelyaron.com>
>> Cc: 73330 <at> debbugs.gnu.org
>> Date: Thu, 19 Sep 2024 14:25:13 +0200
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> >> Date: Wed, 18 Sep 2024 14:36:18 +0200
>> >> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>> >>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> >> 
>> >> 1. emacs -Q
>> >> 2. Insert "(cond (current-p
>> >> 3. Hit M-TAB to complete
>> >> 
>> >> We're completing a symbol in the condition of a cond clause, so it is
>> >> expected to be completed as a variable, to current-prefix-argument.
>> >> However, Emacs mistakenly thinks that we're completing a function name,
>> >> and completes to current-bidi-paragraph-direction.
>> >
>> > Thanks.  Does the patch below give good results?
>> 
>> It helps
>
> Does "helps" mean the original scenario is fixed? or are there any
> leftovers in that scenario?

Yes, it fixed the original scenario.

>> but also seems to cause a regression.  With this change I get:
>> 
>> 1. emacs -Q
>> 2. Insert "(cond ((current-p"
>>                   ^note the additional parenthesis
>> 3. Hit M-TAB to complete
>> 
>> This shows an opposite bug: Emacs should complete function names (and
>> without the change, it does), but with the change we now get variable
>> name completion.
>
> How about the patch below?

That works well in both the original scenario and the modified one.


Thanks!

Eshel





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 19 Sep 2024 16:39:03 GMT) Full text and rfc822 format available.

Notification sent to Eshel Yaron <me <at> eshelyaron.com>:
bug acknowledged by developer. (Thu, 19 Sep 2024 16:39:03 GMT) Full text and rfc822 format available.

Message #25 received at 73330-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Eshel Yaron <me <at> eshelyaron.com>
Cc: 73330-done <at> debbugs.gnu.org
Subject: Re: bug#73330: 31.0.50; Incorrect completions for 'cond' clauses
Date: Thu, 19 Sep 2024 19:38:12 +0300
> From: Eshel Yaron <me <at> eshelyaron.com>
> Cc: 73330 <at> debbugs.gnu.org
> Date: Thu, 19 Sep 2024 16:33:11 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > Does "helps" mean the original scenario is fixed? or are there any
> > leftovers in that scenario?
> 
> Yes, it fixed the original scenario.
> 
> >> but also seems to cause a regression.  With this change I get:
> >> 
> >> 1. emacs -Q
> >> 2. Insert "(cond ((current-p"
> >>                   ^note the additional parenthesis
> >> 3. Hit M-TAB to complete
> >> 
> >> This shows an opposite bug: Emacs should complete function names (and
> >> without the change, it does), but with the change we now get variable
> >> name completion.
> >
> > How about the patch below?
> 
> That works well in both the original scenario and the modified one.

Thanks, installed on master, and closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 18 Oct 2024 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 303 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.