From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Klaus Berndl Newsgroups: gmane.emacs.help Subject: Re: Any standard function to prompt for multiple comma-separated items? Date: 17 Nov 2002 10:27:08 +0100 Organization: sd&m AG, Muenchen, Germany Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1037526361 19643 80.91.224.249 (17 Nov 2002 09:46:01 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 17 Nov 2002 09:46:01 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18DM07-00056Z-00 for ; Sun, 17 Nov 2002 10:45:59 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18DLzy-0006gB-00; Sun, 17 Nov 2002 04:45:50 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.multikabel.nl!news2.euro.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!news.sdm.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 71 Original-NNTP-Posting-Host: callin26.muc.sdm.de Original-X-Trace: solti3.muc.sdm.de 1037525229 18412 195.125.139.26 (17 Nov 2002 09:27:09 GMT) Original-X-Complaints-To: usenet@news.sdm.de Original-NNTP-Posting-Date: 17 Nov 2002 09:27:09 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-Xref: shelby.stanford.edu gnu.emacs.help:107126 Original-To: help-gnu-emacs@gnu.org Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:3677 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:3677 On Fri, 15 Nov 2002, Peter S. Galbraith wrote: > Hello, > > For MH-E, I'm looking for code already available in Emacs to do > completing-read for multiple comma-separated items. e.g. > > To: p.gal[TAB] > -> > To: p.galbraith > -> > To: p.galbraith, psg[TAB] > -> > To: p.galbraith, psg@home > > Does anyone now of such code already existing? > > There's multi-prompt.el bundled with AUC-TeX that comes close (doesn't > allow whitespace after the field separator), but I need something I can > use in MH-E without external packages. Hmm, i do not know if i understand your problem in the right way...Do you want this completion in the minibuffer or is it more like dabbrev-completion in a "normal" buffer? Even more: What should be the domain of the completion, i.e. the set of allowed completions?? If you are searching for something in the minibuffer, here is a function: ,---- | ;; stolen from query.el and slightly enhanced | (defun ecb-query-string (prompt choices &optional other-prompt) | "Prints PROMPT and returns a string which must be one of CHOICES. | CHOICES is either a list of strings whereas the first choice is the default | \(which is returned if the user simply types RET) or nil \(then only a simple | RET quits the query and returns nil). If OTHER-PROMPT is not nil and a string | then the choice \"other\" is added to CHOICES and after selecting this choice | the user is prompted with OTHER-PROMPT to insert any arbitrary string." | (let* ((new-choices (if other-prompt | (add-to-list 'choices "other" t) | choices)) | (default (car new-choices)) | answer) | (setq prompt (concat prompt | " [" | (if new-choices | (mapconcat (function (lambda (x) x)) | new-choices ", ") | "RET") | "] ")) | (setq new-choices (nconc (mapcar (function (lambda (x) (list x t))) | new-choices) | '('("" t)))) | (setq answer (completing-read prompt new-choices nil t "")) | (cond ((string= answer "") | (setq answer default)) | ((string= answer "other") | (setq answer (read-string (concat other-prompt ": "))))) | answer)) `---- Klaus -- Klaus Berndl mailto: klaus.berndl@sdm.de sd&m AG http://www.sdm.de software design & management Thomas-Dehler-Str. 27, 81737 München, Germany Tel +49 89 63812-392, Fax -220