Вопрос по – Как автоматически установить пакеты Emacs, указав список имен пакетов?

118

я используюpackage управлять моими расширениями Emacs. Чтобы синхронизировать мои настройки Emacs на разных компьютерах, я бы хотел указать список имен пакетов в.emacs файл, а затемpackage может автоматически искать и устанавливать пакеты, так что мне не нужно устанавливать их вручную, позвонивM-x package-list-packages, Как это сделать?

Error: User Rate Limit Exceeded phils

Ваш Ответ

10   ответов
101
; 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)))
Error: User Rate Limit Exceededpackage.
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededpackage-refresh-contentsError: User Rate Limit Exceeded
Error: User Rate Limit Exceededpackage-refresh-contentsError: User Rate Limit Exceeded(or (file-exists-p package-user-dir))Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededuse-packageError: User Rate Limit Exceeded:ensureError: User Rate Limit Exceededpackage-selected-packagesError: User Rate Limit Exceeded
1

Error: User Rate Limit Exceeded(package-install 'org)Error: User Rate Limit Exceeded.emacsError: User Rate Limit Exceededorg-modeError: User Rate Limit Exceededorg-modeError: User Rate Limit Exceeded

Error: User Rate Limit Exceededpackage-installError: User Rate Limit Exceeded(unless (package-installed-p package) ...)Error: User Rate Limit Exceeded10093312Error: User Rate Limit Exceeded

(defun package-install (pkg &optional dont-select)
  "Install the package PKG.
PKG can be a package-desc or a symbol naming one of the available packages
in an archive in `package-archives'.  Interactively, prompt for its name.

If called interactively or if DONT-SELECT nil, add PKG to
`package-selected-packages'.

If PKG is a package-desc and it is already installed, don't try
to install it but still mark it as selected."
  (interactive
   (progn
     ;; Initialize the package system to get the list of package
     ;; symbols for completion.
     (unless package--initialized
       (package-initialize t))
     (unless package-archive-contents
       (package-refresh-contents))
     (list (intern (completing-read
                    "Install package: "
                    (delq nil
                          (mapcar (lambda (elt)
                                    (unless (package-installed-p (car elt))
                                      (symbol-name (car elt))))
                                  package-archive-contents))
                    nil t))
           nil)))
  (add-hook 'post-command-hook #'package-menu--post-refresh)
  (let ((name (if (package-desc-p pkg)
                  (package-desc-name pkg)
                pkg)))
    (unless (or dont-select (package--user-selected-p name))
      (package--save-selected-packages
       (cons name package-selected-packages)))
    (if-let ((transaction
              (if (package-desc-p pkg)
                  (unless (package-installed-p pkg)
                    (package-compute-transaction (list pkg)
                                                 (package-desc-reqs pkg)))
                (package-compute-transaction () (list (list pkg))))))
        (package-download-transaction transaction)
      (message "`%s' is already installed" name))))

Error: User Rate Limit Exceededorg-modeError: User Rate Limit Exceededpackage-installError: User Rate Limit Exceeded

(dolist (package (package-compute-transaction
                  () (list (list 'python '(0 25 1))
                           (list 'org '(20171211)))))
  ;; package-download-transaction may be more suitable here and
  ;; I don't have time to check it
  (package-install package))

Error: User Rate Limit Exceededpackage-*Error: User Rate Limit Exceededpackage-descError: User Rate Limit Exceededpackage-installError: User Rate Limit Exceededpackage-descError: User Rate Limit Exceeded

7

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded~/.emacs.d/CaskError: User Rate Limit Exceeded

(source melpa)
(depends-on "expand-region")
(depends-on "goto-last-change")
; ... etc

Error: User Rate Limit ExceededcaskError: User Rate Limit Exceeded

Error: User Rate Limit Exceededcask update.

Error: User Rate Limit Exceeded/path/to/emacs -Q --script /path/to/cask/cask-cli.el -- [args]
Error: User Rate Limit Exceeded
Error: User Rate Limit ExceededdotfilesError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
45

Error: User Rate Limit Exceeded

(defun ensure-package-installed (&rest packages)
  "Assure every package is installed, ask for installation if it’s not.

Return a list of installed packages or nil for every skipped package."
  (mapcar
   (lambda (package)
     ;; (package-installed-p 'evil)
     (if (package-installed-p package)
         nil
       (if (y-or-n-p (format "Package %s is missing. Install it? " package))
           (package-install package)
         package)))
   packages))

;; make sure to have downloaded archive description.
;; Or use package-archive-contents as suggested by Nicolas Dudebout
(or (file-exists-p package-user-dir)
    (package-refresh-contents))

(ensure-package-installed 'iedit 'magit) ;  --> (nil nil) if iedit and magit are already installed

;; activate installed packages
(package-initialize)
Error: User Rate Limit Exceeded
Error: User Rate Limit ExceededmapcError: User Rate Limit Exceededunless?
Error: User Rate Limit Exceeded RNA
Error: User Rate Limit ExceededorError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
36

Error: User Rate Limit Exceededpackage-selected-packagesError: User Rate Limit Exceededpackage-installError: User Rate Limit Exceededpackage-install-selected-packagesError: User Rate Limit Exceeded

Error: User Rate Limit Exceededpackage-autoremoveError: User Rate Limit Exceededpackage-selected-packagesError: User Rate Limit Exceeded

(package-initialize)
(unless package-archive-contents
  (package-refresh-contents))
(package-install-selected-packages)

Error: User Rate Limit ExceededError: User Rate Limit Exceeded

4

Error: User Rate Limit Exceededpackage-installError: User Rate Limit Exceededpackage-installError: User Rate Limit Exceededpackage-installed-pError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

(mapc
 (lambda (package)
   (or (package-installed-p package)
       (package-install package)))
 '(package1 package2 package3))
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededdired+Error: User Rate Limit Exceededpackage-list-packagesError: User Rate Limit Exceededpackage-archivesError: User Rate Limit Exceeded(package-install 'dired+)?
Error: User Rate Limit Exceeded RNA
Error: User Rate Limit Exceedederror: Package Error: User Rate Limit Exceeded RNA
Error: User Rate Limit Exceeded(package-installed-p 'dired+)Error: User Rate Limit ExceededtError: User Rate Limit Exceeded
17

Error: User Rate Limit ExceededError: User Rate Limit Exceeded:

(require 'package)
(require 'melpa)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)

(setq url-http-attempt-keepalives nil)

(defvar prelude-packages
  '(ack-and-a-half auctex clojure-mode coffee-mode deft expand-region
                   gist haml-mode haskell-mode helm helm-projectile inf-ruby
                   magit magithub markdown-mode paredit projectile
                   python sass-mode rainbow-mode scss-mode solarized-theme
                   volatile-highlights yaml-mode yari yasnippet zenburn-theme)
  "A list of packages to ensure are installed at launch.")

(defun prelude-packages-installed-p ()
  (loop for p in prelude-packages
        when (not (package-installed-p p)) do (return nil)
        finally (return t)))

(unless (prelude-packages-installed-p)
  ;; check for new packages (package versions)
  (message "%s" "Emacs Prelude is now refreshing its package database...")
  (package-refresh-contents)
  (message "%s" " done.")
  ;; install the missing packages
  (dolist (p prelude-packages)
    (when (not (package-installed-p p))
      (package-install p))))

(provide 'prelude-packages)

Error: User Rate Limit Exceededmelpa.elError: User Rate Limit Exceededload-pathError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededgithub.com/slipset/emacs/blob/master/ensure-packages.el
3
(require 'cl)
(require 'package)

(setq cfg-var:packages '(
       emmet-mode
       ergoemacs-mode
       flycheck
       flycheck-pyflakes
       monokai-theme
       py-autopep8
       py-isort
       rainbow-mode
       yafolding
       yasnippet))

(defun cfg:install-packages ()
    (let ((pkgs (remove-if #'package-installed-p cfg-var:packages)))
        (when pkgs
            (message "%s" "Emacs refresh packages database...")
            (package-refresh-contents)
            (message "%s" " done.")
            (dolist (p cfg-var:packages)
                (package-install p)))))

(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)

(cfg:install-packages)
3

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

(setq required-pkgs '(jedi flycheck cider clojure-mode paredit markdown-mode jsx-mode company))

(require 'cl)

(setq pkgs-to-install
      (let ((uninstalled-pkgs (remove-if 'package-installed-p required-pkgs)))
        (remove-if-not '(lambda (pkg) (y-or-n-p (format "Package %s is missing. Install it? " pkg))) uninstalled-pkgs)))

(when (> (length pkgs-to-install) 0)
  (package-refresh-contents)
  (dolist (pkg pkgs-to-install)
    (package-install pkg)))
0

Error: User Rate Limit Exceeded

(mapc
 (lambda (package)
   (unless (package-installed-p package)
     (progn (message "installing %s" package)
            (package-refresh-contents)
            (package-install package))))
 '(browse-kill-ring flycheck less-css-mode tabbar org auto-complete undo-tree clojure-mode markdown-mode yasnippet paredit paredit-menu php-mode haml-mode rainbow-mode fontawesome))

Похожие вопросы