2

I have seen that emacs provides some kind of popup menus. Had a go at momentary-string-display and message-box. momentary-string-display displays text in the buffer, whereas message-box displays a box with button.

Can one momentarily show a kind of popup similar to autocomplete or company, something similar to popup tooltip with a coloured background colour, so I do not have to switch to another buffer to see the information I want printed?

1 Answer 1

1

There are a number of packages that provide functionality to display inline information in the buffer. The builtin package eldoc will display information about the current function at point below the modeline, which is often sufficient, but not quite a popup.

The most common approach for selectively displaying information inline or near the current point, is to use an overlay, which are attributes attached to a range of characters. Take a look at how company.el uses the functions overlay-get and overlay-put to attach properties to the text near a popup, and change the face of the text depending on where the point is.

If you are looking for a library that encapsulates this behavior using overlays, take a look at popup.el, or quick-peek. There are other approaches as well, eldoc-box appears to be using a childframe triggered by an overlay. That said, many of the help systems in emacs provide context information in a temporary popup buffer. It may be worth trying that approach first.

Providing more context on what you intend to use the popup for might help in selecting which of these is appropriate for your task.

6
  • 1
    With temporary popup buffer, do you mean something like (with-output-to-temp-buffer "*protocuneus*" (print summary-string))?
    – Dilna
    Commented Aug 23, 2022 at 12:32
  • Yea or with a helper that calls (with-current-buffer (get-buffer-create name) (mode) (insert content)). Take a look at the function help--window-setup and help-form-show in help.el, I believe that's how C-h f generates a help buffer.
    – dgtized
    Commented Aug 23, 2022 at 19:04
  • Do you know how to switch to the temporary help buffer when I call the help-function from another buffer? Currently doing M-x myhelp shows the temporary buffer but does not switch to it.
    – Dilna
    Commented Aug 24, 2022 at 0:26
  • switch-to-buffer or switch-to-buffer-other-window?
    – dgtized
    Commented Aug 25, 2022 at 2:20
  • What do you think of pop-to-buffer compared to switch-to-buffer?
    – Dilna
    Commented Aug 25, 2022 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.