From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Matthew Mundell Newsgroups: gmane.emacs.devel Subject: Re: Improved help from minibuffer prompts Date: 15 Apr 2004 12:42:10 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87y8oxh3hp.fsf@sno.mundell.ukfsn.org> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1082032191 28502 80.91.224.253 (15 Apr 2004 12:29:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 15 Apr 2004 12:29:51 +0000 (UTC) Cc: emacs-devel Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Apr 15 14:29:40 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BE5zv-0001Yx-00 for ; Thu, 15 Apr 2004 14:29:39 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BE5zv-0003Me-00 for ; Thu, 15 Apr 2004 14:29:39 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BE5zT-0005Bk-0F for emacs-devel@quimby.gnus.org; Thu, 15 Apr 2004 08:29:11 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BE5Th-0007SI-WD for emacs-devel@gnu.org; Thu, 15 Apr 2004 07:56:21 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BE5H3-000517-7w for emacs-devel@gnu.org; Thu, 15 Apr 2004 07:43:49 -0400 Original-Received: from [217.158.120.143] (helo=mail.ukfsn.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BE5G4-0004np-Cz for emacs-devel@gnu.org; Thu, 15 Apr 2004 07:42:16 -0400 Original-Received: from localhost (lucy.ukfsn.org [127.0.0.1]) by mail.ukfsn.org (Postfix) with ESMTP id 30D10E6DE4; Thu, 15 Apr 2004 12:39:26 +0100 (BST) Original-Received: from mail.ukfsn.org ([127.0.0.1]) by localhost (lucy.ukfsn.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 29855-11; Thu, 15 Apr 2004 12:39:26 +0100 (BST) Original-Received: from sno.mundell.ukfsn.org (dsl213-218-238-16.as15444.net [213.218.238.16]) by mail.ukfsn.org (Postfix) with ESMTP id 9BE3EE6FE8; Thu, 15 Apr 2004 12:39:25 +0100 (BST) Original-Received: from sno.mundell.ukfsn.org ([10.0.0.3]) by sno.mundell.ukfsn.org with esmtp (Exim 3.36 #1 (Debian)) id 1BE5Fz-0002LC-00; Thu, 15 Apr 2004 12:42:11 +0100 Original-To: =?iso-8859-1?q?Stefan_Reich=F6r?= Original-Lines: 188 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:21683 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:21683 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Stefan Reich=F6r writes: > Hi! >=20 > I am currently working on xtla.el (the arch interface for emacs). >=20 > In my mode the user is often asked some questions in the > minibuffer. Sometimes the questions need some more > explanations. So I decided to put the needed help in the > function's docstring. Here's a function called `question' which may be of use. It allows the responses to an interactive question to be defined, including a help response and associated help string. The patch includes a change to `shell-command' to use `question', in the way suggested for the `compile' command by Dan Jacobson (in the attached mail). This allows `shell-command' to start concurrent asynchronous shell commands. The function `may-y-or-n-p' may also be useful. Note that `question' will need dialog popup additions to be better analogous to yes-or-no-p. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v retrieving revision 1.634 diff -u -r1.634 simple.el --- lisp/simple.el 25 Mar 2004 16:01:37 -0000 1.634 +++ lisp/simple.el 15 Apr 2004 11:14:47 -0000 @@ -1227,6 +1227,62 @@ '(0 . 0))) '(0 . 0))) =0C +(defvar question-history nil) + +(defun question (prompt &optional responses help-response) +"Prompt with PROMPT for a response from RESPONSES. + +RESPONSES is an alist associating responses with returns. Each +member of RESPONSES is of the form (\"response\" . return). For +example '((\"yes\" . t) (\"no\" . n)). The return can be +anything except nil, which is used when searching the list. + +HELP-RESPONSE is a cons cell with a response as its car and a +help string as its cdr. If the help response is entered the +string is displayed in the other buffer and prompting continues. + +If only PROMPT is given `yes-or-no-p' is called with PROMPT as +its argument." + (if responses + (let ((options)) + ;; add alternatives to prompt + (let (rest (answers (if help-response + (append responses (list help-response)) +=09 + responses))) + (while answers + (setq options + (concat options + (if (prog1 rest (setq rest t)) + (if (cdr answers) + (concat ", " + (car (car answers))) + (concat " or " + (car (car answers)))) + (car (car answers))))) + (setq answers (cdr answers)))) + (setq prompt (concat prompt "(" options ") ")) + ;; return the value associated with a prompted response + (cdr (let (ret rsp) + (while (not + (setq ret (assoc (setq rsp (read-from-minibuffer + prompt nil nil nil + question-history nil + nil)) + responses))) + (if (and help-response + (equal rsp (car help-response))) + (with-output-to-temp-buffer "*Help*" + (princ (cdr help-response)) + (with-current-buffer standard-output + (help-mode))) + (ding) + (discard-input) + (message "Please answer %s." options) + (sleep-for 2 nil))) + ret))) + (yes-or-no-p prompt))) +=0C (defvar shell-command-history nil "History list for some commands that read shell commands.") =20 @@ -1356,9 +1412,23 @@ ;; If will kill a process, query first. (setq proc (get-buffer-process buffer)) (if proc - (if (yes-or-no-p "A command is running. Kill it? ") - (kill-process proc) - (error "Shell command in progress"))) + (let ((res (question + "A command is running. Kill it? " + '(("yes" . t) ("no" . no) ("r" . run)) + '("?" . "An asynchronous command is already running in the \"*Async = Shell Command*\" buffer. +Enter + \"yes\" to kill the running command, replacing it with the new one, + \"no\" to quit, leaving the current command running, or + \"r\" to run the new command in parallel in a uniquely-named buffer= .")))) + (cond + ((eq res 'run) + (setq buffer (get-buffer-create + (generate-new-buffer-name + (buffer-name buffer))))) + ((eq res t) (kill-process proc)) + ((eq res 'no) (error "Shell command in progress")) + ;; question-p prevents this case + (t (error "Error processing response"))))) (with-current-buffer buffer (setq buffer-read-only nil) (erase-buffer) --=-=-= Content-Type: message/rfc822 Content-Disposition: inline Path: main.gmane.org!not-for-mail From: Dan Jacobson Newsgroups: gmane.emacs.bugs Subject: A Compilation process is running; kill it? (yes or no) Date: Wed, 17 Mar 2004 10:13:35 +0800 Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Approved: news@gmane.org Message-ID: <87vfl4jk4w.fsf@jidanni.org> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1079553524 7894 80.91.224.253 (17 Mar 2004 19:58:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 17 Mar 2004 19:58:44 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 17 20:58:39 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B3hBW-0004m8-00 for ; Wed, 17 Mar 2004 20:58:38 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B3hBQ-0003vD-4F for geb-bug-gnu-emacs@m.gmane.org; Wed, 17 Mar 2004 14:58:32 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B3hBM-0003v3-9h for bug-gnu-emacs@gnu.org; Wed, 17 Mar 2004 14:58:28 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B3hAp-0003gX-Me for bug-gnu-emacs@gnu.org; Wed, 17 Mar 2004 14:58:26 -0500 Original-Received: from [204.74.68.40] (helo=frodo.hserus.net) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.30) id 1B3hAp-0003ef-CF for bug-gnu-emacs@gnu.org; Wed, 17 Mar 2004 14:57:55 -0500 Original-Received: from tc218-187-78-158.2-4.pl.apol.com.tw ([218.187.78.158]:32793 helo=jidanni.org) by frodo.hserus.net with asmtp (Cipher TLSv1:RC4-SHA:128) (Exim 4.30 #2) id 1B3hAb-0009om-TW by authid with plain for ; Thu, 18 Mar 2004 01:27:42 +0530 Original-Received: from jidanni by jidanni.org with local (Exim 4.30) id 1B3QYp-0001Vv-U8 for bug-gnu-emacs@gnu.org; Wed, 17 Mar 2004 10:13:35 +0800 Original-To: bug-gnu-emacs@gnu.org User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:7303 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii When attempting a second compilation, instead of asking A Compilation process is running; kill it? (yes or no) ask A Compilation process is running;a kill it? (yes or q) which is more telling instead of "no". Better yet, ask A Compilation process is running; kill it? (yes, c, q, ?) c - launch a parallel compilation. --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel --=-=-=--