From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.help Subject: Re: emacs forms input Date: Wed, 04 Aug 2010 11:53:20 +0300 Message-ID: <87sk2uzrlr.fsf@mithlond.arda> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1280912159 6425 80.91.229.12 (4 Aug 2010 08:55:59 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 4 Aug 2010 08:55:59 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Ilya Shlyakhter Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 04 10:55:57 2010 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.69) (envelope-from ) id 1OgZlU-0005WJ-Vn for geh-help-gnu-emacs@m.gmane.org; Wed, 04 Aug 2010 10:55:57 +0200 Original-Received: from localhost ([127.0.0.1]:60652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OgZlU-0002Op-NM for geh-help-gnu-emacs@m.gmane.org; Wed, 04 Aug 2010 04:55:56 -0400 Original-Received: from [140.186.70.92] (port=46052 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OgZkz-0002Ok-SY for help-gnu-emacs@gnu.org; Wed, 04 Aug 2010 04:55:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OgZkv-0003r4-OE for help-gnu-emacs@gnu.org; Wed, 04 Aug 2010 04:55:25 -0400 Original-Received: from mta-out.inet.fi ([195.156.147.13]:44795 helo=kirsi2.inet.fi) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OgZkv-0003cL-Ff for help-gnu-emacs@gnu.org; Wed, 04 Aug 2010 04:55:21 -0400 Original-Received: from mithlond.arda (84.251.132.215) by kirsi2.inet.fi (8.5.122) id 4C33307D00DC7C12; Wed, 4 Aug 2010 11:53:40 +0300 Original-Received: from dtw by mithlond.arda with local (Exim 4.69) (envelope-from ) id 1OgZiy-0001nQ-Vx; Wed, 04 Aug 2010 11:53:21 +0300 In-Reply-To: (Ilya Shlyakhter's message of "Tue, 3 Aug 2010 18:51:56 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:74418 Archived-At: * 2010-08-03 18:51 (-0400), Ilya Shlyakhter wrote: > Is there a way in Emacs Lisp to create a dialog with several fields > (that would work in text mode also), have the user fill out the > dialog, and then get the results? It is possible and I'll give you some examples. First a graphical dialog: (x-popup-dialog t '("How about making a choice?" ("Choice1" . value1) ("Choice2" . value2)) nil) Text dialog (a menu actually): (let ((tmm-completion-prompt "How about making a choice?\n\n")) (tmm-prompt '("" ("" ("Choice1" . value1) ("Choice2" . value2))))) Now, if you want to abstract the implementation between graphical and text interface it could be a function like this: (defun my-dialog (title item-alist) (if (display-popup-menus-p) (x-popup-dialog t (cons title item-alist) nil) (let ((tmm-completion-prompt (concat title "\n\n"))) (tmm-prompt (list "" (cons "" item-alist)))))) Example: (my-dialog "How about making a choice?" '(("Choice1" . value1) ("Choice2" . value2)))