From 8f886c07d267894263e5c9818c60ada480aa7e0a Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Wed, 22 Jun 2011 11:38:40 +0200 Subject: [PATCH] `el-get' now defaults to caring about packages known "required" and "installed" from the status file. This should bring a much easier to understand semantics, near of that of apt-get and friends: by default, any installed package is automatically initialized at next startup without special care. If you don't need local recipes, you don't need to edit and maintain any `el-get-sources'. It's still possible to manually prepare a list of packages to install, so that you can share your setup between multiple installations. To do that, give the package list (names or symbols) to the (el-get) call in your setup. This way you can also maintain specific lists depending on system or network or whatever is useful for you. That's the advanced setup, documented. --- README.asciidoc | 44 +++++++++++++++++++++++------ el-get.el | 74 +++++++++++++++++++++++++------------------------ 2 files changed, 73 insertions(+), 45 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index d1d2fc90..4aaf6ca1 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -73,7 +73,29 @@ avoid this with the following snippet instead: See next section for details about how to setup you emacs so that it's able to benefit from +el-get+ automatically. -== What is this? +== Basic usage + +Now that +el-get+ is installed, simply use +M-x el-get-install+ and pick +whatever package you need. Arrange to have +el-get+ part of your setup, so +that at next emacs startup the installed packages are initialized. Here's +how to: + +-------------------------------------- +(add-to-list 'load-path "~/.emacs.d/el-get/el-get") + +(unless (require 'el-get nil t) + (url-retrieve + "https://github.com/dimitri/el-get/raw/master/el-get-install.el" + (lambda (s) + (end-of-buffer) + (eval-print-last-sexp)))) + +(el-get 'sync) +-------------------------------------- + +That's the basic setup. + +== Advanced setup with local recipes Of course, my emacs setup is managed in a private git repository. Some people on +#emacs+ are using +git submodules+ (or was it straight import) @@ -85,10 +107,9 @@ run emacs, and I want this documentation to be usable as-is. Enters el-get! (add-to-list 'load-path "~/.emacs.d/el-get/el-get") (require 'el-get) +;; local sources (setq el-get-sources - '(cssh el-get switch-window vkill google-maps nxhtml xcscope yasnippet - - (:name magit + '((:name magit :after (lambda () (global-set-key (kbd "C-x C-z") 'magit-status))) (:name asciidoc @@ -104,7 +125,12 @@ run emacs, and I want this documentation to be usable as-is. Enters el-get! (:name dictionary-el :type apt-get) (:name emacs-goodies-el :type apt-get))) -(el-get) +(setq 'my-packages + (append + '(cssh el-get switch-window vkill google-maps nxhtml xcscope yasnippet) + (loop for src in el-get-sources collect (el-get-source-name src)))) + +(el-get 'sync my-packages) -------------------------------------- So now you have a pretty good documentation of the packages you want @@ -154,13 +180,14 @@ You even get a progress report! === Sources -See the documentation of the +el-get-sources+ variable for details. +See the documentation of the +el-get-sources+ variable for details. Please +note that +el-get-sources+ is a Note that you can also give a mix of +packages+ symbols, +inline recipes+ and +source lists+ to +el-get+ as arguments, and completely bypass the +el-get-sources+ variable. - (el-get 'sync 'package 'name '(:name foo :type emacswiki) other-list-of-sources) + (el-get 'sync 'package 'name 'list-of-packages-names-or-symbol) It is still recommended to +(setq el-get-sources '(list of packages))+ then use +(el-get 'sync)+, so that commands such as +el-get-update+ know which @@ -211,8 +238,7 @@ Yes, ok. M-x el-get-sync:: - Synchronously make your current el-get status match +el-get-sources+, - by installing and initializing all your packages. + Synchronously install any "required" package and init any "installed" one. M-x el-get-cd:: diff --git a/el-get.el b/el-get.el index b8fcc215..53480604 100644 --- a/el-get.el +++ b/el-get.el @@ -3092,7 +3092,34 @@ entry which is not a symbol and is not already a known recipe." ;; ;; User Interface, Non Interactive part ;; -(defun el-get (&optional sync &rest source-list) +(defun el-get-init-and-install (&optional packages) + "Install \"required\" packages, init \"installed\" packages. + +When PACKAGES is non-nil, only process entries from this list. +Those packages from the list we don't know the status of are +considered \"required\"." + (message "PHOQUE %S" packages) + (let* ((required (el-get-list-package-names-with-status "required")) + (installed (el-get-list-package-names-with-status "installed")) + (to-init (if packages + (loop for p in packages + when (member (el-get-as-string p) installed) + collect (el-get-as-string p)) + installed)) + (to-install (if packages + (loop for p in packages + unless (member (el-get-as-symbol p) to-init) + collect (el-get-as-string p)) + required))) + (el-get-verbose-message "el-get-init-and-install: init %S" to-init) + (el-get-verbose-message "el-get-init-and-install: install %S" to-install) + (loop for p in + (append + (loop for p in to-install do (el-get-install p) collect p) + (loop for p in to-init do (el-get-init p) collect p)) + collect p))) + +(defun el-get (&optional sync &rest packages) "Ensure that packages have been downloaded once and init them as needed. This will not update the sources by using `apt-get install' or @@ -3120,26 +3147,13 @@ done synchronously, so you will have to wait here. There's `byte-compile' support though, and the packages you use are welcome to use `autoload' too. -SOURCE-LIST is expected to be a list of sources you want to -install or init. Each element in this list can be either a -package name, a package recipe, or a proper source list. When -SOURCE-LIST is omitted, `el-get-standard-packages' is used." +PACKAGES is expected to be a list of packages you want to install +or init. When PACKAGES is omited (the default), the list of +already installed packages is considered." (unless (or (null sync) (member sync '(sync wait))) (error "el-get sync parameter should be either nil, sync or wait")) - ;; Customizations are written to the end of the user's init file, so - ;; if el-get is being called from the init file, the desired value - ;; of `el-get-standard-packages' won't be known yet. - ;; - ;; Unless a specific set of packages was requested, the user expects - ;; all the standard packages to be initialized, so unless the - ;; customizations have been seen, remember to invoke el-get one more - ;; time after initial customizations have been read in. - (unless (or source-list - (get 'el-get-standard-packages 'saved-value)) - (add-hook 'after-init-hook (apply-partially 'el-get sync))) - ;; If there's no autoload file, everything needs to be regenerated. (if (not (file-exists-p el-get-autoload-file)) (el-get-invalidate-autoloads)) @@ -3153,22 +3167,10 @@ SOURCE-LIST is omitted, `el-get-standard-packages' is used." 0 100 0))) (el-get-default-process-sync sync)) - ;; keep the result of mapcar to return it even in the 'wait case + ;; keep the result of `el-get-init-and-install' to return it even in the + ;; 'wait case (prog1 - ;; build el-get-sources from source-list, flattening only one level - ;; of embedded lists in there. That allows users to be as lazy as: - ;; (el-get 'sync 'package 'name (:name recipe) el-get-sources) - (let ((el-get-sources - (if source-list - (loop for sources in source-list - when (and (listp sources) - (not (plist-member sources :name))) - append sources - else collect sources) - el-get-sources))) - - (dolist (s (el-get-standard-package-list)) - (el-get-install s))) + (apply 'el-get-init-and-install packages) ;; el-get-do-install is async, that's now ongoing. (when progress @@ -3183,11 +3185,11 @@ SOURCE-LIST is omitted, `el-get-standard-packages' is used." (progress-reporter-update progress (/ (* 100.0 (- newly-installing still-installing)) newly-installing))) - (progress-reporter-done progress))))) + (progress-reporter-done progress))) - ;; unless we have autoloads to update, just load them now - (unless el-get-outdated-autoloads - (el-get-eval-autoloads))) + ;; unless we have autoloads to update, just load them now + (unless el-get-outdated-autoloads + (el-get-eval-autoloads))))) (provide 'el-get)