From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: Fontification of the interactive prompt string? Date: Fri, 5 Jun 2015 15:34:03 -0700 (PDT) Message-ID: <938d697f-dbf7-4325-b745-ce1ad74038a8@default> References: <87vbf17rtx.fsf@mbork.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1433543699 4477 80.91.229.3 (5 Jun 2015 22:34:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Jun 2015 22:34:59 +0000 (UTC) To: Marcin Borkowski , Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 06 00:34:43 2015 Return-path: Envelope-to: geh-help-gnu-emacs@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 1Z10C7-0002M9-8k for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Jun 2015 00:34:31 +0200 Original-Received: from localhost ([::1]:49909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z10C6-0006vr-Mo for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Jun 2015 18:34:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z10Bv-0006vl-4M for help-gnu-emacs@gnu.org; Fri, 05 Jun 2015 18:34:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z10Bn-0006rx-Us for help-gnu-emacs@gnu.org; Fri, 05 Jun 2015 18:34:19 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:43781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z10Bn-0006ra-Nc for help-gnu-emacs@gnu.org; Fri, 05 Jun 2015 18:34:11 -0400 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t55MY8P0024871 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Jun 2015 22:34:08 GMT Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t55MY6OV015247 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 5 Jun 2015 22:34:08 GMT Original-Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t55MY34q009799; Fri, 5 Jun 2015 22:34:06 GMT In-Reply-To: <87vbf17rtx.fsf@mbork.pl> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:104785 Archived-At: > I have an (interactive "cprompt\n") call, and I'd like the prompt to > list possible characters (they define a few options for my function, > and I have good reasons to implement it this way and not with C-u etc.) > I'd like to have the relevant characters highlighted, like in: > "file: _n_ew, _o_pen, _c_lose" where the underscores mean that > something is e.g. in a different color. >=20 > Is it possible? Yes. The value of variable `minibuffer-prompt-properties' is applied to the prompt. And by default the value is this, which applies a face: `(read-only t face minibuffer-prompt)'. So you will want to bind that variable to a value that does not have any entry for property `face' - e.g., to just `(read-only t)'. Then you can use whatever propertized prompt string you like. Here is something quick-&-dirty, to give you an idea what I mean: ;; Substitute for `completing-read'. It just binds ;; `minibuffer-prompt-properties', to stop it from imposing its ;; single default face. ;; (defun my-compl-read (prompt collection &optional predicate require-match initial-input hist def inherit-input-method) (let ((minibuffer-prompt-properties '(read-only t))) (completing-read prompt collection predicate require-match initial-input hist def inherit-input-method))) (defun my-prompt (string.face-alist) (apply #'concat (mapcar (lambda (s.f) (if (cdr s.f) (propertize (car s.f) 'face (cdr s.f)) (car s.f))) string.face-alist))) (my-compl-read (my-prompt '(("Plain and ") ("highlighted " . font-lock-comment-face) ("text ") ("IS " . font-lock-keyword-face) ("possible: "))) '(a b c d e)) Obviously, you can construct the prompt string in other ways. And instead of defining a function like `my-compl-read' you could use variable `completing-read-function' or advise `completing-read'.