[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#68514: 30.0.50; minibuffer-choose-completion + elisp-c-a-p delete ne
From: |
Stefan Monnier |
Subject: |
bug#68514: 30.0.50; minibuffer-choose-completion + elisp-c-a-p delete next sexp when completing after open paren |
Date: |
Wed, 17 Jan 2024 11:37:15 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> If point is already at the start of a sexp (e.g. immediately after an
> open paren) then backward-sexp will not move point and the beginning
> of the completion region would (correctly) be the original point.
>
> forward-sexp, in this case, will move over the next sexp after point
> and include it in the completion region, even if it's a string or
> list.
The fact that it did not move point is not really the problem.
The problem is that point may be just before something like whitespace,
so the
(member (char-syntax (char-after beg))
'(?\" ?\())
doesn't notice that `forward-sexp` will actually jump over a list or
some other such uncompletable sexp.
I suggest the patch below instead (which also uses `min` to try to make
sure we don't return a BEG..END which doesn't contain point).
Stefan
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 00910fb67c7..60d58191175 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -657,12 +657,12 @@ elisp-completion-at-point
(save-excursion
(backward-sexp 1)
(skip-chars-forward "`',‘#")
- (point))
+ (min (point) pos))
(scan-error pos)))
(end
- (unless (or (eq beg (point-max))
- (member (char-syntax (char-after beg))
- '(?\" ?\()))
+ (unless (or (>= beg (point-max))
+ (not (memq (char-syntax (char-after beg))
+ '(?w ?\\ ?_))))
(condition-case nil
(save-excursion
(goto-char beg)