How to automatically install Emacs packages by specifying a list of package names?

后端 未结 11 2651
隐瞒了意图╮
隐瞒了意图╮ 2020-12-22 15:22

I am using package to manage my Emacs extensions. In order to synchronize my Emacs settings on different computers, I\'d like a way to specify a list of package

11条回答
  •  鱼传尺愫
    2020-12-22 15:49

    ; list the packages you want
    (setq package-list '(package1 package2))
    
    ; list the repositories containing them
    (setq package-archives '(("elpa" . "http://tromey.com/elpa/")
                             ("gnu" . "http://elpa.gnu.org/packages/")
                             ("marmalade" . "http://marmalade-repo.org/packages/")))
    
    ; activate all the packages (in particular autoloads)
    (package-initialize)
    
    ; fetch the list of packages available 
    (unless package-archive-contents
      (package-refresh-contents))
    
    ; install the missing packages
    (dolist (package package-list)
      (unless (package-installed-p package)
        (package-install package)))
    

提交回复
热议问题