all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* emacs forms input
@ 2010-08-03 22:51 Ilya Shlyakhter
  0 siblings, 0 replies; 8+ messages in thread
From: Ilya Shlyakhter @ 2010-08-03 22:51 UTC (permalink / raw)
  To: help-gnu-emacs

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?

thanks,

ilya



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs forms input
       [not found] <mailman.10.1280910238.19279.help-gnu-emacs@gnu.org>
@ 2010-08-04  8:53 ` Teemu Likonen
  2010-08-04 11:55   ` Teemu Likonen
  0 siblings, 1 reply; 8+ messages in thread
From: Teemu Likonen @ 2010-08-04  8:53 UTC (permalink / raw)
  To: Ilya Shlyakhter; +Cc: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs forms input
  2010-08-04  8:53 ` emacs forms input Teemu Likonen
@ 2010-08-04 11:55   ` Teemu Likonen
  2010-08-04 16:24     ` Ilya Shlyakhter
       [not found]     ` <mailman.1.1280939096.6287.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 8+ messages in thread
From: Teemu Likonen @ 2010-08-04 11:55 UTC (permalink / raw)
  To: Ilya Shlyakhter; +Cc: help-gnu-emacs

* 2010-08-04 11:53 (+0300), Teemu Likonen wrote:

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

Perhaps I should add that if you use C-g (keyboard-quit) or close the
dialog box using window's close button that causes a quit signal and the
function nor its callers won't return. Here's a new version which will
catch the quit signal and, if that happens, return nil:

    (defun my-dialog (title item-alist)
      (condition-case nil
          (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)))))
        (quit nil)))



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs forms input
  2010-08-04 11:55   ` Teemu Likonen
@ 2010-08-04 16:24     ` Ilya Shlyakhter
  2010-08-04 16:29       ` Lennart Borgman
       [not found]       ` <mailman.3.1280939390.6287.help-gnu-emacs@gnu.org>
       [not found]     ` <mailman.1.1280939096.6287.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 8+ messages in thread
From: Ilya Shlyakhter @ 2010-08-04 16:24 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: help-gnu-emacs

Thanks, that helps; but I was looking for something more: not simply
choosing a command from a menu,
but displaying a dialog with multiple fields, letting the user fill
some of them, and getting the result --
like displaying an HTML <FORM>.

Basically, I want the user to call an elisp function with many
possible optional arguments.
The standard elisp solution seems to be, "if called with one C-u
prefix, function does this;
if called with C-u C-u, it does that; ..." -- this is unintuitive and
quickly gets hard to remember.
In a GUI program I'd display a dialog box with multiple fields, with
some of them filled-in with
defaults, and let the user change the fields they want.  It seems that
ncurses should support that?
Does it?

thanks,

ilya

On Wed, Aug 4, 2010 at 7:55 AM, Teemu Likonen <tlikonen@iki.fi> wrote:
> * 2010-08-04 11:53 (+0300), Teemu Likonen wrote:
>
>> 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))))))
>
> Perhaps I should add that if you use C-g (keyboard-quit) or close the
> dialog box using window's close button that causes a quit signal and the
> function nor its callers won't return. Here's a new version which will
> catch the quit signal and, if that happens, return nil:
>
>    (defun my-dialog (title item-alist)
>      (condition-case nil
>          (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)))))
>        (quit nil)))
>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs forms input
  2010-08-04 16:24     ` Ilya Shlyakhter
@ 2010-08-04 16:29       ` Lennart Borgman
  2010-08-04 16:53         ` Ilya Shlyakhter
       [not found]       ` <mailman.3.1280939390.6287.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 8+ messages in thread
From: Lennart Borgman @ 2010-08-04 16:29 UTC (permalink / raw)
  To: Ilya Shlyakhter; +Cc: help-gnu-emacs, Teemu Likonen

On Wed, Aug 4, 2010 at 6:24 PM, Ilya Shlyakhter <ilya_shl@alum.mit.edu> wrote:
> Thanks, that helps; but I was looking for something more: not simply
> choosing a command from a menu,
> but displaying a dialog with multiple fields, letting the user fill
> some of them, and getting the result --
> like displaying an HTML <FORM>.

I know of no such general solution, but I have tried to do something
like that in "M-x search-form" in nXhtml.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs forms input
  2010-08-04 16:29       ` Lennart Borgman
