jwiegley / use-package

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

Package is being loaded even with deferred keywords #680

Open Townk opened 6 years ago

Townk commented 6 years ago

I have the following use-package entry on my init.el:

;; https://github.com/noctuid/targets.el
(use-package targets
  :straight (:host github
             :repo "noctuid/targets.el")

  :hook (prog-mode . my/setup-targets)

  :custom
  (targets-user-text-objects '((paren "(" ")" pair :more-keys ("b" "9" "0"))))
  (targets-share-last-text-object t)

  :config
  (defun my/setup-targets ()
    (message "I'm setting up TARGETS")
    (targets-setup t))

  (message "This is TARGETS config body")
  (targets-define-to org-italic "/" nil quote
                     :hooks (org-mode-hook))
  (targets-define-to org-bold "*" nil quote
                     :hooks (org-mode-hook))
  (targets-define-to org-emphasis "_" nil quote
                     :hooks (org-mode-hook))
  (targets-define-to org-description ":" nil quote
                     :hooks (org-mode-hook))

  (general-define-key :keymaps 'global
                      :states '(visual operator)
                      "RET" #'targets-last-text-object))

As far as I understood by the documentation, here I should see "I'm setting up TARGETS" and "This is TARGETS config body" only when a prog-mode is activated.

When I start emacs, my config takes me to the scratch buffer. When I'm there I check the messages and this is the content:

Loading package use-package-ensure-system-package...done
Loading package general...
Configuring package general...done
Loading package general...done
Loading package no-littering...
Configuring package no-littering...
Loading /Users/thiagoa/.emacs.d/config/customize.el (source)...done
Configuring package no-littering...done
Loading package no-littering...done
Loading package ivy...
Configuring package ivy...done
Loading package ivy...done (0.132s)
Loading package paren...
Configuring package paren...done
Loading package paren...done
Loading package savehist...
Configuring package savehist...done
Loading package savehist...done
Loading package saveplace...
Configuring package saveplace...done
Loading package saveplace...done
Loading package evil...
Configuring package evil...done
Loading package evil...done
Loading package evil-collection...
Configuring package evil-collection...done
Loading package evil-collection...done
Configuring package targets...
This is TARGETS config body
Configuring package targets...done
Loading package doom-themes...
Configuring package doom-themes...done (0.132s)
Loading package doom-themes...done (0.166s)
Loading package solaire-mode...done
Loading package doom-modeline...
Configuring package doom-modeline...done
Loading package doom-modeline...done
For information about GNU Emacs and the GNU system, type <f1> C-a.
Emacs ready in 1.90 seconds with 5 garbage collections.
Configuring package shackle...done
Configuring package projectile...
Loading /Users/thiagoa/.emacs.d/data/recentf-save.el (source)...done
Cleaning up the recentf list...done (0 removed)
Configuring package projectile...done
Configuring package anzu...done
Loading package evil-anzu...
Configuring package evil-anzu...done
Loading package evil-anzu...done

Notice that I have the This is TARGETS config body message, even though my scratch is configured to be in the fundamental-mode with (setq-default initial-major-mode 'fundamental-mode).

What am I missing here?

jwiegley commented 6 years ago

If you add :defer t, does it defer loading as you expected?

Townk commented 6 years ago

Nope, it does not.

This is the messages after I start Emacs:

Configuring package targets...
This is TARGETS config body
Configuring package targets...done
Loading package doom-themes...
Configuring package doom-themes...done (0.137s)
Loading package doom-themes...done (0.166s)
Loading package solaire-mode...done
Loading package doom-modeline...
Configuring package doom-modeline...done
Loading package doom-modeline...done
Configuring package eldoc-eval...done
I’m setting up TARGETS
For information about GNU Emacs and the GNU system, type <f1> C-a.
Emacs ready in 1.74 seconds with 5 garbage collections.
Configuring package shackle...done
Configuring package projectile...
Loading /Users/thiagoa/.emacs.d/data/recentf-save.el (source)...done
Cleaning up the recentf list...done (0 removed)
Configuring package projectile...done
Configuring package anzu...done
Loading package evil-anzu...
Configuring package evil-anzu...done
Loading package evil-anzu...done

The message Emacs ready in 1.74 seconds with 5 garbage collections. is the last thing on my init.el. The rest of the loadings are the result of a deffer or the scratch buffer mode.

skangas commented 1 year ago