Auto install emacs packages with MELPA

前端 未结 6 1059
情话喂你
情话喂你 2020-12-22 22:42

I want to declare all packages that I want to use in emacs in a init.el file. I wonder if its possible to load the missing packages with e.g. MELPA when I startup e

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-22 23:31

    In addition to excellent options suggested above you may also want take a look at el-get. I use it for my emacs setup and have been very happy with it.

    How is it different?

    Two main advantages of el-get are

    1) It can fetch packages from variety of sources, the website lists the following possible sources

    github, emacswiki, GNU ELPA or Marmalade, privately hosted pages, git, bzr, CVS etc

    2) It can be used to run OS commands like make if required during package installation. This makes installation of packages that have non-elisp parts easier, eg. emacs-jedi, ropemacs etc

    Installing el-get

    Installation is pretty simple you will need to add the following bootstrap code given at their website to your init file.

    (add-to-list 'load-path "~/.emacs.d/el-get/el-get")
    
    (unless (require 'el-get nil 'noerror)
      (with-current-buffer
          (url-retrieve-synchronously
           "https://raw.github.com/dimitri/el-get/master/el-get-install.el")
        (goto-char (point-max))
        (eval-print-last-sexp)))
    
    (el-get 'sync)
    

    This will install el-get if it is not already installed.

    Installing packages

    You can then declare the packages you want to install and let el-get install them

    ;; List of packages you want to install
    (defvar my-packages '(auto-complete flycheck smart-parens...))
    ;; This will install any package from my-packages which is not already installed
    (el-get 'sync my-packages)
    

    OR

    You can always install packages manually by doing el-get-install RET, I doubt you will want to install your dozens of different packages this way but it is possible.

    Updating packages

    Updating packages is simply a matter of doing el-get-update to update a specific package or el-get-update-all to update all the installed packages.

提交回复
热议问题