all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Klaus Berndl <Klaus.Berndl@sdm.de>
Subject: Re: Any standard function to prompt for multiple comma-separated items?
Date: 17 Nov 2002 10:27:08 +0100	[thread overview]
Message-ID: <u8yzs35sj.fsf@sdm.de> (raw)
In-Reply-To: mailman.1037389349.31174.help-gnu-emacs@gnu.org

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

  parent reply	other threads:[~2002-11-17  9:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1037389349.31174.help-gnu-emacs@gnu.org>
2002-11-16 18:55 ` Any standard function to prompt for multiple comma-separated items? Kai Großjohann
2002-11-17 14:03   ` Peter S Galbraith
     [not found]   ` <mailman.1037542582.16549.help-gnu-emacs@gnu.org>
2002-11-18 15:52     ` Stefan Monnier <foo@acm.com>
2002-11-17  9:27 ` Klaus Berndl [this message]
     [not found]   ` <Klaus.Berndl@sdm.de>
2002-11-17 14:08     ` Peter S Galbraith
2002-12-15 20:44     ` Customize a checklist Peter S Galbraith
2002-11-17 16:39 ` Any standard function to prompt for multiple comma-separated items? Kai Großjohann
2002-11-18 15:53   ` Stefan Monnier <foo@acm.com>
     [not found] <mailman.7309.1054754086.21513.help-gnu-emacs@gnu.org>
2003-06-04 21:13 ` Coding Convections - Enabling a feature by loading a file Stefan Monnier
     [not found]   ` <mailman.7337.1054774167.21513.help-gnu-emacs@gnu.org>
2003-06-05  1:02     ` Stefan Monnier
2003-06-05 16:24 ` Lute Kamstra
2003-05-02  3:12 off-topic? James D
2003-05-02  5:44 ` off-topic? Lute Kamstra
2003-05-02 19:41   ` off-topic? James D
2003-05-02 20:39     ` off-topic? Roodwriter
2003-05-03  3:08       ` off-topic? Oliver Scholz
2003-05-02 22:00     ` off-topic? Lute Kamstra
     [not found]       ` <Lute.Kamstra@cwi.nl>
2003-05-03  3:27         ` off-topic? Peter S Galbraith
2003-06-08  0:58         ` Coding Convections - Enabling a feature by loading a file Peter S Galbraith
2003-05-03 21:13       ` off-topic? Alexander Nikolov
2003-05-03 21:21       ` off-topic? Alexander Nikolov
     [not found] <mailman.227.1039966739.19936.help-gnu-emacs@gnu.org>
2002-12-15 18:56 ` Customize a checklist Klaus Berndl
  -- strict thread matches above, loose matches on Subject: below --
2002-11-15 19:17 Any standard function to prompt for multiple comma-separated items? Peter S Galbraith
2002-10-24 23:52 the real file-attributes function Kin Cho
2002-10-25  0:24 ` Barry Margolin
     [not found]   ` <nqn0p3m2g6.fsf@alcatel.de>
2002-10-25 23:30     ` Kin Cho
2002-10-25 14:23 ` Stefan Monnier <foo@acm.com>
     [not found]   ` <foo@acm.com>
     [not found]     ` <monnier+gnu.emacs.help/news/@flint.cs.yale.edu>
2002-10-25 15:17       ` Peter S Galbraith
2002-10-25 18:51       ` Activating Mousewheel Peter S Galbraith
2002-11-18 18:23       ` Any standard function to prompt for multiple comma-separated items? Peter S Galbraith
2003-06-05  0:47       ` Coding Convections - Enabling a feature by loading a file Peter S Galbraith
2002-10-24 17:20 Activating Mousewheel Florian Lindner
2002-10-24 19:06 ` Daniel Jensen
2002-10-24 20:01 ` Robert Marshall
2002-10-25 15:47 ` Kolya Poganini
2002-10-25 18:22   ` Stefan Monnier <foo@acm.com>

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=u8yzs35sj.fsf@sdm.de \
    --to=klaus.berndl@sdm.de \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.