use-package icon indicating copy to clipboard operation
use-package copied to clipboard

Package is being loaded even with deferred keywords

Open Townk opened this issue 7 years ago • 3 comments

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?

Townk avatar May 17 '18 18:05 Townk

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

jwiegley avatar May 17 '18 19:05 jwiegley

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.

Townk avatar May 20 '18 05:05 Townk

  • Can you reproduce this without using :straight?
  • What does M-x pp-macroexpand-last-sexp say that the declaration expands to?

skangas avatar Dec 08 '22 01:12 skangas