From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: menu system in recent Emacs? Date: Wed, 02 May 2012 21:47:58 -0400 Message-ID: References: <87zk9to1bh.fsf@lifelogs.com> <878vhcgfwu.fsf@lifelogs.com> <87sjfibwhj.fsf@lifelogs.com> <87havybs60.fsf_-_@lifelogs.com> <87havybeks.fsf@thinkpad.tsdh.de> <87wr4u8jgb.fsf@lifelogs.com> <87havy31k5.fsf@gmx.com> <87sjfi8dxt.fsf@lifelogs.com> <8762cem97x.fsf@gnuvola.org> <874nry84qc.fsf@lifelogs.com> <871un2m5j8.fsf@gnuvola.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1336043541 22753 80.91.229.3 (3 May 2012 11:12:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 3 May 2012 11:12:21 +0000 (UTC) Cc: emacs-devel@gnu.org To: Thien-Thi Nguyen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 03 13:12:20 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SPtxM-0000Wq-5G for ged-emacs-devel@m.gmane.org; Thu, 03 May 2012 13:12:20 +0200 Original-Received: from localhost ([::1]:40104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPtxL-0005CZ-Cv for ged-emacs-devel@m.gmane.org; Thu, 03 May 2012 07:12:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:49563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPtxF-0005CS-Nh for emacs-devel@gnu.org; Thu, 03 May 2012 07:12:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPtx9-0007pW-HH for emacs-devel@gnu.org; Thu, 03 May 2012 07:12:13 -0400 Original-Received: from harpie.cc.umontreal.ca ([132.204.2.134]:56632) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPtx9-0007pC-1s for emacs-devel@gnu.org; Thu, 03 May 2012 07:12:07 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q431lx7I011760; Wed, 2 May 2012 21:48:01 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id AD309AE088; Wed, 2 May 2012 21:47:58 -0400 (EDT) In-Reply-To: <871un2m5j8.fsf@gnuvola.org> (Thien-Thi Nguyen's message of "Thu, 03 May 2012 03:12:27 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4210=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4210> : streams <752320> : uri <1106608> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 132.204.2.134 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:150243 Archived-At: > I would really like it to show the list of choices immediately, > as if the user pressed `TAB'. Can that be fed into the > function somehow as a synthetic keypress? > That would be: > (progn > (push ?\t unread-command-events) > (completing-read > "Here are some choices:\n- A\t- B\n- C\t- D\nChoose one: " Note: this will only work when the minibuffer can grow to have enough lines. E.g. my minibuffer-only frame would display this prompt in a way that's rather incomprehensible. > (progn > (push ?\t unread-command-events) > (completing-read > "CHOICE EXPLANATION\nChoose one: " > '("A" "B" "C" "D"))) That's pretty ugly. I recommend something more like (minibuffer-with-setup-hook #'minibuffer-completion-help (completing-read ...)) As for the explanation, you could add an `annotation-function' metadata to the completion-table. Something like (let ((table (lambda (string pred action) (if (eq action 'metadata) `(metadata (annotation-function . ,(lambda (s) (cond ((equal s "A") " explanation a") ((equal s "B") " explanation b") ((equal s "C") " explanation c") ((equal s "D") " explanation d"))))) (complete-with-action action '("A" "B" "C" "D") string pred))))) (minibuffer-with-setup-hook #'minibuffer-completion-help (completing-read "prompt:" table))) -- Stefan