Giter Site home page Giter Site logo

jwiegley / use-package Goto Github PK

View Code? Open in Web Editor NEW
4.4K 93.0 261.0 2.14 MB

A use-package declaration for simplifying your .emacs

Home Page: https://jwiegley.github.io/use-package

License: GNU General Public License v3.0

Emacs Lisp 93.97% Makefile 6.03%
emacs-lisp deferred-loading emacs keymap autoload handler melpa keyword

use-package's Introduction

use-package

Join the chat at https://gitter.im/use-package/Lobby Build Status GNU ELPA

The use-package macro allows you to isolate package configuration in your .emacs file in a way that is both performance-oriented and, well, tidy. I created it because I have over 80 packages that I use in Emacs, and things were getting difficult to manage. Yet with this utility my total load time is around 2 seconds, with no loss of functionality!

NOTE: use-package is not a package manager! Although use-package does have the useful capability to interface with package managers (see below), its primary purpose is for the configuration and loading of packages.

Installing use-package

Either clone from this GitHub repository or install from GNU ELPA (recommended).

Getting started

Here is the simplest use-package declaration:

;; This is only needed once, near the top of the file
(eval-when-compile
  ;; Following line is not needed if use-package.el is in ~/.emacs.d
  (add-to-list 'load-path "<path where use-package is installed>")
  (require 'use-package))

(use-package foo)

This loads in the package foo, but only if foo is available on your system. If not, a warning is logged to the *Messages* buffer.

Use the :init keyword to execute code before a package is loaded. It accepts one or more forms, up to the next keyword:

(use-package foo
  :init
  (setq foo-variable t))

Similarly, :config can be used to execute code after a package is loaded. In cases where loading is done lazily (see more about autoloading below), this execution is deferred until after the autoload occurs:

(use-package foo
  :init
  (setq foo-variable t)
  :config
  (foo-mode 1))

As you might expect, you can use :init and :config together:

(use-package color-moccur
  :commands (isearch-moccur isearch-all)
  :bind (("M-s O" . moccur)
         :map isearch-mode-map
         ("M-o" . isearch-moccur)
         ("M-O" . isearch-moccur-all))
  :init
  (setq isearch-lazy-highlight t)
  :config
  (use-package moccur-edit))

In this case, I want to autoload the commands isearch-moccur and isearch-all from color-moccur.el, and bind keys both at the global level and within the isearch-mode-map (see next section). When the package is actually loaded (by using one of these commands), moccur-edit is also loaded, to allow editing of the moccur buffer.

If you autoload non-interactive function, please use :autoload.

(use-package org-crypt
  :autoload org-crypt-use-before-save-magic)

Key-binding

Another common thing to do when loading a module is to bind a key to primary commands within that module:

(use-package ace-jump-mode
  :bind ("C-." . ace-jump-mode))

This does two things: first, it creates an autoload for the ace-jump-mode command and defers loading of ace-jump-mode until you actually use it. Second, it binds the key C-. to that command. After loading, you can use M-x describe-personal-keybindings to see all such keybindings you've set throughout your .emacs file.

A more literal way to do the exact same thing is:

(use-package ace-jump-mode
  :commands ace-jump-mode
  :init
  (bind-key "C-." 'ace-jump-mode))

When you use the :commands keyword, it creates autoloads for those commands and defers loading of the module until they are used. Since the :init form is always run -- even if ace-jump-mode might not be on your system -- remember to restrict :init code to only what would succeed either way.

The :bind keyword takes either a cons or a list of conses:

(use-package hi-lock
  :bind (("M-o l" . highlight-lines-matching-regexp)
         ("M-o r" . highlight-regexp)
         ("M-o w" . highlight-phrase)))

Alternatively, the command name may be replaced with a cons (desc . command), where desc is a string describing command, which is the name of a command to bind to:

(use-package avy
  :bind ("C-:" ("Jump to char" . avy-goto-char)
         "M-g f" ("Jump to line" . avy-goto-line)))

These descriptions can be used by other code that deals with key bindings. For example, the GNU ELPA package which-key displays them when showing key bindings, instead of the plain command names.

The :commands keyword takes either a symbol or a list of symbols.

NOTE: inside strings, special keys like tab or F1-Fn have to be written inside angle brackets, e.g. "C-<up>". Standalone special keys (and some combinations) can be written in square brackets, e.g. [tab] instead of "<tab>". The syntax for the keybindings is similar to the "kbd" syntax: see https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Rebinding.html for more information.

Examples:

(use-package helm
  :bind (("M-x" . helm-M-x)
         ("M-<f5>" . helm-find-files)
         ([f10] . helm-buffers-list)
         ([S-f10] . helm-recentf)))

Furthermore, remapping commands with :bind and bind-key works as expected, because when the binding is a vector, it is passed straight to define-key. So the following example will rebind M-q (originally fill-paragraph) to unfill-toggle:

(use-package unfill
  :bind ([remap fill-paragraph] . unfill-toggle))

Binding to keymaps

Normally :bind expects that commands are functions that will be autoloaded from the given package. However, this does not work if one of those commands is actually a keymap, since keymaps are not functions, and cannot be autoloaded using Emacs' autoload mechanism.

To handle this case, use-package offers a special, limited variant of :bind called :bind-keymap. The only difference is that the "commands" bound to by :bind-keymap must be keymaps defined in the package, rather than command functions. This is handled behind the scenes by generating custom code that loads the package containing the keymap, and then re-executes your keypress after the first load, to reinterpret that keypress as a prefix key.

For example:

(use-package projectile
  :bind-keymap
  ("C-c p" . projectile-command-map))

Binding within local keymaps

Slightly different from binding a key to a keymap, is binding a key within a local keymap that only exists after the package is loaded. use-package supports this with a :map modifier, taking the local keymap to bind to:

(use-package helm
  :bind (:map helm-command-map
         ("C-c h" . helm-execute-persistent-action)))

The effect of this statement is to wait until helm has loaded, and then to bind the key C-c h to helm-execute-persistent-action within Helm's local keymap, helm-command-map.

Multiple uses of :map may be specified. Any binding occurring before the first use of :map are applied to the global keymap:

(use-package term
  :bind (("C-c t" . term)
         :map term-mode-map
         ("M-p" . term-send-up)
         ("M-n" . term-send-down)
         :map term-raw-map
         ("M-o" . other-window)
         ("M-p" . term-send-up)
         ("M-n" . term-send-down)))

Binding to repeat-maps

A special case of binding within a local keymap is when that keymap is used by repeat-mode. These keymaps are usually defined specifically for this. Using the :repeat-map keyword, and passing it a name for the map it defines, will bind all following keys inside that map, and (by default) set the repeat-map property of each bound command to that map.

This creates a keymap called git-gutter+-repeat-map, makes four bindings in it as above, then sets the repeat-map property of each bound command (git-gutter+-next-hunk git-gutter+-previous-hunk, git-gutter+-stage-hunks and git-gutter+-revert-hunk) to that keymap.

(use-package git-gutter+
  :bind
  (:repeat-map git-gutter+-repeat-map
   ("n" . git-gutter+-next-hunk)
   ("p" . git-gutter+-previous-hunk)
   ("s" . git-gutter+-stage-hunks)
   ("r" . git-gutter+-revert-hunk)))

Specifying :exit inside the scope of :repeat-map will prevent the repeat-map property being set, so that the command can be used from within the repeat map, but after it using it the repeat map will no longer be available. This is useful for commands often used at the end of a series of repeated commands:

(use-package git-gutter+
  :bind
  (:repeat-map my/git-gutter+-repeat-map
   ("n" . git-gutter+-next-hunk)
   ("p" . git-gutter+-previous-hunk)
   ("s" . git-gutter+-stage-hunks)
   ("r" . git-gutter+-revert-hunk)
   :exit
   ("c" . magit-commit-create)
   ("C" . magit-commit)
   ("b" . magit-blame)))

Specifying :continue forces setting the repeat-map property (just like not specifying :exit), so these two snippets are equivalent:

(use-package git-gutter+
  :bind
  (:repeat-map my/git-gutter+-repeat-map
   ("n" . git-gutter+-next-hunk)
   ("p" . git-gutter+-previous-hunk)
   ("s" . git-gutter+-stage-hunks)
   ("r" . git-gutter+-revert-hunk)
   :exit
   ("c" . magit-commit-create)
   ("C" . magit-commit)
   ("b" . magit-blame)))
(use-package git-gutter+
  :bind
  (:repeat-map my/git-gutter+-repeat-map
   :exit
   ("c" . magit-commit-create)
   ("C" . magit-commit)
   ("b" . magit-blame)
   :continue
   ("n" . git-gutter+-next-hunk)
   ("p" . git-gutter+-previous-hunk)
   ("s" . git-gutter+-stage-hunks)
   ("r" . git-gutter+-revert-hunk)))

Modes and interpreters

Similar to :bind, you can use :mode and :interpreter to establish a deferred binding within the auto-mode-alist and interpreter-mode-alist variables. The specifier to either keyword can be a cons cell, a list of cons cells, or a string or regexp:

(use-package ruby-mode
  :mode "\\.rb\\'"
  :interpreter "ruby")

;; The package is "python" but the mode is "python-mode":
(use-package python
  :mode ("\\.py\\'" . python-mode)
  :interpreter ("python" . python-mode))

If you aren't using :commands, :bind, :bind*, :bind-keymap, :bind-keymap*, :mode, :interpreter, or :hook (all of which imply :defer; see the docstring for use-package for a brief description of each), you can still defer loading with the :defer keyword:

(use-package ace-jump-mode
  :defer t
  :init
  (autoload 'ace-jump-mode "ace-jump-mode" nil t)
  (bind-key "C-." 'ace-jump-mode))

This does exactly the same thing as the following:

(use-package ace-jump-mode
  :bind ("C-." . ace-jump-mode))

Magic handlers

Similar to :mode and :interpreter, you can also use :magic and :magic-fallback to cause certain function to be run if the beginning of a file matches a given regular expression. The difference between the two is that :magic-fallback has a lower priority than :mode. For example:

(use-package pdf-tools
  :load-path "site-lisp/pdf-tools/lisp"
  :magic ("%PDF" . pdf-view-mode)
  :config
  (pdf-tools-install :no-query))

This registers an autoloaded command for pdf-view-mode, defers loading of pdf-tools, and runs pdf-view-mode if the beginning of a buffer matches the string "%PDF".

Hooks

The :hook keyword allows adding functions onto package hooks. The following are equivalent:

(use-package company
  :hook (prog-mode . company-mode))

(use-package company
  :commands company-mode
  :init
  (add-hook 'prog-mode-hook #'company-mode))

And likewise, when multiple hooks should be applied, all of the following are also equivalent:

(use-package company
  :hook ((prog-mode text-mode) . company-mode))

(use-package company
  :hook ((prog-mode . company-mode)
         (text-mode . company-mode)))

(use-package company
  :hook (prog-mode . company-mode)
  :hook (text-mode . company-mode))

(use-package company
  :hook
  (prog-mode . company-mode)
  (text-mode . company-mode))

(use-package company
  :commands company-mode
  :init
  (add-hook 'prog-mode-hook #'company-mode)
  (add-hook 'text-mode-hook #'company-mode))

When using :hook, omit the "-hook" suffix if you specify the hook explicitly, as this is appended by default. For example, the following code will not work as it attempts to add to the prog-mode-hook-hook which does not exist:

;; DOES NOT WORK
(use-package ace-jump-mode
  :hook (prog-mode-hook . ace-jump-mode))

If you do not like this behaviour, set use-package-hook-name-suffix to nil. By default the value of this variable is "-hook".

The use of :hook, as with :bind, :mode, :interpreter, etc., causes the functions being hooked to implicitly be read as :commands (meaning they will establish interactive autoload definitions for that module, if not already defined as functions), and so :defer t is also implied by :hook.

Package customization

Customizing variables.

The :custom keyword allows customization of package custom variables.

(use-package comint
  :custom
  (comint-buffer-maximum-size 20000 "Increase comint buffer size.")
  (comint-prompt-read-only t "Make the prompt read only."))

The documentation string is not mandatory.

NOTE: these are only for people who wish to keep customizations with their accompanying use-package declarations. Functionally, the only benefit over using setq in a :config block is that customizations might execute code when values are assigned.

NOTE: The customized values are not saved in the Emacs custom-file. Thus you should either use the :custom option or you should use M-x customize-option which will save customized values in the Emacs custom-file. Do not use both.

Customizing faces

The :custom-face keyword allows customization of package custom faces.

(use-package eruby-mode
  :custom-face
  (eruby-standard-face ((t (:slant italic)))))

(use-package example
  :custom-face
  (example-1-face ((t (:foreground "LightPink"))))
  (example-2-face ((t (:foreground "LightGreen"))) face-defspec-spec))

(use-package zenburn-theme
  :preface
  (setq my/zenburn-colors-alist
        '((fg . "#DCDCCC") (bg . "#1C1C1C") (cyan . "#93E0E3")))
  :custom-face
  (region ((t (:background ,(alist-get my/zenburn-colors-alist 'cyan)))))
  :config
  (load-theme 'zenburn t))

Notes about lazy loading

The keywords :commands, et al, provide "triggers" that cause a package to be loaded when certain events occur. However, if use-package cannot determine that any trigger has been declared, it will load the package immediately (when Emacs is starting up) unless :defer t is given. The presence of triggers can be overridden using :demand t to force immediately loading anyway. For example, :hook represents a trigger that fires when the specified hook is run.

In almost all cases you don't need to manually specify :defer t, because this is implied whenever :bind or :mode or :interpreter are used. Typically, you only need to specify :defer if you know for a fact that some other package will do something to cause your package to load at the appropriate time, and thus you would like to defer loading even though use-package has not created any autoloads for you.

You can override package deferral with the :demand keyword. Thus, even if you use :bind, adding :demand will force loading to occur immediately and not establish an autoload for the bound key.

Information about package loads

When a package is loaded, and if you have use-package-verbose set to t, or if the package takes longer than 0.1s to load, you will see a message to indicate this loading activity in the *Messages* buffer. The same will happen for configuration, or :config blocks that take longer than 0.1s to execute. 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. Rather, the error will be captured by use-package, and reported to a special *Warnings* popup buffer, so that you can debug the situation in an otherwise functional Emacs.

Conditional 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:

(use-package edit-server
  :if window-system
  :init
  (add-hook 'after-init-hook 'server-start t)
  (add-hook 'after-init-hook 'edit-server-start t))

In another example, we can load things conditional on the operating system:

(use-package exec-path-from-shell
  :if (memq window-system '(mac ns))
  :ensure t
  :config
  (exec-path-from-shell-initialize))

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:

(use-package ess-site
  :disabled
  :commands R)

When byte-compiling your .emacs file, disabled declarations are omitted from the output entirely, to accelerate startup times.

NOTE: :when is provided as an alias for :if, and :unless foo means the same thing as :if (not foo).

Conditional loading before :preface

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. For example, the following will also stop :ensure from happening on Mac systems:

(when (memq window-system '(mac ns))
  (use-package exec-path-from-shell
    :ensure t
    :config
    (exec-path-from-shell-initialize)))

Loading packages in sequence

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:

(use-package hydra
  :load-path "site-lisp/hydra")

(use-package ivy
  :load-path "site-lisp/swiper")

(use-package ivy-hydra
  :after (ivy hydra))

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:

:after (foo bar)
:after (:all foo bar)
:after (:any foo bar)
:after (:all (:any foo bar) (:any baz quux))
:after (:any (:all foo bar) (:all baz quux))

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.g., by some :bind. 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.

Prevent loading if dependencies are missing

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 example:

(use-package abbrev
  :requires foo)

This is the same as:

(use-package abbrev
  :if (featurep 'foo))

As a convenience, a list of such packages may be specified:

(use-package abbrev
  :requires (foo bar baz))

For more complex logic, such as that supported by :after, simply use :if and the appropriate Lisp expression.

Byte-compiling your .emacs

Another feature of use-package is that it always loads every file that it can when .emacs is being byte-compiled. 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:

(use-package texinfo
  :defines texinfo-section-list
  :commands texinfo-mode
  :init
  (add-to-list 'auto-mode-alist '("\\.texi$" . texinfo-mode)))

If you need to silence a missing function warning, you can use :functions:

(use-package ruby-mode
  :mode "\\.rb\\'"
  :interpreter "ruby"
  :functions inf-ruby-keys
  :config
  (defun my-ruby-mode-hook ()
    (require 'inf-ruby)
    (inf-ruby-keys))

  (add-hook 'ruby-mode-hook 'my-ruby-mode-hook))

Prevent a package from loading at compile-time

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:

(use-package foo
  :no-require t
  :config
  (message "This is evaluated when `foo' is loaded"))

Extending the load-path

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:

(use-package ess-site
  :load-path "site-lisp/ess/lisp/"
  :commands R)

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:

(eval-and-compile
  (defun ess-site-load-path ()
    (shell-command "find ~ -path ess/lisp")))

(use-package ess-site
  :load-path (lambda () (list (ess-site-load-path)))
  :commands R)

Catching errors during use-package expansion

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). For example:

(use-package example
  ;; Note that errors are never trapped in the preface, since doing so would
  ;; hide definitions from the byte-compiler.
  :preface (message "I'm here at byte-compile and load time.")
  :init (message "I'm always here at startup")
  :config
  (message "I'm always here after the package is loaded")
  (error "oops")
  ;; Don't try to (require 'example), this is just an example!
  :no-require t
  :catch (lambda (keyword err)
           (message (error-message-string err))))

Evaluating the above form will print these messages:

I’m here at byte-compile and load time.
I’m always here at startup
Configuring package example...
I’m always here after the package is loaded
oops

Diminishing and delighting minor modes

use-package also provides built-in support for the diminish and delight utilities -- if you have them installed. Their purpose is to remove or change minor mode strings in your mode-line.

diminish is invoked with the :diminish keyword, which is passed either a minor mode symbol, a cons of the symbol and its replacement string, or just a replacement string, in which case the minor mode symbol is guessed to be the package name with "-mode" appended at the end:

(use-package abbrev
  :diminish abbrev-mode
  :config
  (if (file-exists-p abbrev-file-name)
      (quietly-read-abbrev-file)))

delight is invoked with the :delight keyword, which is passed a minor mode symbol, a replacement string or quoted mode-line data (in which case the minor mode symbol is guessed to be the package name with "-mode" appended at the end), both of these, or several lists of both. If no arguments are provided, the default mode name is hidden completely.

;; Don't show anything for rainbow-mode.
(use-package rainbow-mode
  :delight)

;; Don't show anything for auto-revert-mode, which doesn't match
;; its package name.
(use-package autorevert
  :delight auto-revert-mode)

;; Remove the mode name for projectile-mode, but show the project name.
(use-package projectile
  :delight '(:eval (concat " " (projectile-project-name))))

;; Completely hide visual-line-mode and change auto-fill-mode to " AF".
(use-package emacs
  :delight
  (auto-fill-function " AF")
  (visual-line-mode))

Package installation

You can use use-package to load packages from ELPA with package.el. This is particularly useful if you share your .emacs among several machines; the relevant packages are downloaded automatically once declared in your .emacs. The :ensure keyword causes the package(s) to be installed automatically if not already present on your system:

(use-package magit
  :ensure t)

If you need to install a different package from the one named by use-package, you can specify it like this:

(use-package tex
  :ensure auctex)

Enable use-package-always-ensure if you wish this behavior to be global for all packages:

(require 'use-package-ensure)
(setq use-package-always-ensure t)

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

(use-package auto-package-update
  :config
  (setq auto-package-update-delete-old-versions t)
  (setq auto-package-update-hide-results t)
  (auto-package-update-maybe))

Lastly, when running on Emacs 24.4 or later, use-package can pin a package to a specific archive, allowing you to mix and match packages from different archives. The primary use-case for this is preferring packages from the gnu and melpa-stable 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.el prefers melpa over melpa-stable due to the versioning (> evil-20141208.623 evil-1.0.9), so even if you are tracking only a single package from melpa, you will need to tag all the non-melpa packages with the appropriate archive. 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).

use-package throws an error if you try to pin a package to an archive that has not been configured using package-archives (apart from the magic manual archive mentioned above):

Archive 'foo' requested for package 'bar' is not available.

Example:

(use-package company
  :ensure t
  :pin gnu)

(use-package evil
  :ensure t)
  ;; no :pin needed, as package.el will choose the version in melpa

(use-package adaptive-wrap
  :ensure t
  ;; as this package is available only in the gnu archive, this is
  ;; technically not needed, but it helps to highlight where it
  ;; comes from
  :pin gnu)

(use-package org
  :ensure t
  ;; ignore org-mode from upstream and use a manually installed version
  :pin manual)

NOTE: the :pin argument has no effect on emacs versions < 24.4.

Usage with other package managers

By overriding use-package-ensure-function and/or use-package-pre-ensure-function, other package managers can override :ensure to use them instead of package.el. At the present time, the only package manager that does this is straight.el.

Gathering Statistics

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.

Keyword Extensions

Starting with version 2.0, use-package is based on an extensible framework that makes it easy for package authors to add new keywords, or modify the behavior of existing keywords.

Some keyword extensions are now included in the use-package distribution and can be optionally installed.

(use-package-ensure-system-package)

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. exec-path-from-shell is often a good way to do this.

To enable the extension after you've loaded use-package:

(use-package use-package-ensure-system-package
  :ensure t)

Here’s an example of usage:

(use-package rg
  :ensure-system-package rg)

This will expect a global binary package to exist called rg. If it does not, it will use your system package manager (using the package system-packages) to attempt an install of a binary by the same name asynchronously. For example, for most macOS users this would call: brew install rg.

If the package is named differently than the binary, you can use a cons in the form of (binary . package-name), i.e.:

(use-package rg
  :ensure-system-package
  (rg . ripgrep))

In the previous macOS example, this would call: brew install ripgrep if rg was not found.

What if you want to customize the install command further?

(use-package tern
  :ensure-system-package (tern . "npm i -g tern"))

:ensure-system-package can also take a cons where its cdr is a string that will get called by (async-shell-command) to install if it isn’t found.

You may also pass in a list of cons-es:

(use-package ruby-mode
  :ensure-system-package
  ((rubocop     . "gem install rubocop")
   (ruby-lint   . "gem install ruby-lint")
   (ripper-tags . "gem install ripper-tags")
   (pry         . "gem install pry")))

Finally, in case the package dependency does not provide a global executable, you can ensure packages exist by checking the presence of a file path by providing a string like so:

(use-package dash-at-point
  :if (eq system-type 'darwin)
  :ensure-system-package
  ("/Applications/Dash.app" . "brew cask install dash"))

:ensure-system-package will use system-packages-install to install system packages, except where a custom command has been specified, in which case it will be executed verbatim by async-shell-command.

Configuration variables system-packages-package-manager and system-packages-use-sudo will be honoured, but not for custom commands. Custom commands should include the call to sudo in the command if needed.

(use-package-chords)

The :chords keyword allows you to define key-chord bindings for use-package declarations in the same manner as the :bind keyword.

To enable the extension:

(use-package use-package-chords
  :ensure t
  :config (key-chord-mode 1))

Then you can define your chord bindings in the same manner as :bind using a cons or a list of conses:

(use-package ace-jump-mode
  :chords (("jj" . ace-jump-char-mode)
           ("jk" . ace-jump-word-mode)
           ("jl" . ace-jump-line-mode)))

How to create an extension

First step: Add the keyword

The first step is to add your keyword at the right place in use-package-keywords. This list determines the order in which things will happen in the expanded code. You should never change this order, but it gives you a framework within which to decide when your keyword should fire.

Second step: Create a normalizer

Define a normalizer for your keyword by defining a function named after the keyword, for example:

(defun use-package-normalize/:pin (name-symbol keyword args)
  (use-package-only-one (symbol-name keyword) args
    (lambda (label arg)
      (cond
       ((stringp arg) arg)
       ((symbolp arg) (symbol-name arg))
       (t
        (use-package-error
         ":pin wants an archive name (a string)"))))))

The job of the normalizer is take a list of arguments (possibly nil), and turn it into the single argument (which could still be a list) that should appear in the final property list used by use-package.

Third step: Create a handler

Once you have a normalizer, you must create a handler for the keyword:

(defun use-package-handler/:pin (name-symbol keyword archive-name rest state)
  (let ((body (use-package-process-keywords name-symbol rest state)))
    ;; This happens at macro expansion time, not when the expanded code is
    ;; compiled or evaluated.
    (if (null archive-name)
        body
      (use-package-pin-package name-symbol archive-name)
      (use-package-concat
       body
       `((push '(,name-symbol . ,archive-name)
               package-pinned-packages))))))

Handlers can affect the handling of keywords in two ways. First, it can modify the state plist before recursively processing the remaining keywords, to influence keywords that pay attention to the state (one example is the state keyword :deferred, not to be confused with the use-package keyword :defer). Then, once the remaining keywords have been handled and their resulting forms returned, the handler may manipulate, extend, or just ignore those forms.

The task of each handler is to return a list of forms representing code to be inserted. It does not need to be a progn list, as this is handled automatically in other places. Thus it is very common to see the idiom of using use-package-concat to add new functionality before or after a code body, so that only the minimum code necessary is emitted as the result of a use-package expansion.

Fourth step: Test it out

After the keyword has been inserted into use-package-keywords, and a normalizer and a handler defined, you can now test it by seeing how usages of the keyword will expand. For this, use M-x pp-macroexpand-last-sexp with the cursor set immediately after the (use-package ...) expression.

Some timing results

On my Retina iMac, the "Mac port" variant of Emacs 24.4 loads in 0.57s, with around 218 packages configured (nearly all of them lazy-loaded). However, I experience no loss of functionality, just a bit of latency when I'm first starting to use Emacs (due to the autoloading). Since I also use idle-loading for many packages, perceived latency is typically reduced overall.

On Linux, the same configuration loads in 0.32s.

If I don't use Emacs graphically, I can test the absolute minimum times. This is done by running:

time emacs -l init.elc -batch --eval '(message "Hello, world!")'

On the Mac I see an average of 0.36s for the same configuration, and on Linux 0.26s.

Upgrading to 2.x

Semantics of :init is now consistent

The meaning of :init has been changed: It now always happens before package load, whether :config has been deferred or not. This means that some uses of :init in your configuration may need to be changed to :config (in the non-deferred case). For the deferred case, the behavior is unchanged from before.

Also, because :init and :config now mean "before" and "after", the :pre- and :post- keywords are gone, as they should no longer be necessary.

Lastly, an effort has been made to make your Emacs start even in the presence of use-package configuration failures. So after this change, be sure to check your *Messages* buffer. Most likely, you will have several instances where you are using :init, but should be using :config (this was the case for me in a number of places).

:idle has been removed

I am removing this feature for now because it can result in a nasty inconsistency. Consider the following definition:

(use-package vkill
  :commands vkill
  :idle (some-important-configuration-here)
  :bind ("C-x L" . vkill-and-helm-occur)
  :init
  (defun vkill-and-helm-occur ()
    (interactive)
    (vkill)
    (call-interactively #'helm-occur))

  :config
  (setq vkill-show-all-processes t))

If I load my Emacs and wait until the idle timer fires, then this is the sequence of events:

:init :idle <load> :config

But if I load Emacs and immediately type C-x L without waiting for the idle timer to fire, this is the sequence of events:

:init <load> :config :idle

It's possible that the user could use featurep in their idle to test for this case, but that's a subtlety I'd rather avoid.

:defer now accepts an optional numeric argument

:defer [N] causes the package to be loaded -- if it has not already been -- after N seconds of idle time.

(use-package back-button
  :commands (back-button-mode)
  :defer 2
  :init
  (setq back-button-show-toolbar-buttons nil)
  :config
  (back-button-mode 1))

Add :preface, occurring before everything except :disabled

:preface can be used to establish function and variable definitions that will 1) make the byte-compiler happy (it won't complain about functions whose definitions are unknown because you have them within a guard block), and 2) allow you to define code that can be used in an :if test.

NOTE: whatever is specified within :preface is evaluated both at load time and at byte-compilation time, in order to ensure that definitions are seen by both the Lisp evaluator and the byte-compiler, so you should avoid having any side-effects in your preface, and restrict it merely to symbol declarations and definitions.

Add :functions, for declaring functions to the byte-compiler

What :defines does for variables, :functions does for functions.

use-package.el is no longer needed at runtime

This means you should put the following at the top of your Emacs, to further reduce load time:

(eval-when-compile
  (require 'use-package))
(require 'diminish)                ;; if you use :diminish
(require 'bind-key)                ;; if you use any :bind variant

use-package's People

Contributors

aethanyc avatar aspiers avatar bhankas avatar conao3 avatar damiencassou avatar dudebout avatar fuco1 avatar hugo-heagren avatar jabranham avatar joewreschnig avatar justbur avatar jwiegley avatar kaushalmodi avatar killdash9 avatar kovrik avatar nickmccurdy avatar npostavs avatar philhudson avatar phillord-ncl avatar phst avatar raxod502 avatar rememberyou avatar silex avatar skangas avatar tarsius avatar thomasf avatar tzz avatar waymondo avatar wyuenho avatar youngfrog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

use-package's Issues

Symbol's function definition is void: ert-set-test

Getting this error when doing (require 'use-package):

Symbol's function definition is void: ert-set-test

Emacs version: "GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu) of 2014-01-01 on gkar, modified by Debian"

'Backward compatibility with emacs-22.1 commit' error. fboundp is a funtion not a var.

Please consider change from:

(when fboundp 'declare-function
  (declare-function package-installed-p 'package))

to:

(when (fboundp 'declare-function)
  (declare-function package-installed-p 'package))

Latest working commit:
commit 28bf5fd
Author: John Wiegley [email protected]
Date: Mon Dec 2 03:06:27 2013 -0700

Default use-package-verbose to nil

But for merge: 28bf5fd 768d735 I get:

Debugger entered--Lisp error: (void-variable fboundp)
  (if fboundp (progn (quote declare-function) nil))
  eval-buffer(#<buffer  *load*-16109> nil "/home/kmicu/.live-packs/kmicu-pack/lib/use-package/use-package.el" nil t)  ; Reading at buffer position 10796
  load-with-code-conversion("/home/kmicu/.live-packs/kmicu-pack/lib/use-package/use-package.el" "/home/kmicu/.live-packs/kmicu-pack/lib/use-package/use-package.el" nil t)
  require(use-package)
  eval-buffer(#<buffer  *load*> nil "/home/kmicu/.live-packs/kmicu-pack/init.el" nil t)  ; Reading at buffer position 2063
  load-with-code-conversion("/home/kmicu/.live-packs/kmicu-pack/init.el" "/home/kmicu/.live-packs/kmicu-pack/init.el" nil nil)
  load("/home/kmicu/.live-packs/kmicu-pack/init.el" nil nil t)
  load-file("~/.live-packs/kmicu-pack/init.el")
  (if (file-exists-p pack-init) (load-file pack-init))
  (let* ((pack-info (concat pack-dir "info.el")) (pack-init (concat pack-dir "init.el"))) (setq live-current-pack-dir pack-dir) (message (concat "Live pack lib dir: " (live-pack-lib-dir))) (live-clear-pack-info) (if (file-exists-p pack-info) (load-file pack-info) (message (concat "Could not find info.el file for pack with location: " pack-dir))) (live-check-pack-info) (add-to-list (quote load-path) (live-pack-lib-dir)) (if (file-exists-p pack-init) (load-file pack-init)) (setq live-current-pack-dir nil))
  live-load-pack("~/.live-packs/kmicu-pack/")
  (lambda (pack-dir) (live-load-pack pack-dir))("~/.live-packs/kmicu-pack/")
  mapcar((lambda (pack-dir) (live-load-pack pack-dir)) ("~/.live-packs/kmicu-pack/"))
  (lambda nil (let* ((pack-file (concat (file-name-as-directory "~") ".emacs-live.el"))) (if (and (file-exists-p pack-file) (not live-safe-modep)) (load-file pack-file))) (mapcar (function (lambda (pack-dir) (live-load-pack pack-dir))) (live-pack-dirs)) (if (not custom-file) (setq custom-file (concat live-custom-dir "custom-configuration.el"))) (if (file-exists-p custom-file) (progn (load custom-file))))()
  run-hooks(after-init-hook)
  command-line()
  normal-top-level()

Byte compilation of deferred `:config` forms

This is more of a question than a bug report. I noticed that the byte compiler does not warn about free variables in :config blocks of deferred packages:

(use-package smex
  :bind (("M-x" . smex)
         ("M-X" . smex-major-mode-commands))
  :config
  (setq smex-save-file (locate-user-emacs-file ".smex-items")))

I'd expect too warnings here, one fore the reference to a free variable and another for the assignment to a free variable:

init.el:219:24:Warning: reference to free variable `hello-world'
init.el:219:9:Warning: assignment to free variable `spam-with-eggs'

However, I get no warnings. I assume, :config blocks of deferred packages are not byte-compiled then, are they?

I find that somewhat unfortunate. To me, the main point in compiling my init file is to catch spelling mistakes and the like. Not compiling deferred :config blocks sort of defeats the whole purpose of byte compilation, as most of my customization code is now in such blocks.

Binding to help-command

How can I bind a key say "A" to the command 'apropos in the help-command key map? I tried

(bind-key "A" 'apropos 'help-command)

which seems to work but fails when I call describe-personal-keybindings. Any advice?

Here is the trace after calling describe-personal-keybindings:

Debugger entered--Lisp error: (wrong-type-argument symbolp (quote help-command))
  symbol-name((quote help-command))
  (string= (symbol-name lkeymap) (symbol-name rkeymap))
  (not (string= (symbol-name lkeymap) (symbol-name rkeymap)))
  (and lkeymap rkeymap (not (string= (symbol-name lkeymap) (symbol-name rkeymap))))
  (cond ((and (null lkeymap) rkeymap) (cons t t)) ((and lkeymap (null rkeymap)) (cons nil t)) ((and lkeymap rkeymap (not (string= (symbol-name lkeymap) (symbol-name rkeymap)))) (cons (string< (symbol-name lkeymap) (symbol-name rkeymap)) t)) ((and (null lgroup) rgroup) (cons t t)) ((and lgroup (null rgroup)) (cons nil t)) ((and lgroup rgroup) (if (string= lgroup rgroup) (cons (string< (caar l) (caar r)) nil) (cons (string< lgroup rgroup) t))) (t (cons (string< (caar l) (caar r)) nil)))
  (let* ((regex bind-key-segregation-regexp) (lgroup (and (string-match regex (caar l)) (match-string 0 (caar l)))) (rgroup (and (string-match regex (caar r)) (match-string 0 (caar r)))) (lkeymap (cdar l)) (rkeymap (cdar r))) (cond ((and (null lkeymap) rkeymap) (cons t t)) ((and lkeymap (null rkeymap)) (cons nil t)) ((and lkeymap rkeymap (not (string= (symbol-name lkeymap) (symbol-name rkeymap)))) (cons (string< (symbol-name lkeymap) (symbol-name rkeymap)) t)) ((and (null lgroup) rgroup) (cons t t)) ((and lgroup (null rgroup)) (cons nil t)) ((and lgroup rgroup) (if (string= lgroup rgroup) (cons (string< (caar l) (caar r)) nil) (cons (string< lgroup rgroup) t))) (t (cons (string< (caar l) (caar r)) nil))))
  compare-keybindings((("C-c C-r" . dired-mode-map) mg/dired-sudo-edit-current-file nil) (("A" quote help-command) apropos nil))
  (car (compare-keybindings l r))
.........

:diminish does not work if :idle is used

I have the following config:

(use-package helm
  :if window-system
  :ensure helm
  :diminish helm-mode
  :idle
  (helm-mode 1))

Helm mode does not get diminished as expected. If I change :idle to :config or :init then :diminish works as expected.

Certain configuration causes use-package to error

This config:

(use-package xterm-frobs
  :if (not (display-graphic-p))
  :init
  (progn
    (defun bw-xterm-title ()
      (xterm-set-window-title (concat "emacs@" (system-name)))
      (xterm-set-icon-title (concat "emacs: " (buffer-name))))
    (add-hook 'window-configuration-change-hook 'bw-xterm-title)))

causes the following error:

Wrong type argument: stringp, nil

Which I believe was caused by 1d8c3c5, specifically

,(if (stringp name)

Advice about usage for simple configuration

Hello,

I have a simple configuration for which I'm not sure I should use use-package or not:

(eval-after-load 'tramp-gvfs
  '(add-to-list 'tramp-gvfs-methods "ftp"))

I think I could refactor this into:

(use-package tramp-gvfs
  :defer t
  :config
  (add-to-list 'tramp-gvfs-methods "ftp"))

Which kinda makes more sense for my config as almost everything uses use-package.

Now the questions:

  • Are the two snippets equivalent?
  • Do you bother with use-package if the configuration is only a bunch of (setq foo 'bar) and doesn't need autoloads?

FR: shorter form of :mode

I made a mistake by feeding :mode a string instead of a list:

;; Steve Yegge to the rescue
(use-package js2-mode
  :mode "\\.js\\(\.erb\\)?$")

and I got a reasonably cryptic error (wrong-type-argument listp 92). It would be nice if this did what I meant instead, i.e. treated it the same as :mode ("\\.js\\(\.erb\\)?$" . js2-mode).

not clear how to handle config which involves multiple packages

Hey John :) Firstly, awesome work here. I saw you demo this at emacsconf but only just got round to trying it out. Based on the docs, it seems to cover exactly what I want (the focus on startup speed is especially awesome!), except for one area I am unclear on:

If I have some config which involves integration between multiple packages, how can I use use-package to ensure that config is run only when all those packages are loaded?

For example, guide-key and org-mode, or guide-key and key-chord, or key-chord and any mode which I want key chord bindings for. I'm sure you can easily think of many other combinations :)

If use-package can already do this then I guess this bug is a friendly request to make that more obvious in the README.md, and if it can't, please consider this a feature request :)

Spurious byte compilation warnings

I am trying to use use-package for my configuration, because I have come to like the organization scheme it suggests, however, I have hit several issues with byte-compilation.

For once, if a package is not deferred, the :config block causes byte compiler warnings about free variables. For instance:

(use-package uniquify
  :config
  (setq uniquify-buffer-name-style 'forward
        uniquify-after-kill-buffer-p t
        uniquify-ignore-buffers-re "^\\*"))

The byte compiler now warns about “free variables”:

init.el:233:9:Warning: assignment to free variable
    `uniquify-buffer-name-style'
init.el:234:9:Warning: assignment to free variable
    `uniquify-after-kill-buffer-p'
init.el:235:9:Warning: assignment to free variable
    `uniquify-ignore-buffers-re'

As far as I understood the readme, these warnings should really not happen. uniquify isn't even deferred, thus it should really be loaded before :config gets evaluated, shouldn't it?

If have tried to follow the implementation of use-package, but it is beyond my lisp skills to sort it out.

dependencies between packages

there is no way, to set runtime dependencies for a package. what do you think about adding :requires LIST to the use-package function? It must guarantee loading required package before loading requiring package.

Runtime use-package dependency with :idle

If you have an :idle stanza then your compiled code has a runtime dependency on use-package for function `use-package-init-on-idle'. Unlike previous runtime dependency introductions I've detected, I haven't found a neat way to eliminate this, so I propose simply adding (require 'use-package) to the progn form planted by the :idle stanza expansion.

use-package.el - Lint warnings

FYI, The following warnings are displayed for the *.el file:

*** Lint Emacs 24.3.1 2013-06-25 13:37:25 file: use-package.el

** Lint M-x lm-verify (list-mnt.el)
Missing: ;; Maintainer:
Missing: ;; URL:
Missing: ;;; History:

** Lint M-x checkdoc-current-buffer (checkdoc.el)
use-package.el:305: First sentence should end with punctuation
use-package.el:310: All variables and subroutines might as well have a documentation string
use-package.el:326: All variables and subroutines might as well have a documentation string
use-package.el:359: Argument `form' should appear (as FORM) in the doc string
use-package.el:388: All variables and subroutines might as well have a documentation string
use-package.el:392: Argument `name' should appear (as NAME) in the doc string

Document the excellent :ensure feature

I'm currently passing the package name to :ensure, such as:

(use-package better-defaults
  :ensure better-defaults)

I assume that it has to be this way because e.g. you could ensuring a package which only depends on the present use-package package.

I'm not sure how it works because it's not mentioned in the documentation at all. This is a great feature! Please mention it, and explain it, in the README.

support for keymaps with :bind

I just started using this with my .emacs, and I am really supportive of the interface. The only thing that is unclear to me is how to use the :bind section in order to bind a key only in a specific keymap. For instance I use reftex with org-mode for citations.

      (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search)

I don't want this keybinding to be global because 'org-mode-reftex-search will error if called from a non org mode buffer. Could you make it clear how to do this in the README?

My guess at the interface would be

:bind ("C-c (" . ('org-mode-reftex-search . org-mode-search))

unbind-key doesn't remove binding from describe-personal-bindings

Using bind-key and then unbind-key results in the binding still appearing as nil in the output from describe-personal-bindings:

Key name          Command                                 Comments
----------------- --------------------------------------- ---------------------
�C-c j e           `nil'                                   (as-find-emacs-init-d)

don't bundle bind-key

Would you please consider not bundling bind-key? I am currently trying to resolve such conflicts for packages on the Emacsmirror.

Commit 6af2a63 is broken

The latest commit 6af2a63 doesn't like the code like following

(defmacro hook-into-modes (func modes)
`(dolist (mode-hook ,modes)
(add-hook mode-hook ,func)))

(use-package abbrev
:commands abbrev-mode
:diminish abbrev-mode
:init
(hook-into-modes #'abbrev-mode '(text-mode-hook))
(hook-into-modes #'abbrev-mode '(org-mode-hook))
...
...)

Reverting the commit makes it work again

elpa package does not include bind-key

The version I just grabbed with package-install does not include bind-key.el, and it doesn't look like bind-key is available from any of the package sources.

Feature Request - describe-personal-keybindings to show :prefix-map

It would be super, if describe-personal-keybindings would show the prefix-map in use for the bindings in question.

Currently, this is the output:

projectile-rails-mode-goto-map
-------------------------------------------------------------------------------
m                 `projectile-rails-find-current-model'

For this configuration:

(bind-keys :prefix-map projectile-rails-mode-goto-map
           :prefix "C-x p"
           ("m" . projectile-rails-find-current-model))))

Ideally describe-personal-keybindings would show the "C-x p" as well somewhere.

Make imenu recognize use-package directives

I've just added the following snippet to my init.el file. This allows me to use imenu to navigate my use-package directives. Nevertheless, I find this really ugly because 99% of the regexp is copy/pasted from lisp-mode lisp-imenu-generic-expression. Do you have any idea on how to improve?

(defun my:setup-imenu-for-use-package ()
      "Recognize `use-package` in imenu"
      (when (string= buffer-file-name (expand-file-name "init.el" "~/.emacs.d"))
        (setq imenu-generic-expression
              '((nil "^\\s-*(\\(def\\(?:advice\\|generic\\|ine-\\(?:compiler-macro\\|derived-mode\\|g\\(?:\\(?:eneric\\|lobal\\(?:\\(?:ized\\)?-minor\\)\\)-mode\\)\\|m\\(?:ethod-combination\\|inor-mode\\|odify-macro\\)\\|s\\(?:etf-expander\\|keleton\\)\\)\\|m\\(?:acro\\|ethod\\)\\|s\\(?:etf\\|ubst\\)\\|un\\*?\\)\\|use-package\\)\\s-+\\(\\(\\sw\\|\\s_\\)+\\)" 2)
 ("Variables" "^\\s-*(\\(def\\(?:c\\(?:onst\\(?:ant\\)?\\|ustom\\)\\|ine-symbol-macro\\|parameter\\)\\)\\s-+\\(\\(\\sw\\|\\s_\\)+\\)" 2)
 ("Variables" "^\\s-*(defvar\\s-+\\(\\(\\sw\\|\\s_\\)+\\)[[:space:]\n]+[^)]" 1)
 ("Types" "^\\s-*(\\(def\\(?:class\\|face\\|group\\|ine-\\(?:condition\\|widget\\)\\|package\\|struct\\|t\\(?:\\(?:hem\\|yp\\)e\\)\\)\\)\\s-+'?\\(\\(\\sw\\|\\s_\\)+\\)" 2)))))

(add-hook 'emacs-lisp-mode-hook 'my:setup-imenu-for-use-package)

unbind-key from describe-personal-keybindings

It would be great to be able to press k from a line in the *Personal Keybindings* buffer in order to unbind-key for the binding on that line. (However #74 will need to be fixed before this is fully effective.)

Feature request: failure case

I'd like to have something like:

(use-package missing-package
    :bind ()
    :missing (package-install "missing-package"))

so that if I try to load the package lazily (via a key binding, or via :config), and I haven't already installed it, it can automatically install itself before loading.

Is that insane?

Add a way to specify keymap in :bind keyword for `use-package`

For example, I call use-package preview from inside use-package latex (which still is called from inside use-package tex-site). I'd like to setup some bindings for preview, but they shouldn't go to global map, but latex map. Right now, I have to specify :commands and then bind the keys in :init section.

I'd implement this myself but I'm unsure how to handle it "properly". Should I add new keyword, or assume that e.g. first symbol in :bind is name of a map? I'm not sure if you follow any conventions like that.

(wrong-type-argument processp nil) when installing package

I am trying to port my init over from a hand-rolled thing to use-package, but it is failing to some packages. There were some which installed without any problem, but it is currently stuck trying to install keyfreq. I get the following backtrace on init:

Debugger entered--Lisp error: (wrong-type-argument processp nil)
  set-process-buffer(nil #<buffer  *url-http-temp*>)
  open-network-stream("melpa.milkbox.net" #<buffer  *url-http-temp*> "melpa.milkbox.net" 80 :type plain :nowait t)
  byte-code("..." [coding-system-for-write coding-system-for-read gw-method name buffer host binary (tls ssl native) native plain open-network-stream :type :nowait featurep make-network-process (:nowait t) socks socks-open-network-stream telnet url-open-telnet rlogin url-open-rlogin error "Bad setting of url-gateway-method: %s" service url-gateway-method conn] 11)
  url-open-stream("melpa.milkbox.net" #<buffer  *url-http-temp*> "melpa.milkbox.net" 80)
  url-http-find-free-connection("melpa.milkbox.net" 80)
  url-http([cl-struct-url "http" nil nil "melpa.milkbox.net" nil "/packages/keyfreq-20131109.926.el" nil nil t nil t] #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] (nil))
  url-retrieve-internal("http://melpa.milkbox.net/packages/keyfreq-20131109.926.el" #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"] (nil) nil nil)
  url-retrieve("http://melpa.milkbox.net/packages/keyfreq-20131109.926.el" #[128 "\302\303\304p#\210\300\305\240\210\301p\240\207" [(nil) (nil) url-debug retrieval "Synchronous fetching done (%S)" t] 5 "\n\n(fn &rest IGNORED)"])
  url-retrieve-synchronously("http://melpa.milkbox.net/packages/keyfreq-20131109.926.el")
  package-download-single(keyfreq "20131109.926" "track command frequencies" nil)
  package-download-transaction((keyfreq))
  package-install(keyfreq)
  use-package-ensure-elpa(keyfreq)
  #[(name &rest args) "..." [args commands pre-init-body pre-load-body init-body config-body use-package-validate-keywords use-package-plist-get :commands :pre-init :pre-load :init :config use-package-plist-get-value :diminish :defines :idle :bind :mode :interpreter :if :load-path mapcar #[(var) "\301�D\207" [var defvar] 2] defvar :requires t not member nil (function featurep) quote featurep symbol-name intern :disabled :ensure require package use-package-ensure-elpa progn ignore-errors diminish "-mode" #[(var) "..." [var diminish quote] 3] (require (quote use-package)) use-package-init-on-idle lambda #[(func sym-or-list) "..." [sym-or-list cons-list init-body progn mapcar #[(elem) "..." [elem commands func] 2]] 6] #[(binding) "..." [binding bind-key quote] 4] ...] 24 ("/home/dhackney/.emacs.d/.cask/24.3.1/elpa/use-package-20140216.602/use-package.elc" . 4890)](keyfreq :ensure keyfreq :ensure keyfreq)
  (use-package keyfreq :ensure keyfreq :ensure keyfreq)
  eval((use-package keyfreq :ensure keyfreq :ensure keyfreq))
  #[(target) "..." [verbose target x req-package-log nil t "loading " symbol-name eval] 7]((use-package keyfreq :ensure keyfreq :ensure keyfreq))
  mapcar(#[(target) "..." [verbose target x req-package-log nil t "loading " symbol-name eval] 7] ((use-package tramp :config (progn (add-to-list (quote tramp-default-proxies-alist) (quote (nil "\\`root\\'" "/ssh:%h:"))) (add-to-list (quote tramp-default-proxies-alist) (quote ((regexp-quote (system-name)) nil nil))))) (use-package conf-mode :mode ".cnf$") (use-package man :config (progn (add-hook (quote Man-mode-hook) (quote scroll-lock-mode)))) (use-package woman :config (progn (add-hook (quote woman-mode-hook) (quote scroll-lock-mode)))) (use-package dired :config (progn (require (quote org)) (define-key dired-mode-map "r" (quote dired-launch-command)))) (use-package pcache :ensure pcache :ensure pcache :config (setq pcache-directory (concat tmp-dir "pcache"))) (use-package smex :ensure smex :ensure smex :bind (("M-x" . smex) ("M-X" . smex-major-mode-commands) ("C-c M-x" . execute-extended-command)) :config (smex-initialize)) (use-package smart-mode-line :ensure smart-mode-line :ensure smart-mode-line :init (sml/setup)) (use-package scheme :mode (("\\.ss\\'" . scheme-mode) ("\\.scm$" . scheme-mode)) :config (add-hook (quote scheme-mode-hook) (quote paredit-mode))) (use-package haml-mode :ensure haml-mode) (use-package feature-mode :ensure feature-mode) (use-package rspec-mode :ensure rspec-mode) (use-package sass-mode :ensure sass-mode) (use-package less-css-mode :ensure less-css-mode) (use-package rinari :ensure rinari :ensure rinari) (use-package inf-ruby :ensure inf-ruby :config (setf (car inf-ruby-implementations) (quote ("ruby" . "pry")))) (use-package yard-mode :ensure yard-mode) (use-package ruby-block :ensure ruby-block) (use-package ruby-test-mode :ensure ruby-test-mode) (use-package rvm :ensure rvm) (use-package ruby-mode :ensure ruby-mode :mode (("Gemfile$" . ruby-mode) ("Buildfile$" . ruby-mode) ("config.ru$" . ruby-mode) ("\\.rake$" . ruby-mode) ("Rakefile$" . ruby-mode) ("\\.rabl$" . ruby-mode) ("\\.json_builder$" . ruby-mode)) :config (progn (add-hook (quote ruby-mode-hook) (quote flyspell-prog-mode)) (add-hook (quote ruby-mode-hook) (quote yard-mode)))) (use-package paredit :ensure paredit :ensure paredit :config (define-key lisp-interaction-mode-map (kbd "C-c C-e") (quote eval-print-last-sexp))) (use-package org-plus-contrib :ensure org-plus-contrib) (use-package org :ensure org :ensure org :bind (("C-c l" . org-store-link) ("C-c a" . org-agenda) ("C-c M-d" . org-open-day-page) ("C-c C-x C-o" . org-clock-out) ("C-c r" . org-capture)) :config (progn (defun org-open-day-page nil "Prompt for a date, and open associated day-page." (interactive) (find-file (expand-file-name (concat (replace-regexp-in-string "-" "." ...) ".org") org-directory))) (defun org-format-export-tel-link (path desc format) "Format a tel: link for export" (case format (html (format "<a href=\"%s\">%s</a>" path desc)) (latex (format "\\href{tel:%s}{\\texttt{%s}}" path desc)))) (define-key org-mode-map (kbd "C-M-m") (quote org-insert-heading-after-current)) (org-add-link-type "tel" nil (quote org-format-export-tel-link)))) (use-package multiple-cursors :ensure multiple-cursors :ensure multiple-cursors :bind (("C-c C-S-c" . mc/edit-lines) ("C->" . mc/mark-next-like-this) ("C-<" . mc/mark-previous-like-this) ("C-c C-<" . mc/mark-all-like-this) ("s-SPC" . set-rectangular-region-anchor)) :config (setq mc/list-file (concat tmp-dir ".mc-lists.el"))) (use-package magit :ensure magit :ensure magit :bind ("C-c g" . magit-status) :config (define-key magit-status-mode-map (kbd "W") (quote magit-toggle-whitespace))) (use-package js2-mode :ensure js2-mode :ensure js2-mode :mode (("\\.js\\'" . js2-mode) ("\\.json\\'" . javascript-mode))) (use-package hl-line+ :ensure hl-line+ :ensure hl-line+ :config (progn (defvar hl-line-ignore-regexp "*magit:.*") (defadvice global-hl-line-highlight (around unhighlight-some-buffers nil activate) "Don't highlight in buffers which match a regexp." (unless (string-match hl-line-ignore-regexp (buffer-name (window-buffer ...))) ad-do-it)))) (use-package helm :ensure helm :ensure helm :bind (("M-C-y" . helm-show-kill-ring) ("C-x f" . helm-recentf) ("C-x b" . helm-buffers-list)) :config (progn (define-key esc-map [remap find-tag] (quote helm-semantic-or-imenu)) (global-set-key [remap find-tag] (quote helm-semantic-or-imenu)) (define-key help-map [remap apropos-command] (quote helm-apropos)) (global-set-key [remap apropos-command] (quote helm-apropos)) (when (boundp (quote ido-minor-mode-map-entry)) (define-key (cdr ido-minor-mode-map-entry) [remap ido-switch-buffer] (quote helm-buffers-list))))) (use-package graphviz-dot-mode :ensure graphviz-dot-mode :ensure graphviz-dot-mode :mode "\\.dot$") (use-package quack :ensure quack) (use-package geiser :ensure geiser :ensure geiser :config (eval-after-load (quote geiser-mode) (quote (define-key geiser-mode-map [remap geiser-edit-symbol-at-point] (quote helm-semantic-or-imenu))))) (use-package geben :ensure geben :ensure geben :config (defadvice geben-dbgp-redirect-stream (around geben-output-inhibit-read-only activate) "Set `inhibit-read-only' during `geben-dbgp-redirect-stream'" (let ((inhibit-read-only t) (inhibit-modification-hooks t)) ad-do-it) (set-buffer-modified-p nil))) (use-package ess :ensure ess :ensure ess :config (require (quote ess-site) nil t)) (use-package erc :config (progn (add-hook (quote erc-mode-hook) (quote visual-line-mode)) (ad-activate (quote erc-process-away)) (ad-activate (quote erc-cmd-AWAY)))) (use-package jedi :ensure jedi) (use-package elpy :ensure elpy :ensure elpy :config (progn (add-to-list (quote exec-path) (expand-file-name "~/.local/bin")) (elpy-use-ipython) (define-key elpy-mode-map [remap elpy-goto-definition] (quote helm-semantic-or-imenu)))) (use-package dired-details :ensure dired-details :ensure dired-details :init (autoload (quote dired-details-install) "dired-details") :config (add-hook (quote after-init-hook) (quote dired-details-install))) (use-package auto-indent-mode :ensure auto-indent-mode :ensure auto-indent-mode) (use-package groovy-mode :ensure groovy-mode :ensure groovy-mode) (use-package yaml-mode :ensure yaml-mode :ensure yaml-mode) (use-package whitespace-cleanup-mode :ensure whitespace-cleanup-mode :ensure whitespace-cleanup-mode) (use-package websocket :ensure websocket :ensure websocket) (use-package vlf :ensure vlf :ensure vlf) (use-package undo-tree :ensure undo-tree :ensure undo-tree) (use-package unbound :ensure unbound :ensure unbound) (use-package tidy :ensure tidy :ensure tidy) (use-package sws-mode :ensure sws-mode :ensure sws-mode) (use-package ssh-config-mode :ensure ssh-config-mode :ensure ssh-config-mode) (use-package smooth-scrolling :ensure smooth-scrolling :ensure smooth-scrolling) ...))
  req-package-eval(((use-package tramp :config (progn (add-to-list (quote tramp-default-proxies-alist) (quote (nil "\\`root\\'" "/ssh:%h:"))) (add-to-list (quote tramp-default-proxies-alist) (quote ((regexp-quote (system-name)) nil nil))))) (use-package conf-mode :mode ".cnf$") (use-package man :config (progn (add-hook (quote Man-mode-hook) (quote scroll-lock-mode)))) (use-package woman :config (progn (add-hook (quote woman-mode-hook) (quote scroll-lock-mode)))) (use-package dired :config (progn (require (quote org)) (define-key dired-mode-map "r" (quote dired-launch-command)))) (use-package pcache :ensure pcache :ensure pcache :config (setq pcache-directory (concat tmp-dir "pcache"))) (use-package smex :ensure smex :ensure smex :bind (("M-x" . smex) ("M-X" . smex-major-mode-commands) ("C-c M-x" . execute-extended-command)) :config (smex-initialize)) (use-package smart-mode-line :ensure smart-mode-line :ensure smart-mode-line :init (sml/setup)) (use-package scheme :mode (("\\.ss\\'" . scheme-mode) ("\\.scm$" . scheme-mode)) :config (add-hook (quote scheme-mode-hook) (quote paredit-mode))) (use-package haml-mode :ensure haml-mode) (use-package feature-mode :ensure feature-mode) (use-package rspec-mode :ensure rspec-mode) (use-package sass-mode :ensure sass-mode) (use-package less-css-mode :ensure less-css-mode) (use-package rinari :ensure rinari :ensure rinari) (use-package inf-ruby :ensure inf-ruby :config (setf (car inf-ruby-implementations) (quote ("ruby" . "pry")))) (use-package yard-mode :ensure yard-mode) (use-package ruby-block :ensure ruby-block) (use-package ruby-test-mode :ensure ruby-test-mode) (use-package rvm :ensure rvm) (use-package ruby-mode :ensure ruby-mode :mode (("Gemfile$" . ruby-mode) ("Buildfile$" . ruby-mode) ("config.ru$" . ruby-mode) ("\\.rake$" . ruby-mode) ("Rakefile$" . ruby-mode) ("\\.rabl$" . ruby-mode) ("\\.json_builder$" . ruby-mode)) :config (progn (add-hook (quote ruby-mode-hook) (quote flyspell-prog-mode)) (add-hook (quote ruby-mode-hook) (quote yard-mode)))) (use-package paredit :ensure paredit :ensure paredit :config (define-key lisp-interaction-mode-map (kbd "C-c C-e") (quote eval-print-last-sexp))) (use-package org-plus-contrib :ensure org-plus-contrib) (use-package org :ensure org :ensure org :bind (("C-c l" . org-store-link) ("C-c a" . org-agenda) ("C-c M-d" . org-open-day-page) ("C-c C-x C-o" . org-clock-out) ("C-c r" . org-capture)) :config (progn (defun org-open-day-page nil "Prompt for a date, and open associated day-page." (interactive) (find-file (expand-file-name (concat (replace-regexp-in-string "-" "." ...) ".org") org-directory))) (defun org-format-export-tel-link (path desc format) "Format a tel: link for export" (case format (html (format "<a href=\"%s\">%s</a>" path desc)) (latex (format "\\href{tel:%s}{\\texttt{%s}}" path desc)))) (define-key org-mode-map (kbd "C-M-m") (quote org-insert-heading-after-current)) (org-add-link-type "tel" nil (quote org-format-export-tel-link)))) (use-package multiple-cursors :ensure multiple-cursors :ensure multiple-cursors :bind (("C-c C-S-c" . mc/edit-lines) ("C->" . mc/mark-next-like-this) ("C-<" . mc/mark-previous-like-this) ("C-c C-<" . mc/mark-all-like-this) ("s-SPC" . set-rectangular-region-anchor)) :config (setq mc/list-file (concat tmp-dir ".mc-lists.el"))) (use-package magit :ensure magit :ensure magit :bind ("C-c g" . magit-status) :config (define-key magit-status-mode-map (kbd "W") (quote magit-toggle-whitespace))) (use-package js2-mode :ensure js2-mode :ensure js2-mode :mode (("\\.js\\'" . js2-mode) ("\\.json\\'" . javascript-mode))) (use-package hl-line+ :ensure hl-line+ :ensure hl-line+ :config (progn (defvar hl-line-ignore-regexp "*magit:.*") (defadvice global-hl-line-highlight (around unhighlight-some-buffers nil activate) "Don't highlight in buffers which match a regexp." (unless (string-match hl-line-ignore-regexp (buffer-name (window-buffer ...))) ad-do-it)))) (use-package helm :ensure helm :ensure helm :bind (("M-C-y" . helm-show-kill-ring) ("C-x f" . helm-recentf) ("C-x b" . helm-buffers-list)) :config (progn (define-key esc-map [remap find-tag] (quote helm-semantic-or-imenu)) (global-set-key [remap find-tag] (quote helm-semantic-or-imenu)) (define-key help-map [remap apropos-command] (quote helm-apropos)) (global-set-key [remap apropos-command] (quote helm-apropos)) (when (boundp (quote ido-minor-mode-map-entry)) (define-key (cdr ido-minor-mode-map-entry) [remap ido-switch-buffer] (quote helm-buffers-list))))) (use-package graphviz-dot-mode :ensure graphviz-dot-mode :ensure graphviz-dot-mode :mode "\\.dot$") (use-package quack :ensure quack) (use-package geiser :ensure geiser :ensure geiser :config (eval-after-load (quote geiser-mode) (quote (define-key geiser-mode-map [remap geiser-edit-symbol-at-point] (quote helm-semantic-or-imenu))))) (use-package geben :ensure geben :ensure geben :config (defadvice geben-dbgp-redirect-stream (around geben-output-inhibit-read-only activate) "Set `inhibit-read-only' during `geben-dbgp-redirect-stream'" (let ((inhibit-read-only t) (inhibit-modification-hooks t)) ad-do-it) (set-buffer-modified-p nil))) (use-package ess :ensure ess :ensure ess :config (require (quote ess-site) nil t)) (use-package erc :config (progn (add-hook (quote erc-mode-hook) (quote visual-line-mode)) (ad-activate (quote erc-process-away)) (ad-activate (quote erc-cmd-AWAY)))) (use-package jedi :ensure jedi) (use-package elpy :ensure elpy :ensure elpy :config (progn (add-to-list (quote exec-path) (expand-file-name "~/.local/bin")) (elpy-use-ipython) (define-key elpy-mode-map [remap elpy-goto-definition] (quote helm-semantic-or-imenu)))) (use-package dired-details :ensure dired-details :ensure dired-details :init (autoload (quote dired-details-install) "dired-details") :config (add-hook (quote after-init-hook) (quote dired-details-install))) (use-package auto-indent-mode :ensure auto-indent-mode :ensure auto-indent-mode) (use-package groovy-mode :ensure groovy-mode :ensure groovy-mode) (use-package yaml-mode :ensure yaml-mode :ensure yaml-mode) (use-package whitespace-cleanup-mode :ensure whitespace-cleanup-mode :ensure whitespace-cleanup-mode) (use-package websocket :ensure websocket :ensure websocket) (use-package vlf :ensure vlf :ensure vlf) (use-package undo-tree :ensure undo-tree :ensure undo-tree) (use-package unbound :ensure unbound :ensure unbound) (use-package tidy :ensure tidy :ensure tidy) (use-package sws-mode :ensure sws-mode :ensure sws-mode) (use-package ssh-config-mode :ensure ssh-config-mode :ensure ssh-config-mode) (use-package smooth-scrolling :ensure smooth-scrolling :ensure smooth-scrolling) ...) nil)
  req-package-finish()
  eval-buffer()  ; Reading at buffer position 1005
  call-interactively(eval-buffer record nil)
  command-execute(eval-buffer record)
  execute-extended-command(nil "eval-buffer")
  call-interactively(execute-extended-command nil nil)

See my init settings here. I am using Cask and following the pattern used in this init file.

To reproduce, start Emacs with -Q and call eval-buffer in init.el. If I start emacs -Q and run package-install manually, it installs without a problem. Any ideas?

bind-keys does not accept a vector

I've been trying to use use-package. It seems just what I need.

Noting that bind-key accepts a vector, I tried similar with bind-keys inside a use-package :config. However it failed as follows:

(bind-keys :prefix-map mc-map
:prefix "C-c m"
("n" . mc/mark-next-like-this)
("p" . mc/mark-previous-like-this)
([(shift n)] . mc/unmark-next-like-this))

mapcar: Wrong type argument: characterp, (shift n)

Perhaps my usage is incorrect? I am only recently getting into elisp and the code here is more advanced than most.

bind-key.el - Unsafe package (not using unique prefix for symbols)

It appears that this package is not safe to install as it does not use customary PREFIX-* for all symbols. The names may clash existing or future definitions in Emacs; or user's own definitions.

Would it be possible to prefix all with bind-key-* to make it clear that these symbols are defined in bind-key.el package?

$ grep def bind-key.el

(defgroup bind-key nil
(defcustom bind-key-segregation-regexp
(defvar override-global-map (make-keymap)
(define-minor-mode override-global-mode
(defvar personal-keybindings nil)
(defmacro bind-key (key-name command &optional keymap)
   (define-key (or ,keymap global-map) ,keyvar ,command))))
(defmacro unbind-key (key-name &optional keymap)
(defmacro bind-key* (key-name command)
 (define-key override-global-map ,(read-kbd-macro key-name) ,command)))
(defun get-binding-description (elem)
(defun compare-keybindings (l r)
(defun describe-personal-keybindings ()

use-package fires twice (and :config is evaled when it shouldn't)?

Hello,

With the following:

(use-package dired+
  :commands toggle-diredp-find-file-reuse-dir)

(use-package dired
  :commands (dired
             find-name-dired
             find-dired)
  :config
    (toggle-diredp-find-file-reuse-dir 1))

I have the following output:

LOADING /Users/silex/Dropbox/emacs/config/dired.el
Configuring package dired... [2 times]
Reusing Dired buffers is now ON
Configuring package dired...done (0.348s)
Reusing Dired buffers is now ON
Configuring package dired...done (0.604s)

Weird isn't it? This file is loaded from my .emacs... but when I eval-buffer it then things are only printed once to *Message*, yet I'm sure the file is loaded only once.

Attach comments to binding

When running describe-personal-bindings I see there is a column named Comments, but nothing happens in it.

Key name             Command                  Comments

C-x s             `sr-speedbar-toggle'

Was wondering if this is for specifying conflicts, keymap or if there was a way one could specify the comments he wants in the bind statement?

(If it's not used for anything so far, it might be a good feature to enable user to specify such comments. For instance with this syntax:

 (use-package sr-speedbar
               :bind ("C-x s" . sr-speedbar-toggle   "testing" )

we could get in describe-personal-bindings this:

Key name             Command                  Comments

C-x s             `sr-speedbar-toggle'                testing

bind-key.el - Lint warnings

FYI, The following warnings are displayed for the *.el file

*** Lint Emacs 24.3.1 2013-06-25 13:16:00 file: bind-key.el

** Lint M-x lm-verify (list-mnt.el)
Missing: ;; Maintainer:
Missing: ;; URL:
Missing: ;;; History:
Missing: ;;; Code:

** Lint M-x checkdoc-current-buffer (checkdoc.el)
bind-key.el:119: All variables and subroutines might as well have a documentation string
bind-key.el:122: All variables and subroutines might as well have a documentation string
bind-key.el:127: All variables and subroutines might as well have a documentation string
bind-key.el:146: All variables and subroutines might as well have a documentation string
bind-key.el:173: All interactive functions should have documentation
bind-key.el:71: First line is not a complete sentence
bind-key.el:79: First line should be capitalized
bind-key.el:79: First sentence should end with punctuation
bind-key.el:98: All variables and subroutines might as well have a documentation string

el-get suggestions

I see in the source that el-get gets all sorts of special treatment, also it gets loaded if el-get-sources is defined... This looks a bit weird to me. Why do you load it if el-get-sources is defined?

IMHO there shouldn't be a different treatment for el-get, and all the monkey patching to be done for el-get to be correctly setup should be done in the :config section for it.

I understand you want to play nice with el-get, but then why not simply provide some macros/functions so it's easy to write the config section? something like :config (use-package-setup-el-get-sources)?

Unclear relationship with el-get

I didn't quite get the relationship between use-package and el-get. At the end of the readme, could you please extend your example setting el-get-sources to a list of packages you want installed? Also, I would like to understand your el-get-read-status-file function.

Allow multiple packages for :ensure

Hello, is it possible to make :ensure work with multiple packages? For instance, I'd like the following to install and require both packages:

(use-package yasnippet
  :ensure (yasnippet dropdown-list))

Add a default setting for :ensure

I think that it would be nice to allow the possibility to :ensure all packages by default.

I started to look at adding this via a customize variable, with a way to stop a particular package from being “ensured” when the customize variable is set to t.

The first thought I had would be to use :ensure nil for the override. However, I found that plist-get returns nil when the argument is unspecified, so all packages would override a default of t.

So I thought I'd come back here and ask about it. Is it a good idea? What kind of argument should override the default when it's t to say ‘no, don't ensure this is installed’?

Putting a variable for :bind does not work

When using the following construct:

(setq my-bind-for-magit '("C-c i" . magit-status))
(use-package magit
  :bind my-bind-for-magit)

I get the error message: Wrong type argument: sequencep, my-bind-for-magit. Is there any way around this?

`user-site-lisp-directory` used in `use-package-discover-el-get-type`

Your own constant, user-site-lisp-directory, is used in the use-package-discover-el-get-type method while trying to discover el-get.

I think it could be substituted with the standard user-emacs-directory, or otherwise made a setting particular to use-package, to make this more generally portable.

please tag releases

Could you please tag releases. If you have already done so and are wondering what I am talking about: tags have to be pushed explicitly using git push --tags. -- Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.