conao3 / leaf.el

Flexible, declarative, and modern init.el package configuration
GNU General Public License v3.0
505 stars 28 forks source link

Using :ensure (straight) and :after #524

Closed hans-d closed 2 years ago

hans-d commented 2 years ago

Description

I'm using leaf together with straight. The combination :ensure and :after is somehow not working ok-ish, or I'm missing how I should do it.

If have p1 before p2 in the init.el (generated out of a .org) and was expecting this is how I could control load order.

example 1

Issue leaf-block

(leaf p1
  :ensure t
  :after p2)

macroexpand-1 leaf-block

(prog1 'p1
  (straight-use-package 'p1))

Expected leaf-block

(prog1 'p1
  (eval-after-load 'p2
    '(progn
       (straight-use-package 'p1))))

example 2

Issue leaf-block

(leaf p1
  :require t
  :ensure t
  :after p2)

macroexpand-1 leaf-block

(prog1 'p1
  (straight-use-package 'p1)
  (eval-after-load 'p2
    '(progn
       (require 'p1))))

Expected leaf-block

(prog1 'p1
  (eval-after-load 'p2
    '(progn
       (straight-use-package 'p1)
       (require 'p1))))

using straight on ensure

(leaf leaf-keywords
    (straight-use-package 'leaf-keywords)
    :custom
    (leaf-alias-keyword-alist .'((:ensure . :straight)))
    :config
    (leaf-keywords-init))
Hxppdv commented 2 years ago

https://github.com/radian-software/straight.el/tree/develop#what-does-it-mean-to-load-a-package https://github.com/radian-software/straight.el/tree/develop#what-happens-when-i-call-straight-use-package although the word load is used, straight.el does not require the package, which means that straight-use-package does not load the files of the package.

I think use-package use the word load to mean requiring, because that is what it's for. In fact use-package does the same thing as leaf.

(use-package p1
  :straight t
  :after p2)
(progn
  (straight-use-package 'p1)
  (defvar use-package--warning145
    #'(lambda
        (keyword err)
        (let
            ((msg
              (format "%s/%s: %s" 'p1 keyword
                      (error-message-string err))))
          (display-warning 'use-package msg :error))))
  (condition-case-unless-debug err
      (eval-after-load 'p2
        '(let
             ((now
               (current-time)))
           (message "%s..." "Loading package p1")
           (prog1
               (if
                   (not
                    (require 'p1 nil t))
                   (display-warning 'use-package
                                    (format "Cannot load %s" 'p1)
                                    :error))
             (let
                 ((elapsed
                   (float-time
                    (time-subtract
                     (current-time)
                     now))))
               (if
                   (> elapsed 0.1)
                   (message "%s...done (%.3fs)" "Loading package p1" elapsed)
                 (message "%s...done" "Loading package p1"))))))
    (error
     (funcall use-package--warning145 :catch err))))

so everything is ok here, i don't think there's somthing leaf should do.

conao3 commented 2 years ago

Thanks @Hxppdv.

@hans-d, I cannot understand the issue, closing for now, but please re-open if you have any questions.