You can override package deferral with the :demand keyword. Thus, even if you use :bind , using :demand will force loading to occur immediately and not establish an autoload for the bound key. When a package is loaded, and if you have use-package-verbose set to t , or if the package takes longer than 0. The same will happen for configuration, or :config blocks that take longer than 0.
In general, you should keep :init forms as simple and quick as possible, and put as much as you can get away with into the :config block. This way, deferred loading can help your Emacs to start as quickly as possible. Additionally, if an error occurs while initializing or configuring a package, this will not stop your Emacs from loading.
You can use the :if keyword to predicate the loading and initialization of modules. For example, I only want edit-server running for my main, graphical Emacs, not for other Emacsen I may start at the command line:. The :disabled keyword can turn off a module you're having difficulties with, or stop loading something you're not using at the present time:. When byte-compiling your. NOTE : :when is provided as an alias for :if , and :unless foo means the same thing as :if not foo.
For example, the following will also stop :ensure from happening on Mac systems:. If you need to conditionalize a use-package form so that the condition occurs before even the :preface is executed, simply use when around the use-package form itself:. Sometimes it only makes sense to configure a package after another has been loaded, because certain variables or functions are not in scope until that time.
This can achieved using an :after keyword that allows a fairly rich description of the exact conditions when loading should occur. Here is an example:. In this case, because all of these packages are demand-loaded in the order they occur, the use of :after is not strictly necessary. By using it, however, the above code becomes order-independent, without an implicit depedence on the nature of your init file. By default, :after foo bar is the same as :after :all foo bar , meaning that loading of the given package will not happen until both foo and bar have been loaded.
Here are some of the other possibilities:. When you nest selectors, such as :any :all foo bar :all baz quux , it means that the package will be loaded when either both foo and bar have been loaded, or both baz and quux have been loaded. NOTE : pay attention if you set use-package-always-defer to t, and also use the :after keyword, as you will need to specify how the declared package is to be loaded: e.
If you're not using one of the mechanisms that registers autoloads, such as :bind or :hook , and your package manager does not provide autoloads, it's possible that without adding :demand t to those declarations, your package will never be loaded. While the :after keyword delays loading until the dependencies are loaded, the somewhat simpler :requires keyword simply never loads the package if the dependencies are not available at the time the use-package declaration is encountered.
By "available" in this context it means that foo is available if featurep 'foo evaluates to a non-nil value. For more complex logic, such as that supported by :after , simply use :if and the appropriate Lisp expression. Another feature of use-package is that it always loads every file that it can when. This helps to silence spurious warnings about unknown variables and functions. However, there are times when this is just not enough.
For those times, use the :defines and :functions keywords to introduce dummy variable and function declarations solely for the sake of the byte-compiler:. If you need to silence a missing function warning, you can use :functions :. Normally, use-package will load each package at compile time before compiling the configuration, to ensure that any necessary symbols are in scope to satisfy the byte-compiler. At times this can cause problems, since a package may have special loading requirements, and all that you want to use use-package for is to add a configuration to the eval-after-load hook.
In such cases, use the :no-require keyword:. If your package needs a directory added to the load-path in order to load, use :load-path. This takes a symbol, a function, a string or a list of strings. If the path is relative, it is expanded within user-emacs-directory :. NOTE : when using a symbol or a function to provide a dynamically generated list of paths, you must inform the byte-compiler of this definition so the value is available at byte-compilation time.
This is done by using the special form eval-and-compile as opposed to eval-when-compile. Further, this value is fixed at whatever was determined during compilation, to avoid looking up the same information again on each startup:. By default, if use-package-expand-minimally is nil the default , use-package will attempts to catch and report errors that occur during expansion of use-package declarations in your init file. Setting use-package-expand-minimally to t completely disables this checking.
This behavior may be overridden locally using the :catch keyword. If t or nil , it enables or disables catching errors at load time. It can also be a function taking two arguments: the keyword being processed at the time the error was encountered, and the error object as generated by condition-case. Their purpose is to remove or change minor mode strings in your mode-line. If no arguments are provided, the default mode name is hidden completely.
You can use use-package to load packages from ELPA with package. This is particularly useful if you share your. The :ensure keyword causes the package s to be installed automatically if not already present on your system:. If you need to install a different package from the one named by use-package , you can specify it like this:.
Enable use-package-always-ensure if you wish this behavior to be global for all packages:. NOTE : :ensure will install a package if it is not already installed, but it does not keep it up-to-date. If you want to keep your packages updated automatically, one option is to use auto-package-update , like.
Lastly, when running on Emacs The primary use-case for this is preferring packages from the melpa-stable and gnu archives, but using specific packages from melpa when you need to track newer versions than what is available in the stable archives is also a valid use-case.
By default package. If this really annoys you, then you can set use-package-always-pin to set a default. If you want to manually keep a package updated and ignore upstream updates, you can pin it to manual , which as long as there is no repository by that name, will Just Work tm. At the present time, the only package manager that does this is straight.
If you'd like to see how many packages you've loaded, what stage of initialization they've reached, and how much aggregate time they've spent roughly , you can enable use-package-compute-statistics after loading use-package but before any use-package forms, and then run the command M-x use-package-report to see the results.
The buffer displayed is a tabulated list. You can use S in a column to sort the rows based on it. Starting with version 2. Some keyword extensions are now included in the use-package distribution and can be optionally installed. The :ensure-system-package keyword allows you to ensure system binaries exist alongside your package declarations.
First, you will want to make sure exec-path is cognisant of all binary package names that you would like to ensure are installed. This is not only true for choosing what packages you want to install, but also what features a certain package should support. If you don't want to use KDE, why would you bother compiling packages with KDE support if those packages work flawlessly without? This forces the user into deciding what they really want and eases the process for the package management system, Portage.
Enter the USE flags. USE flag is a keyword that embodies support and dependency-information for a certain concept. If you define a certain USE flag, Portage will know that you want support for the chosen keyword. Of course this also alters the dependency information for a package. Let us take a look at a specific example: the kde keyword. All packages that have an optional KDE dependency will be installed without installing the KDE libraries as dependency.
If you have defined the kde keyword, then those packages will be compiled with KDE support, and the KDE libraries will be installed as dependency. By correctly defining the keywords you will receive a system tailored specifically to your needs. Each Calculate Linux distro has its collection of USE flags which have been optimized for particular tasks. Each profile works on top of another, larger profile, the end result is therefore the sum of all profiles. To change this default setting, you need to add or remove keywords in the USE variable.
This latter is done by prefixing the keyword with the minus-sign «-». Calculate Linux distros use a binary profile by default, which ignores any modifications you make to USE flags. For these modifications to take effect, use the -N or --newuse argument when emerging or updating packages.
Here is an example:. Sometimes you want to declare a certain USE flag for one or a couple of applications but not system-wide. You can choose any name you like for this file. Email Required, but never shown. The Overflow Blog.
Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta. Now live: A fully responsive profile. Related 9. Hot Network Questions. Question feed.
Accept all cookies Customize settings.
0コメント