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 ?

Talespin_Kit
  • 445
  • 2
  • 11

1 Answers1

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.

Fran Burstall
  • 3,855
  • 11
  • 18
  • 1
    So (featurep 'emacs) is true. (Who knew?) And the reason is...? I wonder. – Drew Oct 18 '20 at 01:41
  • I did not know until I tried it. No idea why... – Fran Burstall Oct 18 '20 at 09: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 Oct 18 '20 at 09: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 Oct 18 '20 at 15:21