From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Canonical way to add a pre-filter to completing-read Date: Thu, 10 May 2018 11:21:42 -0400 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1525965620 15306 195.159.176.226 (10 May 2018 15:20:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 10 May 2018 15:20:20 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 10 17:20:16 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fGnMe-0003sj-90 for geh-help-gnu-emacs@m.gmane.org; Thu, 10 May 2018 17:20:16 +0200 Original-Received: from localhost ([::1]:34393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGnOl-0000zC-Ga for geh-help-gnu-emacs@m.gmane.org; Thu, 10 May 2018 11:22:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGnOF-0000vh-Fp for help-gnu-emacs@gnu.org; Thu, 10 May 2018 11:22:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGnOB-0003TB-Ad for help-gnu-emacs@gnu.org; Thu, 10 May 2018 11:21:55 -0400 Original-Received: from [195.159.176.226] (port=36352 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGnOB-0003SH-3O for help-gnu-emacs@gnu.org; Thu, 10 May 2018 11:21:51 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fGnM1-000370-IM for help-gnu-emacs@gnu.org; Thu, 10 May 2018 17:19:37 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:TPNafyJW/PLc3JsresF46EnSxjs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116703 Archived-At: > (completing-read "Entry: " '("abc" "bcd" "cde") nil :require-match "bc") > ;INITIAL-INPUT deprecated, but works as I want > > Above will show in the completion list with just the filtered items > matching "bc": > > abc > bcd Could you clarify exactly here: - "will show"... when the user does what? Just calling the above `completing-read` won't show any list of completions - When I hit ? at the prompt, I indeed get a list of completions, but that list only includes `bcd` because the default completion style does not include `substring`. So your use/test case is different from the default. Let's say the user does M-: (km-completion "Entry: " '("abc" "bcd" "cde") "bc") RET and then types `a` (and then hits `?` to see the list of remaining completions, or maybe he uses icomplete-mode to always see the list of remaining candidates). What do you want the list of completions to be at that point? Some things you can do with the standard completion-UI: - setup your completion table such that it uses `substring` completion by default. - use `completion-table-in-turn` with the first table being a sub-table which only includes the entries that match "bc". -- Stefan