unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Spencer Baugh <sbaugh@janestreet.com>
Cc: dmitry@gutov.dev, 68514@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
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	[thread overview]
Message-ID: <jwv5xzr3otu.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <ierwms9qd20.fsf@janestreet.com> (Spencer Baugh's message of "Tue, 16 Jan 2024 14:43:35 -0500")

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






  reply	other threads:[~2024-01-17 16:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16 17:06 bug#68514: 30.0.50; minibuffer-choose-completion + elisp-c-a-p delete next sexp when completing after open paren Spencer Baugh
2024-01-16 17:28 ` Dmitry Gutov
2024-01-16 17:39 ` Juri Linkov
2024-01-16 19:43   ` Spencer Baugh
2024-01-17 16:37     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-01-17 17:20       ` Spencer Baugh
2024-01-17 17:53         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-17 18:10           ` Spencer Baugh
2024-01-17 19:03             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-18 19:05           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-01-17 16:42     ` Juri Linkov
2024-01-17 17:22       ` Spencer Baugh
2024-01-17 17:44         ` Juri Linkov

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwv5xzr3otu.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=68514@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=juri@linkov.net \
    --cc=monnier@iro.umontreal.ca \
    --cc=sbaugh@janestreet.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 public inbox

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

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