1

I'm trying to display some highlighted text in the Emacs minibuffer. I know it's possible because SLIME does it when displaying argument hints. However, I can't see how it's being accomplished by looking at slime.el. Based on what I'm reading there, the displayed text shouldn't be highlighted (relevant section starts at line 3615).

I've tried

  • (message "%s" (propertize "test" 'face 'highlight))
  • (overlay-put (make-overlay (point-min) (point-min)) 'before-string (propertize "test" 'face 'highlight))
  • (with-current-buffer (window-buffer (minibuffer-window)) (insert (propertize "test" 'face 'highlight)))

That last one seems closest to what I want, but the displayed text appears and disappears sporadically as I move point, and it has to be manually removed later. I've also tested the solution given here, and it doesn't seem to work for me either. The non-working solutions all do the same thing; display the text

  #("test" 0 4 (face highlight))

in the minibuffer.

In case it matters, I'm running Emacs 23.4.1 on Debian Wheezy.

Community
  • 1
  • 1
Inaimathi
  • 13,853
  • 9
  • 49
  • 93

1 Answers1

2

You're victim of testing with M-: which additionally to running the code, displays the returned value in the minibuffer, thus immediately overwriting whatever your code has done.

Stefan
  • 27,908
  • 4
  • 53
  • 82
  • Actually, I'm testing with `C-M-x`, but the effect is the same. You are correct; binding the snippet to a key lets the first option work. – Inaimathi Jul 29 '13 at 03:15
  • 1
    You can also test it with `C-j` in the \*scratch\* buffer (the result is inserted in the buffer instead of displayed in the minibuffer), or you can use `M-x ielm`. – Stefan Jul 29 '13 at 13:36