jwiegley / use-package

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

Strange behavior of use-package with Helm when using :bind #893

Closed FabArd closed 1 year ago

FabArd commented 3 years ago

Hi,

I noticed a strange behavior of use-package with helm when using :bind :

When I start Emacs, if no Helm command has been executed, if I use C-h v or C-h f those command do not use helm. After executing a command of helm (for example Helm-M-x) C-h v, C-h f respond with helm.

I noticed that the problem is generated if the key binding is made by ":bind".

Here are the tests I performed :

1 - configuration without problem : (use-package helm :config (helm-mode t) (global-set-key (kbd "M-x") 'helm-M-x))

Restart Emacs and test C-h v or C-h f : responding with Helm

2 - configuration with problem : (use-package helm :config (helm-mode t) :bind ("M-x" . helm-M-x))

Restart Emacs and test C-h v or C-h f : Helm is not responding execute a Helm command (for exempla M-x for the helm-M-x) as define in this config. test again C-h v or C-h f : Helm is responding.

collares commented 3 years ago

:bind defers loading (to when you use one of the bound keys), and :config runs only after the package is loaded. So I think the behavior you're seeing is expected.

conao3 commented 3 years ago

Please use :demand t if you want to load when emacs wake up. (macroexpand use-package is the fastest way to understand use-package)

(setq use-package-expand-minimally t)
;;=> t

(macroexpand
 '(use-package helm
    :config
    (helm-mode t)
    :bind ("M-x" . helm-M-x)))
;;=> (progn
;;     (unless (fboundp 'helm-M-x)
;;       (autoload #'helm-M-x "helm" nil t))
;;     (eval-after-load 'helm
;;       '(progn
;;          (helm-mode t)
;;          t))
;;   
;;     (bind-keys :package helm ("M-x" . helm-M-x)))

(macroexpand
 '(use-package helm
    :demand t
    :config
    (helm-mode t)
    :bind ("M-x" . helm-M-x)))
;;=> (progn
;;     (require 'helm nil nil)
;;     (helm-mode t)
;;     t
;;     (bind-keys :package helm
;;                ("M-x" . helm-M-x)))
lispstudent commented 3 years ago

I had same issue. This invocation fixed it for me:

(use-package helm
  :defer 3
  :config
  (require 'helm-config)
  (helm-mode 1)
  :bind
  (("M-x"      . helm-M-x)
   ("C-x b"    . helm-mini)
   ("C-x r b"  . helm-filtered-bookmarks)
   ("C-x C-f"  . helm-find-files)
   ("C-x f"    . helm-for-files)))
skangas commented 1 year ago

:bind defers loading (to when you use one of the bound keys), and :config runs only after the package is loaded. So I think the behavior you're seeing is expected.

I have to agree, this is the expected behavior.