all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Eshel Yaron <me@eshelyaron.com>
Cc: 73330@debbugs.gnu.org
Subject: bug#73330: 31.0.50; Incorrect completions for 'cond' clauses
Date: Thu, 19 Sep 2024 16:15:56 +0300	[thread overview]
Message-ID: <86r09f9437.fsf@gnu.org> (raw)
In-Reply-To: <m1tteb7rva.fsf@sp-byods-145-109-45-221.wireless.uva.nl> (message from Eshel Yaron on Thu, 19 Sep 2024 14:25:13 +0200)

> From: Eshel Yaron <me@eshelyaron.com>
> Cc: 73330@debbugs.gnu.org
> Date: Thu, 19 Sep 2024 14:25:13 +0200
> 
> Eli Zaretskii <eliz@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@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)





  reply	other threads:[~2024-09-19 13:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-18 12:36 bug#73330: 31.0.50; Incorrect completions for 'cond' clauses Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-19 10:07 ` Eli Zaretskii
2024-09-19 12:25   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-19 13:15     ` Eli Zaretskii [this message]
2024-09-19 14:33       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-19 14:33       ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-19 16:38         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86r09f9437.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=73330@debbugs.gnu.org \
    --cc=me@eshelyaron.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.