* Fontification of the interactive prompt string?
@ 2015-06-05 21:44 Marcin Borkowski
2015-06-05 22:12 ` Tassilo Horn
2015-06-05 22:34 ` Drew Adams
0 siblings, 2 replies; 3+ messages in thread
From: Marcin Borkowski @ 2015-06-05 21:44 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi all,
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.
Is it possible? Bonus points if instead of colors the relevant letter
might be e.g. put in brackets on terminals not supporting colors.
TIA,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Fontification of the interactive prompt string?
2015-06-05 21:44 Fontification of the interactive prompt string? Marcin Borkowski
@ 2015-06-05 22:12 ` Tassilo Horn
2015-06-05 22:34 ` Drew Adams
1 sibling, 0 replies; 3+ messages in thread
From: Tassilo Horn @ 2015-06-05 22:12 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list
Marcin Borkowski <mbork@mbork.pl> writes:
Hi Marcin,
> 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.
>
> Is it possible?
The `interactive' argument may also be a form which reads the arguments
as it sees fit.
,----[ (info "(elisp)Using Interactive") ]
| • It may be a Lisp expression that is not a string; then it should be
| a form that is evaluated to get a list of arguments to pass to the
| command. Usually this form will call various functions to read
| input from the user, most often through the minibuffer (*note
| Minibuffers::) or directly from the keyboard (*note Reading
| Input::).
`----
> Bonus points if instead of colors the relevant letter might be
> e.g. put in brackets on terminals not supporting colors.
I don't know but I would refrain from trying to test terminal
capabilities from elisp and then act differently.
Bye,
Tassilo
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Fontification of the interactive prompt string?
2015-06-05 21:44 Fontification of the interactive prompt string? Marcin Borkowski
2015-06-05 22:12 ` Tassilo Horn
@ 2015-06-05 22:34 ` Drew Adams
1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2015-06-05 22:34 UTC (permalink / raw)
To: Marcin Borkowski, Help Gnu Emacs mailing list
> 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.
>
> 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'.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-05 22:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-05 21:44 Fontification of the interactive prompt string? Marcin Borkowski
2015-06-05 22:12 ` Tassilo Horn
2015-06-05 22:34 ` Drew Adams
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.