doomemacs / doomemacs/core

+popup-mode should support ansi-color rendering or provide a hook to specify which popups can support ansi-color codes

Open
#8,216 0 comments 0 reactions 0 assignees View on GitHub
is:bug needs-triage
Dominant language
Emacs Lisp
Stars
22.7k
Forks
3.1k
Avg merge
10h 46m
Merged PRs (30d)
4

Description

### I confirm that...

- [x] I have searched the [issue tracker](https://github.com/doomemacs/doomemacs/issues), [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [Discourse](https://discourse.doomemacs.org), and [Google](https://google.com), in case this issue has already been reported/resolved.

- [x] I have read "[How to Debug Issues](https://doomemacs.org/d/how2debug)", and will use it to provide as much information about this issue as possible.

- [x] The issue can be reproduced on the **latest** available commit of Doom.

- [x] The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. *(Unstable versions end in .50, .60, or .9x)*

### Expected behavior

* ideal: the popup supports ansi-colors out of the box
* compromised: provide the right hook to enable ansi-colors in config.el:

### Current behavior

ansi-color codes are not applied:

![Image](https://github.com/user-attachments/assets/07860bc9-15ff-45b9-8e41-ef6260d63ba1)

This is related possibly to this issue in lsp-metals in outputting ansi-color codes to begin with: https://github.com/scalameta/metals/issues/2621

### Repro steps:

Fedora 41 | emacs 29.3 | doom latest as of 12/30/24

* with init.el having (scala +lsp), lsp-mode, and syntax enabled
* create a random `.scala` file somewhere (e.g. `foo.scala`)
* do not add current project folder to lsp-workspace and do not connect lsp server at this moment (i.e. press `n` upon initial request)
* start typing (e.g. `implicit d`)
* see popup buffer with a bunch of ansi-color codes:

I've written a simple function in config.el that enables ansi-colors to a buffer, but need to run it with the correct hook which I could not find (which is either due to my limited knowledge of emacs and doom or something else). BTW, I've posted this in the discord emacs-help channel as well.

My function:

```elisp
(require 'ansi-color)
(defun apply-colors ()
(let ((inhibit-read-only t))
(ansi-color-apply-on-region (point-min) (point-max))))
```

If I run this interactively, I can enable the color in the resulting `*Messages*` buffer manually. Or if I hook this into '+popup-buffer-mode-hook, it runs whenever I click into an actively select the popup buffer in question.

![Image](https://github.com/user-attachments/assets/bb821862-7285-42c5-ac4d-76329cbab347)

But the popup when it appears doesn't seem to colorize on its own.

This leads me to believe that the hook isn't being run because popup doesn't immediately switch buffers to the newly created popup. Instead, it gets applied to the current buffer which is the main file I'm editing which doesn't include color codes... So is there already a way to apply a hook to when the popup gets called or select the inactive popup buffer to apply the hook OR is there something else I'm missing?

Again, this could be due to my limited knowledge of emacs, elisp, and doom. But I've looked everywhere! Google, claude, chatgpt, gemini, discord, etc.

Thanks, and hope you all have a great new year!

### System Information

https://pastebin.com/0NSSe3LU

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.