Learn how to manage Emacs packages well.

Asked 1 months ago, Updated 1 months ago, 3 views

I'm looking for a good way to manage packages to run Emacs on many OS machines.

The Emacs version is currently 24.4.This is the version of any machine, so you don't have to consider running anything other than the latest version.

The answer I would like is to try to achieve the following preferred methods as much as possible.

  • Complete with only configuration files and Emacs packages (no commands required in OS)
  • Multiple operating systems (including Windows)
  • Automatically install packages
  • Using the Git protocol, etc., you can retrieve packages from places other than the repository (i.e., you can automatically install so-called stray packages)
  • Easy to write settings

Of course, I would be happy if there are other ways to benefit from the above preferred method, and I don't need to satisfy everything.

As a trial and error, I tried Package.el+'s own set of functions, Quelpa, and Cask, but I don't think any of them met all of the requirements.

Currently, I implement the following commands in Package.el to install the package.

 (defvar my/favorite-packages)
  '(package names here))
(defun set-pac()
  "my package install command"
  (dolist (package my/favorite-packages)
    (when (not (package-installed-package))
    (package-install package)))

Is there any other good way to meet the requirements?


2022-09-30 12:06

3 Answers

How about using use-package

There are all the elements you need to write .emacs, such as post-load settings, conditional branches, delay loads, and key settings.Plus, the library can be loaded and configured in one S formula, making it more readable.

If package.el requires automatic installation of external packages, add :ensuret to the argument.Without it, AutoInstall will not occur and the configuration will be skipped.

 (use-package magit)

2022-09-30 12:06

How about el-get


If you write a recipe like this (e.g., ~/.emacs.d/el-get-user/recipes/migemo.rcp),

 (:name migemo)
   :description "Japanese incremental search through dynamic pattern expansion."
   —website "http://0xcc.net/migemo/"
   —type github
   : pkgname "emacs-jp/migemo")

.emacs or .emacs.d/init.el can be installed at startup by simply writing:


(unless(require'el-get nil'no error)
    (goto-char (point-max))



Addition by @uchida

It also supports the elpa package.

If you wrote the above in .emacs.d/init.el, you can create recipes from the elpa package from to/.emacs.d/el-get/el-get/recipe/elpa.

(unless (file-directory-pel-get-recipe-path-elpa)

Therefore, in addition to your own recipe, you can install the elpa package as follows:

(defvar my/el-get-packages' (package names here))
(el-get'sync my/el-get-packages)

2022-09-30 12:06

As for the questioner, I am posting because I have a certain successful approach to this issue.

Define the following with init.el or any .el (where hoge.el)

(add-to-list 'package-archives' ("melpa". "http://melpa.milkbox.net/packages/"))
(add-to-list 'package-archives' ("marmalade". "http://marmalade-repo.org/packages/"))

This section uses packages, adds repositories to use, and initializes packages.Change the repository as needed.

 (defvar my/favorite-packages)
  '(package names here))

Here we define a list and write the name of the package exactly as it is , such as popwin.

 (defun set-pac()
  "my package install command"
  (dolist (package my/favorite-packages)
    (when (not (package-installed-package))
    (package-install package)))

This command updates the package information and installs packages that are not included.

To install the package, do one of the following:

  • Start Emacs and then run M-xset-pac
  • emacs--batch-l path/to/hoge.el-f'set-pac'

For path/to/hoge.el, write the init.el or any .el location that defines the variables and functions above. If defined in init.el, it will probably be ~/.emacs.d/init.el.

This method is complete with only configuration files and Emacs, as well as auto-installation on multiple operating systems that Emacs can handle in the package.el of Emacs.

I hope it will be helpful for someone.

Note: "Kosh said ""use-package"" and ""use-package"" was a very good extension." However, use-package is a bootstrap problem, so only package.el will write an Emacs Lisp to automatically install use-package.

Assume the first block of code in this answer (requiring)

(when (not (package-installed-p 'use-package))
  (package-install 'use-package))

(require 'use-package)

If you write something like this before the use-package part of init.el, you can use the use-package as it is without having to install it manually.

I hope this will also be helpful.

2022-09-30 12:06

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.