emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What does use-package do?


From: Philip Kaludercic
Subject: Re: What does use-package do?
Date: Tue, 11 Oct 2022 09:17:56 +0000

Naoya Yamashita <conao3@gmail.com> writes:

> (I used to send Email from gnus, but I have already lost my gnus
> settings and will reply from Gmail.  I hope I get it right.)
>
>> There was talk of integrating leaf into use-package a year ago.
>
> Nothing is going on with integrating leaf and use-package as no
> one is working on it.  Honestly, I don't like use-package because
> it has surprising behavior that often seems nosy.  That is why
> leaf was created, to organize/reduce the features that
> use-package has and to give user a better interface, which is
> why it cannot be integrated.
>
> On the other hand, I agree that leaf has a puzzling internal
> structure.  It has huge conditional branches directly in a list,
> dynamically generating S-expressions and eval'ing them.  This
> structure makes debugging difficult and adding new features
> difficult for new people. (I can do it, though.)  This is why I
> am hesitant to have it standardized in Emacs.
>
> In summary, the functionality that use-package already provides
> should be sorted out because it contains magic.  The interface
> provided by leaf is pretty, but it has a puzzling internal
> structure.  I would support a third use-package that should come
> standard with Emacs, if there is one.  And some people said that
> the name "LEAF" is a bad name.  Hopefully the third use-package
> will have a better name.

I am not sure if there is any interest, but my `setup' package[0] might
be such a candidate, when combined with a "declarative to imperative"
translation layer.  I was playing with such a concept a few months
ago[1], but never completed it.  This specific implementation might be
too "cl-generic"-heavy.  But in principle it works:

We start with a declarative expression:

        (use-setup foo
          :init
          (first we have)
          (to eval this)
          :config
          (do this)
          (then that)
          :hook (bar-mode)
          :bind ("C-f" . foo-forward)
          :custom (foo-option t))

which is translated into a `setup'-expression:

        (setup foo
          (:option foo-option t)
          (:bind "C-f" foo-forward)
          (:hook-into bar-mode)
          (:when-loaded :when-loaded
                        (do this))
          (progn
            (to eval this)
            (first we have)))

that then expands to regular code:

        (progn
          (progn
            (custom-load-symbol 'foo-option)
            (funcall
             (or
              (get 'foo-option 'custom-set)
              (function set-default))
             'foo-option t))
          (eval-after-load 'foo
            (function
             (lambda nil
               (define-key foo-mode-map ""
                           (function foo-forward)))))
          (add-hook 'bar-mode-hook
                    (function foo-mode))
          (eval-after-load 'foo
            (function
             (lambda nil
               (do this)
               (then that))))
          (progn
            (to eval this)
            (first we have)))

[0] https://git.sr.ht/~pkal/setup
[1] https://paste.sr.ht/~pkal/4b8519fca721e0ac651d5598f6d582ae92ff84dd

> 2022年10月10日(月) 5:16 Stefan Kangas <stefankangas@gmail.com>:
>
>> Philip Kaludercic <philipk@posteo.net> writes:
>>
>> > Do you remember what thread that was, the only one I remember is
>> >
>> https://yhetil.org/emacs-devel/20201008.103747.1339582189858984269.conao3@gmail.com/
>> .
>>
>> Yes, that's the one I'm thinking of.
>>
>> I think you want to start reading at:
>>
>> https://yhetil.org/emacs-devel/CADwFkm=mSZHeKf0=G7rXhOKOqSxOYWwOQfUv8=7fZWEaDOCTKg@mail.gmail.com/
>>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]