Question

When I use query-replace to replace, say, "abc" by "def", and then call query-replace again, I get a minibuffer that looks like this, all in the same face:

  Query replace (default abc -> def):

It would be easier to read this line if "abc" and "def" were displayed in a different face. This would be even more pronounced if either the search or replacement string contained spaces, or parentheses, or arrows, all of which would blend with the prompt around them. I would expect a different face for the search and replacement strings to be offered by default. However, I can't find anything in the documentation that even allows one to separately customize the faces used to show the search and replacement strings. Can someone provide me with some code that I could use to do this?

Was it helpful?

Solution

Use library replace+.el -- description here.

See also Emacs bug #16136, which is a related enhancement request. The problem is that users can currently decide only whether the entire prompt is to have a face. (And if so, they can customize that face.) What's needed is the ability to do that, but also let that face take a back seat to any faces that might already be given to particular parts of the prompt string.

Library replace+.el turns off the face over the entire prompt, and highlights important parts of the prompt (exactly the ones you are requesting) in different faces (which you can of course customize. If enhancement request #16136 is implemented, then the rest of the prompt can be kept in the normal prompt face (minibuffer-prompt).

It's a bit hard to believe that the design for this was so shortsighted in Emacs, but it was. And it is implemented in C code, so it is not very amenable to user improvement. Let's hope for a fix. Meanwhile, you can get what you request, but without minibuffer-prompt being used on the rest of the prompt, by loading replace.el.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top