jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.39k stars 259 forks source link

:delight `:eval` setup requires me to toggle modes first #704

Closed hjpotter92 closed 4 years ago

hjpotter92 commented 6 years ago

I have set the following for my projectile package:

(use-package projectile
  :ensure t
  :after (ivy magit)
  :delight (projectile-mode '(:eval (format "P[%s]" (projectile-project-name))))
  :bind
  (("C-x p" . projectile-switch-project))
  :init
  (progn
    (projectile-mode t))
  :custom
  ((projectile-enable-caching t)
   (projectile-completion-system 'ivy)
   (projectile-require-project-root nil)
   ;; (projectile-mode-line '(:eval
   ;;                         (if (projectile-project-p)
   ;;                             (format "P[%s]" (projectile-project-name))
   ;;                           "")))
   (projectile-tags-backend "ggtags"))
  :config
  (progn
   (setq projectile-project-root-files-bottom-up (delete ".git" projectile-project-root-files-bottom-up))
    (dolist (item '("GTAGS" "GRTAGS" "GPATH"))
      (add-to-list 'projectile-globally-ignored-files item))
    ;; Git projects should be marked as projects in top-down fashion,
    ;; so that each git submodule can be a projectile project.
    (add-to-list 'projectile-project-root-files ".git")
    (mapc #'projectile-add-known-project
          (mapcar #'file-name-as-directory (magit-list-repos)))
    ;; Optionally write to persistent `projectile-known-projects-file'
    (projectile-save-known-projects)))

A lot of it was copied from different sections from .emacs setups found around github. When I open a file inside a git project, my modeline displays something like:

2018-07-13_13_04_30

Notice how projectile-project-name is displayed around the file-name. Now, if I toggle projectile-mode twice (it is already on, I switch it off then back to on):

2018-07-13_13_07_25

It starts respecting the :delight section I have in my use-package.


My emacs is 26.1.50, compiled locally.

honnix commented 4 years ago

The readme says something like:

(use-package projectile
  :delight '(:eval (concat " " (projectile-project-name))))

while you have

:delight (projectile-mode '(:eval (format "P[%s]" (projectile-project-name))))
honnix commented 4 years ago

This would however cause performance issue under certain circumstances, and in my case for a file under go module <somewhere>/go/pkg/mod/.

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

hjpotter92 commented 4 years ago

Updating it to the documented version did fix the issue. However, you're correct. I should make use of the projectile-mode-line-function instead.