Subject: bug#73330: 31.0.50; Incorrect completions for 'cond' clauses

From: Eli Zaretskii <[email-masked]>
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" <[email-masked]>
> 
> 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)