22

I just do this manually: run list-packages hit Uto mark available upgrades, then review to decide if there are any I don't want to pick up. Then x to upgrade. I do this pretty regularly, and often check what's new at the same time. I've got a couple tweaks to simplify this (see below). I suspect upgrading could be automated, but you do want to consider the ...


20

You can use with-eval-after-load to defer the key binding until after a certain module has been loaded (and thus defined the keymap): (with-eval-after-load "helm" (bind-key "M-Y" #'helm-end-of-buffer helm-map)) Use C-h v helm-map to find which module the keymap is defined in, and thus what to put in the string on the first line. with-eval-after-load was ...


19

They are different if the package is deferred, i.e. not loaded until it is needed. In that case :init will be executed at the time your emacs file is first read, but :config will be executed at the time the package is actually loaded. In your example, the use of mode implicitly defers loading the package. You have configured the package to be loaded the ...


18

The below would work. For the sake of clarity, I am using :ensure org-plus-contrib which deviates a bit from the example in your question. (use-package org :mode (("\\.org$" . org-mode)) :ensure org-plus-contrib :config (progn ;; config stuff )) Here are some explanation notes for the above: (use-package FEATURE-NAME FEATURE-NAME is what ...


17

The correct way to do this with use-package is as follows: (use-package org :ensure org-plus-contrib ... The first argument makes sure that it is the org.el file being sourced. The :ensure argument makes sure that you are getting the version with all the extras. Of course you also need to have ("org" . "http://orgmode.org/elpa/") in your package-...


14

The right way to do it would be (use-package markdown-mode :mode ("\\.markdown\\'" "\\.md\\'")) or (use-package markdown-mode :mode (("\\.markdown\\'" . markdown-mode) ("\\.md\\'" . markdown-mode))) In general, to see what any macro is expanding to, take the cursor to the closing parenthesis of that macro and do M-x pp-macroexpand-...


14

If you C-h f and enter unbind-key, the help says: unbind-key is an autoloaded Lisp macro in `bind-key.el'. (unbind-key KEY-NAME &optional KEYMAP) Not documented. The second argument to unbind-key is a key map -- for example org-mode-map. This works for me: (require 'bind-key) (unbind-key "C-," org-mode-map) (unbind-key "C-'" org-mode-map) ...


13

Is there any rule by which the user can determine whether the package configuration requires :init or :config? There is no general rule which applies to all settings and packages; you just need to familiarise yourself with the meaning of these keywords by reading the README file of use-package. In summary, the :init block is run at startup, as if you had ...


12

You can use the package manager to install a package and keep it up to date. htmlize isn't in the default archive, but you can easily add new ones (Marmalade and MELPA are the two most popular): (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) (add-to-list 'package-archives '("melpa" . "http://...


12

The following should work: (use-package js2-mode :mode (("\\.js\\'" . js2-mode) ("\\.jsx\\'" . js2-mode)) ... :ensure t)


12

You can use auto-package-update to automatically update packages. Copied from my other post (https://emacs.stackexchange.com/a/31903/9972) (use-package auto-package-update :ensure t :config (setq auto-package-update-delete-old-versions t auto-package-update-interval 4) (auto-package-update-maybe)) With that setup, packages will be ...


12

But for some packages that doesn't work. Such as auctex. The reason (use-package tex :ensure t) doesn't work for auctex is because auctex names a GNU ELPA package (see (emacs) Packages), whereas tex names a feature (see (elisp) Named Features) provided by the auctex package. In other words, tex names a single file tex.el which is distributed as part of the ...


11

The package's name is compile. Below should work. (use-package compile :init (progn (setq compilation-scroll-output t))) It would be worthwhile to note @JordonBiondo's comment on how to figure out a package's name. If you want to know which package a variable belongs to, do C-h v or M-x describe-variable followed by the var name (for a function ...


11

IIUC what you want to do is: (package-initialize t) Note the t argument, which is the key to your happiness here since it will (or should, at least) initialize package.el without activating all the installed packages.


11

Do I need (package-initialize) before these lines? If your version of Emacs (M-xemacs-versionRET) is older than 27, and you are using the built-in package manager, then you indeed need to call (package-initialize) before you can call on any installed packages, such as use-package. From Emacs 27 onwards, package-initialize will effectively be called ...


9

While quelpa and use-package have no direct relation with each other, there now is a package, quelpa-use-package, which adds a quelpa handler to use-package. This allows one to use use-package with a quelpa source package name or recipe, for example: (use-package flycheck-pony :quelpa (flycheck-pony :fetcher github :repo "rmloveland/flycheck-pony"))


9

When you call edebug-defun it debugs the top-level form, which in this case is (use-package ...). You can use debug-on-entry to debug a named function.


9

use-package is not part of standard Emacs. It's an extension you can install via the package manager from Melpa or download direct and as such you will need to: (require 'use-package) before you can use it to manage you package loads.


9

Solution In order to execute stuff after a given package is loaded, you need to put that after :config in use-package. Here's an example using the snippet in your question: Snippet # 1 (use-package helm :config (progn (bind-key "M-Y" #'helm-end-of-buffer helm-map) (bind-key "M-k" #'helm-next-line helm-find-files-map))) (use-package gnus :...


9

As the README will tell you, the :mode keyword allows you to define a deferred binding (i.e. on-demand), which will load the package when visiting a buffer which filename matches the expression you provided. The :init and :config keywords are what you are looking for: They allow you to respectively execute code before and after the package is loaded. ...


9

Use :mode "\\.jsx?\\'" Remember: all those backslashes are there because it's a regexp, so you really want to take advantage of it when you can, otherwise you're just suffering through those backslashes for nothing. You could also write it :mode "\\.\\(js\\|jsx\\)\\'" or many other ways, of course.


9

I use auto-package-update to automatically update packages. (use-package auto-package-update :ensure t :config (setq auto-package-update-delete-old-versions t auto-package-update-interval 4) (auto-package-update-maybe)) With that setup, packages will be updated every 4 days, and the old packages will be removed.


9

dired+ has left MELPA repository, and now you have to download it manually from EmacsWiki. You can still use use-package with a downloaded package, like this: (use-package dired+ :load-path "~/.emacs.d/packages/dired+") Another option is to use a dired+ repository mirror in github, along with a tool like quelpa, which allows you to fetch packages ...


8

This example made me much easy to understand the difference between :init and :config. Let's take an example of ace-window package (but this can be any package). Put this in your init.el file: (use-package ace-window :ensure t :defer t :config (progn (message "ace window: hello world"))) Now open your emacs and see in the *Messages* buffer to ...


8

You need to quote "<f11>", like this: :bind ("<f11>" . multi-term) And here's a full example, with ace-jump-mode: (use-package ace-jump-mode :commands ace-jump-mode :init :bind ("<f7>" . ace-jump-mode))


8

I don't know why company-mode is getting diminished, but I think I know what's going on with whitespace-mode. Your block (use-package whitespace :ensure t ;; I also tried without this line :config (global-whitespace-mode) :bind (([f10] . whitespace-mode) ([(shift f10)] . global-whitespace-mode))) will automatically defer loading the ...


8

This particular error happens if Emacs failed looking up the latest version of a package, like if there's no package-archives file containing that information. Before installing packages, make sure to run M-x package-refresh-contents so that there is one. Alternatively, use M-x package-list-packages for installing packages, that ensures that the package-...


7

Debugger entered--Lisp error: (error "Package ‘dired-’ is unavailable") You get this error when package.el tries to install a non-existent package. use-package will attempt to install the given package name if you pass or :ensure t or you have set use-package-always-ensure to non-nil. Use :ensure nil to override use-package-always-ensure. You need to do ...


Only top voted, non community-wiki answers of a minimum length are eligible