checks dependencies in package section.

This commit is contained in:
larstvei 2014-04-02 22:08:48 +02:00
parent 6774efff6e
commit 0f18bb1fe6
3 changed files with 117 additions and 81 deletions

42
init.el
View File

@ -10,7 +10,6 @@ tangled, and the tangled file is compiled."
(add-hook 'after-save-hook 'init-hook) (add-hook 'after-save-hook 'init-hook)
(require 'package) (require 'package)
(package-initialize)
(add-to-list 'package-archives (add-to-list 'package-archives
'("MELPA" . "http://melpa.milkbox.net/packages/") t) '("MELPA" . "http://melpa.milkbox.net/packages/") t)
@ -36,6 +35,12 @@ PACKAGE is installed and the current version is deleted."
(package-desc-vers (cdr pkg-desc))))) (package-desc-vers (cdr pkg-desc)))))
(package-install package)))) (package-install package))))
(defun dependencies (package)
"Returns a list of dependencies from a given PACKAGE."
(let* ((pkg-desc (assq package package-alist))
(reqs (and pkg-desc (package-desc-reqs (cdr pkg-desc)))))
(mapcar 'car reqs)))
(defvar days-between-updates 1) (defvar days-between-updates 1)
(defvar do-package-update-on-init t) (defvar do-package-update-on-init t)
(defvar package-last-update-file (defvar package-last-update-file
@ -69,7 +74,7 @@ PACKAGE is installed and the current version is deleted."
(y-or-n-p "Update all packages?")) (y-or-n-p "Update all packages?"))
(package-refresh-contents) (package-refresh-contents)
(dolist (package (let* ((packages
'(ac-geiser ; Auto-complete backend for geiser '(ac-geiser ; Auto-complete backend for geiser
ac-slime ; An auto-complete source using slime completions ac-slime ; An auto-complete source using slime completions
ace-jump-mode ; quick cursor location minor mode ace-jump-mode ; quick cursor location minor mode
@ -94,11 +99,21 @@ PACKAGE is installed and the current version is deleted."
pretty-lambdada ; the word `lambda' as the Greek letter. pretty-lambdada ; the word `lambda' as the Greek letter.
smex ; M-x interface with Ido-style fuzzy matching. smex ; M-x interface with Ido-style fuzzy matching.
undo-tree)) ; Treat undo history as a tree undo-tree)) ; Treat undo history as a tree
(upgrade-or-install-package package)) ;; Fetch dependencies from all packages.
(reqs (mapcar 'dependencies packages))
;; Append these to the original list, and remove any duplicates.
(packages (delete-dups (apply 'append packages reqs))))
(dolist (package packages)
(upgrade-or-install-package package)))
;; This package is only relevant for Mac OS X. ;; This package is only relevant for Mac OS X.
(when (memq window-system '(mac ns)) (when (memq window-system '(mac ns))
(upgrade-or-install-package 'exec-path-from-shell))) (upgrade-or-install-package 'exec-path-from-shell)))
(setq package-enable-at-startup nil)
(package-initialize)
(when (memq window-system '(mac ns)) (when (memq window-system '(mac ns))
(setq mac-option-modifier nil (setq mac-option-modifier nil
mac-command-modifier 'meta mac-command-modifier 'meta
@ -115,6 +130,7 @@ PACKAGE is installed and the current version is deleted."
ox-md ; Markdown exporter (from org) ox-md ; Markdown exporter (from org)
pretty-lambdada ; show 'lambda' as the greek letter. pretty-lambdada ; show 'lambda' as the greek letter.
recentf ; recently opened files recentf ; recently opened files
smex ; M-x interface Ido-style.
tex-mode)) ; TeX, LaTeX, and SliTeX mode commands tex-mode)) ; TeX, LaTeX, and SliTeX mode commands
(require feature)) (require feature))
@ -283,17 +299,17 @@ PACKAGE is installed and the current version is deleted."
(when (fboundp 'imagemagick-register-types) (when (fboundp 'imagemagick-register-types)
(imagemagick-register-types)) (imagemagick-register-types))
(defadvice mu4e (before show-mu4e (arg) activate) ;; (defadvice mu4e (before show-mu4e (arg) activate)
"Always show mu4e in fullscreen and remember window ;; "Always show mu4e in fullscreen and remember window
configuration." ;; configuration."
(unless arg ;; (unless arg
(window-configuration-to-register :mu4e-fullscreen) ;; (window-configuration-to-register :mu4e-fullscreen)
(mu4e-update-mail-and-index t) ;; (mu4e-update-mail-and-index t)
(delete-other-windows))) ;; (delete-other-windows)))
(defadvice mu4e-quit (after restore-windows nil activate) ;; (defadvice mu4e-quit (after restore-windows nil activate)
"Restore window configuration." ;; "Restore window configuration."
(jump-to-register :mu4e-fullscreen)) ;; (jump-to-register :mu4e-fullscreen))
;; Overwrite the native 'compose-mail' binding to 'show-mu4e'. ;; Overwrite the native 'compose-mail' binding to 'show-mu4e'.
(global-set-key (kbd "C-x m") 'mu4e)) (global-set-key (kbd "C-x m") 'mu4e))

View File

@ -41,7 +41,6 @@
#+BEGIN_SRC emacs-lisp :tangle yes #+BEGIN_SRC emacs-lisp :tangle yes
(require 'package) (require 'package)
(package-initialize)
#+END_SRC #+END_SRC
Packages can be fetched from different mirrors, [[http://melpa.milkbox.net/#/][melpa]] is the largest Packages can be fetched from different mirrors, [[http://melpa.milkbox.net/#/][melpa]] is the largest
@ -84,6 +83,16 @@
(package-install package)))) (package-install package))))
#+END_SRC #+END_SRC
Also, we will need a function to find all dependencies from a given package.
#+BEGIN_SRC emacs-lisp :tangle yes
(defun dependencies (package)
"Returns a list of dependencies from a given PACKAGE."
(let* ((pkg-desc (assq package package-alist))
(reqs (and pkg-desc (package-desc-reqs (cdr pkg-desc)))))
(mapcar 'car reqs)))
#+END_SRC
The =package-refresh-contents= function downloads archive descriptions, The =package-refresh-contents= function downloads archive descriptions,
this is a major bottleneck in this configuration. To avoid this we can this is a major bottleneck in this configuration. To avoid this we can
try to only check for updates once every day or so. Here are three try to only check for updates once every day or so. Here are three
@ -140,7 +149,7 @@
(y-or-n-p "Update all packages?")) (y-or-n-p "Update all packages?"))
(package-refresh-contents) (package-refresh-contents)
(dolist (package (let* ((packages
'(ac-geiser ; Auto-complete backend for geiser '(ac-geiser ; Auto-complete backend for geiser
ac-slime ; An auto-complete source using slime completions ac-slime ; An auto-complete source using slime completions
ace-jump-mode ; quick cursor location minor mode ace-jump-mode ; quick cursor location minor mode
@ -165,10 +174,20 @@
pretty-lambdada ; the word `lambda' as the Greek letter. pretty-lambdada ; the word `lambda' as the Greek letter.
smex ; M-x interface with Ido-style fuzzy matching. smex ; M-x interface with Ido-style fuzzy matching.
undo-tree)) ; Treat undo history as a tree undo-tree)) ; Treat undo history as a tree
(upgrade-or-install-package package)) ;; Fetch dependencies from all packages.
(reqs (mapcar 'dependencies packages))
;; Append these to the original list, and remove any duplicates.
(packages (delete-dups (apply 'append packages reqs))))
(dolist (package packages)
(upgrade-or-install-package package)))
;; This package is only relevant for Mac OS X. ;; This package is only relevant for Mac OS X.
(when (memq window-system '(mac ns)) (when (memq window-system '(mac ns))
(upgrade-or-install-package 'exec-path-from-shell))) (upgrade-or-install-package 'exec-path-from-shell)))
(setq package-enable-at-startup nil)
(package-initialize)
#+END_SRC #+END_SRC
** Mac OS X ** Mac OS X
@ -204,6 +223,7 @@
ox-md ; Markdown exporter (from org) ox-md ; Markdown exporter (from org)
pretty-lambdada ; show 'lambda' as the greek letter. pretty-lambdada ; show 'lambda' as the greek letter.
recentf ; recently opened files recentf ; recently opened files
smex ; M-x interface Ido-style.
tex-mode)) ; TeX, LaTeX, and SliTeX mode commands tex-mode)) ; TeX, LaTeX, and SliTeX mode commands
(require feature)) (require feature))
#+END_SRC #+END_SRC
@ -510,17 +530,17 @@
(when (fboundp 'imagemagick-register-types) (when (fboundp 'imagemagick-register-types)
(imagemagick-register-types)) (imagemagick-register-types))
(defadvice mu4e (before show-mu4e (arg) activate) ;; (defadvice mu4e (before show-mu4e (arg) activate)
"Always show mu4e in fullscreen and remember window ;; "Always show mu4e in fullscreen and remember window
configuration." ;; configuration."
(unless arg ;; (unless arg
(window-configuration-to-register :mu4e-fullscreen) ;; (window-configuration-to-register :mu4e-fullscreen)
(mu4e-update-mail-and-index t) ;; (mu4e-update-mail-and-index t)
(delete-other-windows))) ;; (delete-other-windows)))
(defadvice mu4e-quit (after restore-windows nil activate) ;; (defadvice mu4e-quit (after restore-windows nil activate)
"Restore window configuration." ;; "Restore window configuration."
(jump-to-register :mu4e-fullscreen)) ;; (jump-to-register :mu4e-fullscreen))
;; Overwrite the native 'compose-mail' binding to 'show-mu4e'. ;; Overwrite the native 'compose-mail' binding to 'show-mu4e'.
(global-set-key (kbd "C-x m") 'mu4e)) (global-set-key (kbd "C-x m") 'mu4e))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 KiB

After

Width:  |  Height:  |  Size: 329 KiB