4

In the use-package documentation https://github.com/jwiegley/use-package#diminishing-and-delighting-minor-modes there is an example that considers emacs as a package(i.e (use-package emacs))

Usually the installed packages reside in the subdirectory of '~/.emacs.d/...'. How does use-package handle the package emacs ? Is it handled as a special case ?

1 Answer 1

8

It is not packages that use-package loads but features (which are things you can require and test for with featurep). From this point of view, use-package is essentially a fancy wrapper for require.

While use-package can often seem like magic, you can demystify by placing point after a use-package stanza and doing M-x pp-macroexpand-last-sexp. In the case you reference, macro-expanding

(use-package emacs
  :delight
  (auto-fill-function " AF")
  (visual-line-mode))

yields

(if
    (not
     (require 'emacs nil t))
    (display-warning 'use-package
             (format "Cannot load %s" 'emacs)
             :error)
  (if
      (fboundp 'delight)
      (delight
       '((auto-fill-function " AF" emacs)
     (visual-line-mode nil emacs)))))

wrapped in some error-checking, messages and timing.

This is helpful: you can use the nice use-package interface to configure built-in things like dired.

4
  • 1
    So (featurep 'emacs) is true. (Who knew?) And the reason is...? I wonder.
    – Drew
    Commented Oct 18, 2020 at 1:41
  • I did not know until I tried it. No idea why... Commented Oct 18, 2020 at 9:40
  • It can be a convenience when writing code which deals with features if there's a feature which is guaranteed to always be present. Rather than dealing with special-cases, you can just supply the emacs feature. I don't know for certain if this is the reason for it existing, but I think it's a good thing that it does.
    – phils
    Commented Oct 18, 2020 at 9:49
  • 5
    I asked on [email protected], and @stefan replied saying "emacs was added as a feature as a consequence of xemacs being a feature."
    – Drew
    Commented Oct 18, 2020 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.