@ 2010-08-04 16:53         ` Ilya Shlyakhter
  0 siblings, 0 replies; 8+ messages in thread
From: Ilya Shlyakhter @ 2010-08-04 16:53 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: help-gnu-emacs, Teemu Likonen

Great, thanks a lot -- that was exactly what I was looking for!
So, I guess the Emacs Widget Library at
http://www.dina.kvl.dk/~abraham/custom/widget.html
is the answer.
Thanks again!
ilya

p.s. a related question: is there a text-mode menus library,
e.g. something based on the ncurses menus library?
tmm-menubar doesn't let you physically select menu items --
it displays the menu above and you have to choose an item in the
minibuffer.


On Wed, Aug 4, 2010 at 12:29 PM, Lennart Borgman
<lennart.borgman@gmail.com> wrote:
> nXhtml



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs forms input
       [not found]     ` <mailman.1.1280939096.6287.help-gnu-emacs@gnu.org>
@ 2010-08-04 22:23       ` Tim X
  0 siblings, 0 replies; 8+ messages in thread
From: Tim X @ 2010-08-04 22:23 UTC (permalink / raw)
  To: help-gnu-emacs

Ilya Shlyakhter <ilya_shl@alum.mit.edu> writes:

> Thanks, that helps; but I was looking for something more: not simply
> choosing a command from a menu,
> but displaying a dialog with multiple fields, letting the user fill
> some of them, and getting the result --
> like displaying an HTML <FORM>.
>
> Basically, I want the user to call an elisp function with many
> possible optional arguments.
> The standard elisp solution seems to be, "if called with one C-u
> prefix, function does this;
> if called with C-u C-u, it does that; ..." -- this is unintuitive and
> quickly gets hard to remember.
> In a GUI program I'd display a dialog box with multiple fields, with
> some of them filled-in with
> defaults, and let the user change the fields they want.  It seems that
> ncurses should support that?
> Does it?
>
> thanks,
>
> ilya
>
> On Wed, Aug 4, 2010 at 7:55 AM, Teemu Likonen <tlikonen@iki.fi> wrote:
>> * 2010-08-04 11:53 (+0300), Teemu Likonen wrote:
>>
>>> 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))))))
>>
>> Perhaps I should add that if you use C-g (keyboard-quit) or close the
>> dialog box using window's close button that causes a quit signal and the
>> function nor its callers won't return. Here's a new version which will
>> catch the quit signal and, if that happens, return nil:
>>
>>    (defun my-dialog (title item-alist)
>>      (condition-case nil
>>          (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)))))
>>        (quit nil)))
>>
>

What about using emacs' forms? 

tim

-- 
tcross (at) rapttech dot com dot au


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: emacs forms input
       [not found]       ` <mailman.3.1280939390.6287.help-gnu-emacs@gnu.org>
@ 2010-08-05 14:39         ` Ted Zlatanov
  0 siblings, 0 replies; 8+ messages in thread
From: Ted Zlatanov @ 2010-08-05 14:39 UTC (permalink / raw)
  To: help-gnu-emacs

On Wed, 4 Aug 2010 18:29:25 +0200 Lennart Borgman <lennart.borgman@gmail.com> wrote: 

LB> On Wed, Aug 4, 2010 at 6:24 PM, Ilya Shlyakhter <ilya_shl@alum.mit.edu> wrote:
>> Thanks, that helps; but I was looking for something more: not simply
>> choosing a command from a menu, but displaying a dialog with multiple
>> fields, letting the user fill some of them, and getting the result --
>> like displaying an HTML <FORM>.

LB> I know of no such general solution, but I have tried to do something
LB> like that in "M-x search-form" in nXhtml.

Gnus has assistant.el which is very general and IMHO suitable for data
collection.  It supports all the Emacs widgets, I think.  It's not
Gnus-specific although the intent is to eventually use it to set up Gnus
interactively.

Ted


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-08-05 14:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.10.1280910238.19279.help-gnu-emacs@gnu.org>
2010-08-04  8:53 ` emacs forms input Teemu Likonen
2010-08-04 11:55   ` Teemu Likonen
2010-08-04 16:24     ` Ilya Shlyakhter
2010-08-04 16:29       ` Lennart Borgman
2010-08-04 16:53         ` Ilya Shlyakhter
     [not found]       ` <mailman.3.1280939390.6287.help-gnu-emacs@gnu.org>
2010-08-05 14:39         ` Ted Zlatanov
     [not found]     ` <mailman.1.1280939096.6287.help-gnu-emacs@gnu.org>
2010-08-04 22:23       ` Tim X
2010-08-03 22:51 Ilya Shlyakhter

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.