I'm trying to use use-package
to load projectile
. Projectile uses helm
for completion, which I'm also loading with use-package
. Since projectile and helm have :bind
sections I believe they're both being lazy-loaded.
My problem is that when I try to open a project in projectile it gives me the error message 'No projects need to be removed' after I've pressed C-c p
. If I C-g
to get out of that, and then press C-c p p
I get the error message Please install helm from https://github.com/emacs-helm/helm
.
If I open up my config file and evaluate the use-package form for helm then the 'open project' feature works great in projectile (i.e., C-c p p
puts me into helm to open a known project).
My gut feeling is that use-package is deferring the loading of both helm and projectile. Pressing the projectile key combo must load projectile but not helm (even though I've got an :after
section in my projectile config saying to load after helm.
Indeed - I can force helm to load (by invoking helm-recentf
), after which projectile's open project feature works great.
How do I force use-package to load both projectile AND helm, when a key combo for projectile is pressed?
Here's what I've got for helm & projectile in my config file:
(use-package helm
:ensure t
:bind (
("C-x b" . helm-buffers-list)
("C-S-y" . helm-show-kill-ring)
("C-x m" . helm-M-x)
("C-x C-f" . helm-find-files)
("C-r" . helm-recentf)
)
:config
(helm-mode 1)
(setq helm-ff-file-name-history-use-recentf t)
)
(use-package projectile
:ensure t
:pin melpa-stable
:after helm
:bind-keymap (
("C-c p" . projectile-command-map)
)
:config
;; (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
;; (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(projectile-mode +1)
(setq-default
projectile-completion-system 'helm
projectile-switch-project-action #'projectile-find-file-dwim
;; Display project name, or else remove this section
projectile-mode-line '(:eval (if (string= "-" (projectile-project-name) ) " " (format " [%s] " (projectile-project-name) ) ) )
)
)
EDIT: If I add :demand t
to the use-package for helm then projectile's open-project works great. So it looks like the problem is that use-package is loading projectile, but not it's dependencies.
EDIT 2: Is this a bug in use-package?
(require 'helm)
to the:config
section ofprojectile
. projectile needs helm but without loading helm, thus its users have to make sure helm is loaded by themselves if they want the helm support.:after helm
, since it just makes all your projectile configuration unavailable until helm has been loaded. If you are not very familiar with use-package, simply use the plainwith-eval-after-load
etc, after everything is working "translate" it to the use-package form. BTW, use-package is a hard thing, I guess many users (me included) don't understand its implementation.