Auto install emacs packages with MELPA

前端 未结 6 1077
情话喂你
情话喂你 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:48

    A bit of code in your init file can do that quite easily:

    (setq my-onlinep nil)
    (unless
        (condition-case nil
            (delete-process
             (make-network-process
              :name "my-check-internet"
              :host "elpa.gnu.org"
              :service 80))
          (error t))
      (setq my-onlinep t))
    
    (setq my-packages
          '(ack-and-a-half
            ac-nrepl
            ... more packages here ...
            web-mode
            yaml-mode
            yari
            yasnippet))
    
    (when my-onlinep
      (package-refresh-contents)
      (cl-loop for p in my-packages
               unless (package-installed-p p)
               do (package-install p)))
    

    The online check is not really needed but helps to avoid getting a stuck Emacs startup when there is no internet connection.

    For my full config see here: http://steckerhalter.co.vu/steckemacs.html#sec-2-5

提交回复
热议问题