Subject: bug#55491: All completion fragments get added to obarray

From: Dmitry Gutov <[email-masked]>
Date: Tue, 7 Jun 2022 00:30:00 +0300

On 06.06.2022 15:44, Lars Ingebrigtsen wrote:
> Dmitry Gutov<[email-masked]>  writes:
> 
>> Looking at the possible problems, I guess the regexp doesn't account
>> for possible escapings? Like a symbol 'let\ s\ go\ to\ the\ mall',
>> which shouldn't be mistaken for 'let'. That would require a more
>> complex regexp.
> Yes, so that won't be the right thing.  It'd be nice if we had a version
> of `read' that's more like "read the next symbol but return nil if it's
> not interned already" for these cases.

How about this, then?

Too bad 'forward-symbol' doesn't handle escapings, otherwise we could 
just do (intern-soft (thing-at-point 'symbol)).

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 77bf3f1ed1..44f4c012ef 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -697,7 +697,11 @@ elisp-completion-at-point
                                      (let ((c (char-after)))
                                        (if (eq c ?\() ?\(
                                          (if (memq (char-syntax c) '(?w ?_))
-                                             (read (current-buffer))))))
+                                             (let ((pt (point)))
+                                               (ignore-errors
+                                                 (forward-sexp)
+                                                 (intern-soft
+                                                  (buffer-substring pt (point)))))))))
                             (error nil))))
                      (pcase parent
                        ;; FIXME: Rather than hardcode special cases here,