seagle0128 / doom-modeline

A fancy and fast mode-line inspired by minimalism design.
https://seagle0128.github.io/doom-modeline/
GNU General Public License v3.0
1.27k stars 157 forks source link

[Bug] Custom segment makes emacs lag #670

Closed 0x4d6165 closed 11 months ago

0x4d6165 commented 11 months ago

Thank you for the bug report

Bug description

Defining a custom segment results in emacs slowing to a crawl. I don't think my custom segment is overly complex but maybe it's being polled too much?

Steps to reproduce

(use-package doom-modeline
  :straight t
  :after nerd-icons
  :config
  (setq doom-modeline-battery t)
  (setq doom-modeline-time t)
  (add-hook 'doom-modeline-mode-hook
            (lambda ()
                (doom-modeline-set-modeline 'my-custom-modeline 'default)))
  (doom-modeline-def-segment todo-count
  "Display the remaining number of todo items."
  (let ((todo-count (count-todos-in-org-files)))
        (propertize (format " %s" todo-count)
                    'face '(:foreground "yellow")))) 
  (doom-modeline-def-modeline 'my-custom-modeline
  '(bar workspace-name window-number modals matches buffer-info remote-host buffer-position word-count parrot selection-info)
  '(objed-state misc-info persp-name grip todo-count irc mu4e gnus github debug input-method indent-info buffer-encoding lsp major-mode process vcs checker battery time))

  (setq doom-modeline-modeline 'my-custom-modeline)
  (add-hook 'doom-modeline-mode-hook
            (lambda ()
                (doom-modeline-set-modeline 'my-custom-modeline 'default)))
  :hook (after-init . doom-modeline-mode))

Define a custom segment and add it to the modeline.

Expected behavior

I expected the current number of org todos to be output to the modeline without introducing noticeable latency

OS

Linux

Emacs Version

29

Emacs Configurations

https://git.sr.ht/~x4d6165/.emacs.d

Error callstack

No response

Anything else

No response

seagle0128 commented 11 months ago

Is count-todos-in-org-files the bottle-neck? Do profiling, then you will find out the root cause.