Use-package: Example in README showing delight and projectile has performance issue

Created on 29 Apr 2020  路  15Comments  路  Source: jwiegley/use-package

I could not think of a good way to work on a PR, so creating an issue instead.

This is what REAME says regarding delight and projectile:

;; Remove the mode name for projectile-mode, but show the project name.
(use-package projectile
  :delight '(:eval (concat " " (projectile-project-name))))

However this under certain circumstances would have serious performance issue, and in my case for a file under go module <some/path>/go/pkg/mod/. The cursor becomes super laggy while CPU is busy computing projectile-project-name (according to profiler), because I guess mode-line is refreshed/reevaluated for each cursor move?

A better way to do this kind of customisation I believe is ~https://docs.projectile.mx/en/latest/configuration/#mode-line-indicator~ https://docs.projectile.mx/projectile/configuration.html#mode-line-indicator

Most helpful comment

@honnix Done!

All 15 comments

@jwiegley Have you got time to take a look at this? Thanks.

It should be easy to do a per-buffer caching of the projectile name:

(defvar buffer-project-project-name nil)
(make-variable-buffer-local 'buffer-project-project-name)

;; Remove the mode name for projectile-mode, but show the project name.
(use-package projectile
  :delight '(:eval (concat " " (or buffer-project-project-name
                                   (setq buffer-project-project-name
                                         (projectile-project-name))))))

However, I don't use delight, so I'm not sure how well this interacts with it.

I can already get decent performance with the following config. I guess per-buffer caching is not required.

(use-package projectile
  :ensure t
  :bind-keymap ("s-p" . projectile-command-map)
  :init
  (setq projectile-completion-system 'ivy
        projectile-mode-line-function '(lambda () (format " [%s]" (projectile-project-name))))
  :config
  (projectile-mode +1))

This is also what projectile suggests. However as you see this does not use delight and that was why I wasn't sure how to work on a PR.

@honnix i think that example is meant more as an example of how to use delight, than how to use projectile :)

@chee Yeah that is true. I was just trying to find a way out so folks will not get hit by the performance issue as I did.

maybe there should be a repo of use-package snippets for people to share good base use-package config for various packages. it took a while for me to get projectile and eaf right, for instance. late night benchmark-init vibes

a repo of use-package snippets for people to share good base use-package config

That sounds great. @jwiegley What do you think?

I think that's a fantastic idea, @honnix! The only issue is making sure that they're all up to date and actually work. :)

That almost sounds like a luxury problem to have, so not a bad thing. :) I think if it gets bootstrapped, people will start contributing and sending PRs to make things more or less up to date. Depending on how this is done, adding CI is also possible.

Good point. I'm all for it! Want to start us off?

@jwiegley Yes! I will think about possible ways going forward and propose them here first. @chee If you have already got thoughts around this, please leave them here. :)

@jwiegley Would you like to create a repo under your account? Something like use-package-examples might work. I can fork, add things and start a PR.

@honnix Done!

how exciting!

so what are you thinking? one .el file per project, with maybe a few different examples for different setups/considerations?

or even a .org file with #+begin_src emacs-lisp blocks so they render nicely on github? oh, and that way they there could even be a handsome gh-pages rendering for the example files too :3

i've started moving my entire computer configuration over to org-mode (emacs init here) and i think this sort of project might work very well like that, because we'd want to encourage explaining why particular choices were made and when they'll no longer be relevant. encouraging good documentation because the PRs are for an org-mode file rather than a .el file

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davep picture davep  路  6Comments

sondr3 picture sondr3  路  14Comments

DarkWingMcQuack picture DarkWingMcQuack  路  4Comments

cswarth picture cswarth  路  5Comments

Yevgnen picture Yevgnen  路  5Comments