Skip to content

add ansi-color to be required#600

Merged
ricardoricho merged 2 commits intoemacs-dashboard:masterfrom
mmahmoudian:require-ansi-color
Mar 29, 2026
Merged

add ansi-color to be required#600
ricardoricho merged 2 commits intoemacs-dashboard:masterfrom
mmahmoudian:require-ansi-color

Conversation

@mmahmoudian
Copy link
Copy Markdown
Contributor

Recently when I load my Emacs I get the following warning:

⛔ Warning` (native-compiler): dashboard-widgets.el:875:12: Warning: the function ‘ansi-color-apply-on-region’ is not known to be defined.

Which refers to this line:

(ansi-color-apply-on-region start (point-max)))

The issue mostly happens when running Emacs daemon and then connect an emacsclient to it. Also the issue does not always happen.

The ansi-color-apply-on-region is a natively compiled function defined in ansi-color.el.gz. So I think the problem is some sort of race condition, that if dashboard.el is loaded before the ansi-color.el, the error occurs.

I managed to solve it permanently (as far as my testing goes) using the following:

(use-package dashboard
  :ensure t
  :after (:all ansi-color nerd-icons)
  ...
)

Considering this ad-hoc fix, I added (require 'ansi-color) to the dashboard-widgets.el to make sure `ansi-color' is always loaded before we use its functions.

The ansi-color-apply-on-region function from ansi-color is used in this
script, but the ansi-color is not required in the beginning of loading the
package. This means that a race condition can happen that the dashboard is
loaded before ansi-color and causes the following error:

Warning` (native-compiler): dashboard-widgets.el:875:12: Warning: the function
‘ansi-color-apply-on-region’ is not known to be defined.

This commit fixes that by requiring the ansi-color in the correct place.
Copy link
Copy Markdown
Member

@ricardoricho ricardoricho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for the PR.

This is as per kind comment of Ricardo
Arredondo (https://github.com/ricardoricho) since only the
ansi-color-apply-on-region function is used from all the functions in the
ansi-color package.
Copy link
Copy Markdown
Member

@ricardoricho ricardoricho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@ricardoricho ricardoricho merged commit 1c21c25 into emacs-dashboard:master Mar 29, 2026
24 of 28 checks passed
@mmahmoudian mmahmoudian deleted the require-ansi-color branch March 29, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants