Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid turning on the mode in temporary buffers #121

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions color-identifiers-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -816,10 +816,17 @@ evaluates to true."
limit))

(defun color-identifiers-mode-maybe ()
"Enable `color-identifiers-mode' in the current buffer if desired.
When `major-mode' is listed in `color-identifiers:modes-alist', then
`color-identifiers-mode' will be enabled."
(when (assoc major-mode color-identifiers:modes-alist)
"Potentially enable `color-identifiers-mode' in the current buffer.

Specifically, when `major-mode' is listed in
`color-identifiers:modes-alist', and the buffer isn't temporary."
;; Avoid running in temp buffers created by `with-temp-buffer'. Most notably,
;; package installation process is known to create one and then enable
;; `emacs-lisp-mode' for the purpose of parsing autoloads, which in turn triggers
;; color-identifers-mode for no reason. During a huge upgrade this may add up,
;; especially given our ad hoc ELisp parsing code isn't the fastest.
(when (and (not (string-prefix-p " *temp" (buffer-name)))
(assoc major-mode color-identifiers:modes-alist))
(color-identifiers-mode 1)))

(provide 'color-identifiers-mode)
Expand Down
Loading