help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs forms input


From: Teemu Likonen
Subject: Re: emacs forms input
Date: Wed, 04 Aug 2010 11:53:20 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.50 (gnu/linux)

* 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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]