From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.help Subject: Canonical way to add a pre-filter to completing-read Date: Thu, 10 May 2018 13:09:14 +0000 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1525957746 18955 195.159.176.226 (10 May 2018 13:09:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 10 May 2018 13:09:06 +0000 (UTC) To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 10 15:09:02 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 1fGlJd-0004n9-Gx for geh-help-gnu-emacs@m.gmane.org; Thu, 10 May 2018 15:09:01 +0200 Original-Received: from localhost ([::1]:33891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGlLk-0004eD-E6 for geh-help-gnu-emacs@m.gmane.org; Thu, 10 May 2018 09:11:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGlK5-0003K4-RI for help-gnu-emacs@gnu.org; Thu, 10 May 2018 09:09:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGlK4-0007PH-N5 for help-gnu-emacs@gnu.org; Thu, 10 May 2018 09:09:29 -0400 Original-Received: from mail-lf0-x235.google.com ([2a00:1450:4010:c07::235]:34946) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGlK4-0007P4-Fw for help-gnu-emacs@gnu.org; Thu, 10 May 2018 09:09:28 -0400 Original-Received: by mail-lf0-x235.google.com with SMTP id y72-v6so2893584lfd.2 for ; Thu, 10 May 2018 06:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=NZfBGJmwTZ1cjdhO8wG93f6XlypBzI/MhoA92HCSzB8=; b=BmbfSWc/67GzR3UvQiXJm3aqP9Hl0UZTYH1q3oQ9b9sDH1Ulg1IjiFdDy2248l9iT9 hjPU6KSeGYQOEdL4qpFNHZyrAtocoCOE9PYlCQD/n9mCff5uI8zcAFEhQvM4IqPuftsD IptEcIo8WxxrCYPJRgjs/23DVvq9ov1IkpS6Z4VbC3ryAvaQj9G5Xmv7bukSjcj2hma4 +G6MRx6PXpMUMCKoVXu1GebNd934SCAwPn5Up511fsV/UB8x4FaYk2zgDYUClWK6o8Gb lfbZmkt11YCA7763JgS5nRU7pvzS9OhRr4QWCS9Fxy5QGjak8TUqk/ZezdhMYRhB6utZ eyXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=NZfBGJmwTZ1cjdhO8wG93f6XlypBzI/MhoA92HCSzB8=; b=SSGxXzbt101I9EWIg9WEehJ03DijerXa+g67hYpqMCxJcpk+h/JXsGgte+xCwQ4BXA VYAbWhTdJXpPzGbeYRnK0/maKLKJxpPp5B/jAW8FxQzpgMuE0D0i5TM82hxGqIbJlE39 Ic+Mgl+KaUP36iAD/dp1JENNG8hToyncJdTYwo6Cz9G+xcCUlrenQlfzgplBekqgRs+T EqIsASBzyfEbQ0vaO9gQE+q+BmtBhfmfZBLpPf68JhxkLBtoSYYzNAOs1XMlSuOEDxdH 7fQvWZ5ao3uQM+jjiBgnAFYt6IvByK/UkGNglcWnzqJxTx32w/AldChILQnli4hQSGiE 9G5Q== X-Gm-Message-State: ALKqPwdRcwItr+dExPzdBywrEuh/mPZTWOBbfUg3hEl3xaqYsjTAmTsg tC5NGiusSfm/8wHMvrmbKezHKGykJeQ3aKG9DwY= X-Google-Smtp-Source: AB8JxZqZb7GLyEcRd3OtlWLV7i9WzGmBIML4bz6jkJaCiAvJNJChAegn5lt0Cegfp6InxuHpUoqjdHVzH4HQTwauGNI= X-Received: by 2002:a2e:8659:: with SMTP id i25-v6mr1218317ljj.128.1525957765421; Thu, 10 May 2018 06:09:25 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::235 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:116698 Archived-At: Hello, I want to use completing-read to provide a "pre-filter" to narrow down the completion list. My real use use is to take the symbol-at-point as the pre-filter to narrow down in a list of all identifiers. For a real example, the symbol name is "walkDirRec", but the completion list contains "os.walkDirRec".. so I am trying to figure out how to use completing-read with that. (I am aware that I can use the counsel library to make this easier, but was looking for a way for completing-read to Just Work(TM).) So here are some minimal examples to explain my conundrum.. Below works exactly as I want.. but the docs and manual say that INITIAL-INPUT is deprecated. (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 So following the manual, I tried using the DEF (default) argument instead, but that doesn't work as I want.. that just throws in that DEF value verbatim to the completion list.. (completing-read "Entry: " '("abc" "bcd" "cde") nil :require-match nil nil "bc") ;Using DEF does not work.. it just inserts that as one more element in the completion list Above will end up with this list: bc abc bcd cde So the DEF approach is not useful unless the DEF value is matching exactly with one of the items in COLLECTION. So, what would be the right way, i.e. not using the deprecated INITIAL-INPUT? Thanks. -- Kaushal Modi