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

24
init.el
View File

@ -58,12 +58,19 @@ tangled, and the tangled file is compiled."
(defun newest-package-installed-p (package)
"Return true if the newest available PACKAGE is installed."
(when (package-installed-p package)
(let* ((local-pkg-desc (or (assq package package-alist)
(assq package package--builtins)))
(newest-pkg-desc (assq package package-archive-contents)))
(and local-pkg-desc newest-pkg-desc
(version-list-= (package-desc-vers (cdr local-pkg-desc))
(package-desc-vers (cdr newest-pkg-desc)))))))
(let* ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr))
(builtin-version (assq package package--builtin-versions))
(local-pkg-desc (assq package package-alist))
(newest-pkg-desc (assq package package-archive-contents)))
(cond ((and local-pkg-desc newest-pkg-desc)
(version-list-= (package-desc-version
(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
;; 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
PACKAGE is installed and the current version is deleted."
(unless (newest-package-installed-p package)
(let ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr))
(pkg-desc (assq package package-alist)))
(let ((pkg-desc (assq package package-alist)))
(when pkg-desc
(if (version< emacs-version "24.4")
(package-delete (symbol-name package)
(package-version-join
(package-desc-vers (get-desc pkg-desc))))
(package-desc-vers (cdr pkg-desc))))
(package-delete pkg-desc)))
(and (assq package package-archive-contents)
(package-install package)))))

View File

@ -111,12 +111,19 @@
(defun newest-package-installed-p (package)
"Return true if the newest available PACKAGE is installed."
(when (package-installed-p package)
(let* ((local-pkg-desc (or (assq package package-alist)
(assq package package--builtins)))
(newest-pkg-desc (assq package package-archive-contents)))
(and local-pkg-desc newest-pkg-desc
(version-list-= (package-desc-vers (cdr local-pkg-desc))
(package-desc-vers (cdr newest-pkg-desc)))))))
(let* ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr))
(builtin-version (assq package package--builtin-versions))
(local-pkg-desc (assq package package-alist))
(newest-pkg-desc (assq package package-archive-contents)))
(cond ((and local-pkg-desc newest-pkg-desc)
(version-list-= (package-desc-version
(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
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
PACKAGE is installed and the current version is deleted."
(unless (newest-package-installed-p package)
(let ((get-desc (if (version< emacs-version "24.4") 'cdr 'cadr))
(pkg-desc (assq package package-alist)))
(let ((pkg-desc (assq package package-alist)))
(when pkg-desc
(if (version< emacs-version "24.4")
(package-delete (symbol-name package)
(package-version-join
(package-desc-vers (get-desc pkg-desc))))
(package-desc-vers (cdr pkg-desc))))
(package-delete pkg-desc)))
(and (assq package package-archive-contents)
(package-install package)))))