Update for 24.4.

This commit is contained in:
Lars Tveito 2014-12-16 20:28:07 +01:00
parent 90b6af78fe
commit 009ffd95f5
3 changed files with 77 additions and 59 deletions

View File

@ -1,35 +1,35 @@
- [About](#about) - [About](#sec-1)
- [Configurations](#configurations) - [Configurations](#sec-2)
- [Meta](#meta) - [Meta](#sec-2-1)
- [Package](#package) - [Package](#sec-2-2)
- [Mac OS X](#mac-os-x) - [Mac OS X](#sec-2-3)
- [Require](#require) - [Require](#sec-2-4)
- [Sane defaults](#sane-defaults) - [Sane defaults](#sec-2-5)
- [Modes](#modes) - [Modes](#sec-2-6)
- [Visual](#visual) - [Visual](#sec-2-7)
- [Ido](#ido) - [Ido](#sec-2-8)
- [Calendar](#calendar) - [Calendar](#sec-2-9)
- [Mail](#mail) - [Mail](#sec-2-10)
- [Flyspell](#flyspell) - [Flyspell](#sec-2-11)
- [Org](#org) - [Org](#sec-2-12)
- [Interactive functions](#interactive-functions) - [Interactive functions](#sec-2-13)
- [Advice](#advice) - [Advice](#sec-2-14)
- [Presentation-mode](#presentation-mode) - [Presentation-mode](#sec-2-15)
- [Mode specific](#mode-specific) - [Mode specific](#sec-3)
- [Shell](#shell) - [Shell](#sec-3-1)
- [Lisp](#lisp) - [Lisp](#sec-3-2)
- [Emacs Lisp](#emacs-lisp) - [Emacs Lisp](#sec-3-2-1)
- [Common lisp](#common-lisp) - [Common lisp](#sec-3-2-2)
- [Scheme](#scheme) - [Scheme](#sec-3-2-3)
- [Java and C](#java-and-c) - [Java and C](#sec-3-3)
- [Assembler](#assembler) - [Assembler](#sec-3-4)
- [LaTeX](#latex) - [LaTeX](#sec-3-5)
- [Markdown](#markdown) - [Markdown](#sec-3-6)
- [Python](#python) - [Python](#sec-3-7)
- [Haskell](#haskell) - [Haskell](#sec-3-8)
- [Matlab](#matlab) - [Matlab](#sec-3-9)
- [Key bindings](#key-bindings) - [Key bindings](#sec-4)
- [License](#license) - [License](#sec-5)
# About<a id="sec-1" name="sec-1"></a> # About<a id="sec-1" name="sec-1"></a>
@ -142,12 +142,19 @@ of a package is installed.
(defun newest-package-installed-p (package) (defun newest-package-installed-p (package)
"Return true if the newest available PACKAGE is installed." "Return true if the newest available PACKAGE is installed."
(when (package-installed-p package) (when (package-installed-p package)
(let* ((local-pkg-desc (or (assq package package-alist) (let* ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr))
(assq package package--builtins))) (builtin-version (assq package package--builtin-versions))
(local-pkg-desc (assq package package-alist))
(newest-pkg-desc (assq package package-archive-contents))) (newest-pkg-desc (assq package package-archive-contents)))
(and local-pkg-desc newest-pkg-desc (cond ((and local-pkg-desc newest-pkg-desc)
(version-list-= (package-desc-vers (cdr local-pkg-desc)) (version-list-= (package-desc-version
(package-desc-vers (cdr newest-pkg-desc))))))) (funcall get-desc local-pkg-desc))
(package-desc-version
(funcall get-desc newest-pkg-desc))))
((and builtin-version newest-pkg-desc)
(version-list-= builtin-version
(package-desc-version
(funcall get-desc newest-pkg-desc))))))))
``` ```
Let's write a function to install a package if it is not installed or Let's write a function to install a package if it is not installed or
@ -159,13 +166,12 @@ in handy.
"Unless the newest available version of PACKAGE is installed "Unless the newest available version of PACKAGE is installed
PACKAGE is installed and the current version is deleted." PACKAGE is installed and the current version is deleted."
(unless (newest-package-installed-p package) (unless (newest-package-installed-p package)
(let ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr)) (let ((pkg-desc (assq package package-alist)))
(pkg-desc (assq package package-alist)))
(when pkg-desc (when pkg-desc
(if (version< emacs-version "24.4") (if (version< emacs-version "24.4")
(package-delete (symbol-name package) (package-delete (symbol-name package)
(package-version-join (package-version-join
(package-desc-vers (get-desc pkg-desc)))) (package-desc-vers (cdr pkg-desc))))
(package-delete pkg-desc))) (package-delete pkg-desc)))
(and (assq package package-archive-contents) (and (assq package package-archive-contents)
(package-install package))))) (package-install package)))))

22
init.el
View File

@ -58,12 +58,19 @@ tangled, and the tangled file is compiled."
(defun newest-package-installed-p (package) (defun newest-package-installed-p (package)
"Return true if the newest available PACKAGE is installed." "Return true if the newest available PACKAGE is installed."
(when (package-installed-p package) (when (package-installed-p package)
(let* ((local-pkg-desc (or (assq package package-alist) (let* ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr))
(assq package package--builtins))) (builtin-version (assq package package--builtin-versions))
(local-pkg-desc (assq package package-alist))
(newest-pkg-desc (assq package package-archive-contents))) (newest-pkg-desc (assq package package-archive-contents)))
(and local-pkg-desc newest-pkg-desc (cond ((and local-pkg-desc newest-pkg-desc)
(version-list-= (package-desc-vers (cdr local-pkg-desc)) (version-list-= (package-desc-version
(package-desc-vers (cdr newest-pkg-desc))))))) (funcall get-desc local-pkg-desc))
(package-desc-version
(funcall get-desc newest-pkg-desc))))
((and builtin-version newest-pkg-desc)
(version-list-= builtin-version
(package-desc-version
(funcall get-desc newest-pkg-desc))))))))
;; Let's write a function to install a package if it is not installed or ;; Let's write a function to install a package if it is not installed or
;; upgrades it if a new version has been released. Here our predicate comes ;; upgrades it if a new version has been released. Here our predicate comes
@ -73,13 +80,12 @@ tangled, and the tangled file is compiled."
"Unless the newest available version of PACKAGE is installed "Unless the newest available version of PACKAGE is installed
PACKAGE is installed and the current version is deleted." PACKAGE is installed and the current version is deleted."
(unless (newest-package-installed-p package) (unless (newest-package-installed-p package)
(let ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr)) (let ((pkg-desc (assq package package-alist)))
(pkg-desc (assq package package-alist)))
(when pkg-desc (when pkg-desc
(if (version< emacs-version "24.4") (if (version< emacs-version "24.4")
(package-delete (symbol-name package) (package-delete (symbol-name package)
(package-version-join (package-version-join
(package-desc-vers (get-desc pkg-desc)))) (package-desc-vers (cdr pkg-desc))))
(package-delete pkg-desc))) (package-delete pkg-desc)))
(and (assq package package-archive-contents) (and (assq package package-archive-contents)
(package-install package))))) (package-install package)))))

View File

@ -111,12 +111,19 @@
(defun newest-package-installed-p (package) (defun newest-package-installed-p (package)
"Return true if the newest available PACKAGE is installed." "Return true if the newest available PACKAGE is installed."
(when (package-installed-p package) (when (package-installed-p package)
(let* ((local-pkg-desc (or (assq package package-alist) (let* ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr))
(assq package package--builtins))) (builtin-version (assq package package--builtin-versions))
(local-pkg-desc (assq package package-alist))
(newest-pkg-desc (assq package package-archive-contents))) (newest-pkg-desc (assq package package-archive-contents)))
(and local-pkg-desc newest-pkg-desc (cond ((and local-pkg-desc newest-pkg-desc)
(version-list-= (package-desc-vers (cdr local-pkg-desc)) (version-list-= (package-desc-version
(package-desc-vers (cdr newest-pkg-desc))))))) (funcall get-desc local-pkg-desc))
(package-desc-version
(funcall get-desc newest-pkg-desc))))
((and builtin-version newest-pkg-desc)
(version-list-= builtin-version
(package-desc-version
(funcall get-desc newest-pkg-desc))))))))
#+END_SRC #+END_SRC
Let's write a function to install a package if it is not installed or Let's write a function to install a package if it is not installed or
@ -128,13 +135,12 @@
"Unless the newest available version of PACKAGE is installed "Unless the newest available version of PACKAGE is installed
PACKAGE is installed and the current version is deleted." PACKAGE is installed and the current version is deleted."
(unless (newest-package-installed-p package) (unless (newest-package-installed-p package)
(let ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr)) (let ((pkg-desc (assq package package-alist)))
(pkg-desc (assq package package-alist)))
(when pkg-desc (when pkg-desc
(if (version< emacs-version "24.4") (if (version< emacs-version "24.4")
(package-delete (symbol-name package) (package-delete (symbol-name package)
(package-version-join (package-version-join
(package-desc-vers (get-desc pkg-desc)))) (package-desc-vers (cdr pkg-desc))))
(package-delete pkg-desc))) (package-delete pkg-desc)))
(and (assq package package-archive-contents) (and (assq package package-archive-contents)
(package-install package))))) (package-install package)))))