4

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?

Drew
  • 29,895
  • 7
  • 74
  • 104
Alan
  • 1,889
  • 2
  • 18
  • 30
  • Sounds like a good thing. Why don't you suggest this as an addition to Emacs. I believe that you can use the Help -> Send Bug Report menu item for this. – Lindydancer Dec 13 '13 at 21:32
  • @Alan: aren't you talking about the mini-buffer instead of the modeline? – TacticalCoder Dec 14 '13 at 00:10
  • The function at issue is `query-replace-read-from` within `replace.el`. And, yes, @TacticalCoder is correct -- the mini-buffer is at issue, not the modeline. It should be possible to use font-lock for different elements of the `query-replace-read-from` or something like an overlay / text-properties. Modifying the format of the layout is also possible. We already know it is possible to change the font for `minibuffer-prompt` and also set minibuffer default font with an enter/exit-minibuffer-setup; so it should be possible to do what you propose. – lawlist Dec 14 '13 at 00:17

1 Answers1

2

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.

Drew
  • 29,895
  • 7
  • 74
  • 104