unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Al Haji-Ali <abdo.haji.ali@gmail.com>
Cc: 50781@debbugs.gnu.org
Subject: bug#50781: 27.2; completing-read with a vector
Date: Sat, 25 Sep 2021 04:15:12 +0200	[thread overview]
Message-ID: <87fsttpfin.fsf@gnus.org> (raw)
In-Reply-To: <x1otuiajcjv.fsf@gmail.com> (Al Haji-Ali's message of "Fri, 24 Sep 2021 14:49:51 +0100")

Al Haji-Ali <abdo.haji.ali@gmail.com> writes:

> I am not sure if `completing-read` is supposed to accept a vector but
> an error is not thrown on this usage (incidentally helpful uses
> `completing-read` in this way).
>
> However, starting from `emacs -Q` and executing the following code
>
> (completing-read "Test: " [A B C])
>
> works but then pressing <TAB> for auto-completion shows objects beside
> A, B and C.

The documentation here says:

COLLECTION can be a list of strings, an alist, an obarray or a hash table.

So using a vector isn't really supported, but works in some instances by
chance.

> On the other hand, executing
> (completing-read "Test: " [1 2 3])
> and then pressing <TAB> shows the error `(error "Bad data in guts of obarray")`

It interprets all vectors as obarrays, and an obarray is just a vector
of symbols.  But numbers aren't symbols, which is what it's complaining
about.

We could make `completing-read' iterate over all the elements in the
vector to see whether it's valid, and signal an error earlier, but it
would make common usages slower.

So I don't think there's an error in Emacs here -- feeding a
(non-obarray) vector to `completing-read' is not supported, and is an
error in the code that does it.  So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





      reply	other threads:[~2021-09-25  2:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24 13:49 bug#50781: 27.2; completing-read with a vector Al Haji-Ali
2021-09-25  2:15 ` Lars Ingebrigtsen [this message]

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=87fsttpfin.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=50781@debbugs.gnu.org \
    --cc=abdo.haji.ali@gmail.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).