From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Mix of completing-read and read-string Date: Sat, 7 Feb 2009 20:09:16 -0800 Message-ID: <001201c989a3$02d61970$0200a8c0@us.oracle.com> References: <929ccd880902071222o64e828e3h107f176ccb78592a@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1234066196 15930 80.91.229.12 (8 Feb 2009 04:09:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 8 Feb 2009 04:09:56 +0000 (UTC) To: "'Johan Andersson'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 08 05:11:10 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LW10g-0007DW-Hc for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Feb 2009 05:11:10 +0100 Original-Received: from localhost ([127.0.0.1]:47630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LW0zN-0000vK-5j for geh-help-gnu-emacs@m.gmane.org; Sat, 07 Feb 2009 23:09:49 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LW0z5-0000tX-3v for help-gnu-emacs@gnu.org; Sat, 07 Feb 2009 23:09:31 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LW0z2-0000rH-KJ for help-gnu-emacs@gnu.org; Sat, 07 Feb 2009 23:09:29 -0500 Original-Received: from [199.232.76.173] (port=33147 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LW0z2-0000rE-EQ for help-gnu-emacs@gnu.org; Sat, 07 Feb 2009 23:09:28 -0500 Original-Received: from rcsinet12.oracle.com ([148.87.113.124]:64428 helo=rgminet12.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LW0z2-0007sy-1o for help-gnu-emacs@gnu.org; Sat, 07 Feb 2009 23:09:28 -0500 Original-Received: from rgminet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by rgminet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n1848rQ2013666 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 8 Feb 2009 04:08:54 GMT Original-Received: from acsmt707.oracle.com (acsmt707.oracle.com [141.146.40.85]) by rgminet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n1849Fho011092; Sun, 8 Feb 2009 04:09:16 GMT Original-Received: from dradamslap1 (/24.5.128.33) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 07 Feb 2009 20:09:14 -0800 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <929ccd880902071222o64e828e3h107f176ccb78592a@mail.gmail.com> Thread-Index: AcmJYhF9LJXSiT/WRjmXQNQDpGqyPgAPen+w X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350 X-Source-IP: acsmt707.oracle.com [141.146.40.85] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090205.498E5AEE.00D4:SCFSTAT928724,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:61991 Archived-At: > I'm looking for a function that is a mix of read-string > and completing-read. I want completion and I want to be > able to input anything, such as spaces. Is there any such > function or do I have to write one myself? 1. Use lax completion (`completing-read' with nil as the REQUIRE-MATCH argument. 2. Use a keymap that has SPC bound to `self-insert-command'. You can do #2 by binding `minibuffer-local-completion-map' (so it is restored afterward), and doing (define-key minibuffer-local-completion-map " " 'self-insert-command). IOW, something like this: (defun my-read-string-completing (prompt collection &optional predicate init hist def i-i-m) "..." (let ((minibuffer-local-completion-map minibuffer-local-completion-map)) (define-key minibuffer-local-completion-map " " 'self-insert-command) (completing-read prompt collection predicate nil init def hist i-i-m))) You would call the function with a COLLECTION argument that is a list of strings (Emacs 22+) or a list of singleton string lists (all versions). E.g.: (my-read-string-completing "String: " '(("alpha") ("beta") ("gamma"))) (If you use Icicles, `icicle-read-string-completing' does this.)