[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 088aae0 09/14: Support live updates from earlier versions
From: |
Phil |
Subject: |
[elpa] master 088aae0 09/14: Support live updates from earlier versions |
Date: |
Sat, 11 Jul 2020 00:57:56 -0400 (EDT) |
branch: master
commit 088aae04247df7a9e48221864955cab9f5c058aa
Author: Phil Sainty <psainty@orcon.net.nz>
Commit: Phil Sainty <psainty@orcon.net.nz>
Support live updates from earlier versions
---
delight.el | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/delight.el b/delight.el
index a4a4b5b..3d44253 100644
--- a/delight.el
+++ b/delight.el
@@ -94,6 +94,8 @@
;;; Change Log:
;;
;; 1.7 (2020-07-11)
+;; - Add `delight-version'.
+;; - Support loading newer versions over the top of older versions.
;; - Rename `delighted-modes' to `delight-delighted-modes'.
;; - Rename `delight--inhibit' to `delight-mode-name-inhibit', and
;; document its uses.
@@ -120,6 +122,35 @@
(eval-when-compile (require 'cl-lib))
(require 'nadvice)
+(defconst delight--latest-version "1.7")
+
+;; Check whether a newer version is being loaded over an older one.
+;;
+;; If `delight-version' has an existing value which is less than
+;; `delight--latest-version', then an earlier version was already loaded,
+;; and we must perform any necessary updates (see "Live upgrades" below).
+;;
+;; If `delight-version' is unbound then most likely there was no older
+;; version loaded; however, prior to version 1.7 `delight-version' was not
+;; defined at all, and so we need to detect that scenario too.
+(defvar delight-version
+ (if (not (featurep 'delight))
+ ;; The normal case: delight was not already loaded.
+ delight--latest-version
+ ;; Otherwise delight was loaded. However, as this initial value code is
+ ;; being evaluated, the loaded version had not defined `delight-version'.
+ (cond
+ ;; In 1.5 and earlier, `delight--format-mode-line' didn't exist.
+ ;; (Earlier versions can be treated as 1.5 for upgrade purposes.)
+ ((not (fboundp 'delight--format-mode-line))
+ "1.5")
+ ;; In 1.6 `delight--inhibit' wasn't an alias.
+ ((eq (indirect-variable 'delight--inhibit) 'delight--inhibit)
+ "1.6")
+ ;; If we get to here, we've probably used `eval-defun' on this defvar.
+ (t delight--latest-version)))
+ "The loaded version of delight.el.")
+
(define-obsolete-variable-alias 'delighted-modes
'delight-delighted-modes "delight-1.7")
@@ -275,5 +306,24 @@ Delighted major modes should exhibit their original
`mode-name' when
(advice-add 'format-mode-line :around #'delight--format-mode-line)
+;; Live upgrades, for when a newer version is loaded over an older one.
+(when (version< delight-version delight--latest-version)
+ ;; Perform each update in sequence, as necessary.
+ ;; Update to version 1.6 from earlier versions:
+ (when (version< delight-version "1.6")
+ ;; Old advice was replaced by nadvice.
+ (eval-and-compile (require 'advice)) ;; Both macros and functions.
+ (declare-function ad-find-advice "advice")
+ (declare-function ad-remove-advice "advice")
+ (declare-function ad-activate "advice")
+ (when (ad-find-advice 'format-mode-line 'around 'delighted-modes-are-glum)
+ (ad-remove-advice 'format-mode-line 'around 'delighted-modes-are-glum)
+ (ad-activate 'format-mode-line)))
+ ;; Update to version 1.N:
+ ;; (when (version< delight-version "1.N") ...)
+ ;;
+ ;; All updates completed.
+ (setq delight-version delight--latest-version))
+
(provide 'delight)
;;; delight.el ends here
- [elpa] master updated (b8c9fbb -> 2a774d1), Phil, 2020/07/11
- [elpa] master 05ef4d7 03/14: Fix quote character in `delight' docstring in Emacs 25+, Phil, 2020/07/11
- [elpa] master d2cc2fc 02/14: Use GNU ELPA version number formatting, Phil, 2020/07/11
- [elpa] master e3bd4c2 01/14: * delight.el: Fix copyright, Phil, 2020/07/11
- [elpa] master 8ec8a5b 05/14: Use cl-lib, nadvice, and lexical-binding, Phil, 2020/07/11
- [elpa] master 6d4a5aa 06/14: Use double-spaced sentence formatting, Phil, 2020/07/11
- [elpa] master 17cce66 04/14: Re-format the Change Log, Phil, 2020/07/11
- [elpa] master a763ec1 07/14: Rename `delight--inhibit' to `delight-mode-name-inhibit', Phil, 2020/07/11
- [elpa] master da63492 08/14: Rename `delighted-modes' to `delight-delighted-modes', Phil, 2020/07/11
- [elpa] master 088aae0 09/14: Support live updates from earlier versions,
Phil <=
- [elpa] master 26dab6b 10/14: Support `unload-feature', Phil, 2020/07/11
- [elpa] master 989eed2 11/14: Add to after-change-major-mode-hook at load time, Phil, 2020/07/11
- [elpa] master 2a774d1 14/14: Merge commit '5a0cd5ccb650d7bba1c1ea02cf67b71d7cfa6e9a' from delight, Phil, 2020/07/11
- [elpa] master 5a0cd5c 12/14: Documentation, Phil, 2020/07/11
- [elpa] master a1b7e94 13/14: * externals-list: Use https for "delight" subtree URL, Phil, 2020/07/11