[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/so-long-updates 781ab5d 6/6: Support loading so-long.el on top o
From: |
Phil |
Subject: |
scratch/so-long-updates 781ab5d 6/6: Support loading so-long.el on top of an earlier version |
Date: |
Sat, 2 Nov 2019 08:23:42 -0400 (EDT) |
branch: scratch/so-long-updates
commit 781ab5d555c73bded81ff4a72a5194da4def52f8
Author: Phil Sainty <address@hidden>
Commit: Phil Sainty <address@hidden>
Support loading so-long.el on top of an earlier version
* so-long.el (so-long-version, so-long--latest-version): New variables.
This enables users to safely load version 1.0 of so-long.el on top of
an earlier version, as well as making provisions for doing likewise
following any incompatible changes arising in future versions.
---
lisp/so-long.el | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/lisp/so-long.el b/lisp/so-long.el
index 355c5c3..8f5e234 100644
--- a/lisp/so-long.el
+++ b/lisp/so-long.el
@@ -411,6 +411,9 @@
(add-to-list 'customize-package-emacs-version-alist
'(so-long ("1.0" . "27.1")))
+(set (defvar so-long--latest-version)
+ "1.0") ;; Keep this up to date in the code.
+
(declare-function longlines-mode "longlines")
(defvar longlines-mode)
@@ -1818,6 +1821,54 @@ If it appears in `%s', you should remove it."
(cdr hookfunc)))
(make-obsolete (car hookfunc) nil "so-long.el version 1.0")))
+;; Live upgrades, for when a newer version is loaded over an older one.
+;;
+;; If `so-long-version' was already bound then that tells us which version we
+;; should upgrade from. If `so-long-version' is unbound then most likely there
+;; was no older version loaded; however, prior to version 1.0 `so-long-version'
+;; was not defined at all, and so we also need to detect that scenario, which
+;; we can do by testing for the presence of a symbol which was removed in 1.0.
+;;
+;; The variable `so-long-mode-enabled' covers versions 0.5 - 0.7.6, which is
+;; every pre-1.0 release using the name "so-long.el".
+(defvar so-long-version (if (boundp 'so-long-mode-enabled)
+ "0.5" ;; >= 0.5 and < 1.0
+ so-long--latest-version)
+ "The loaded version of so-long.el.")
+
+;; Version-specific updates.
+(when (version< so-long-version so-long--latest-version)
+ ;; Perform each update in sequence, as necessary.
+ ;; Update to version 1.0 from earlier versions:
+ (when (version< so-long-version "1.0")
+ (remove-hook 'change-major-mode-hook 'so-long-change-major-mode)
+ (require 'advice)
+ (when (ad-find-advice 'hack-local-variables 'after
'so-long--file-local-mode)
+ (ad-remove-advice 'hack-local-variables 'after 'so-long--file-local-mode)
+ (ad-activate 'hack-local-variables))
+ (when (ad-find-advice 'set-auto-mode 'around 'so-long--set-auto-mode)
+ (ad-remove-advice 'set-auto-mode 'around 'so-long--set-auto-mode)
+ (ad-activate 'set-auto-mode))
+ (when (boundp 'so-long-mode-map)
+ (define-key so-long-mode-map [remap so-long-mode-revert]
#'so-long-revert))
+ (dolist (var '(so-long-mode--inhibited
+ so-long-original-mode))
+ (makunbound var))
+ (dolist (func '(so-long-change-major-mode
+ so-long-check-header-modes
+ so-long-line-detected-p))
+ (fmakunbound func))
+ (defvar so-long-mode-enabled)
+ (when so-long-mode-enabled
+ (unless global-so-long-mode
+ (global-so-long-mode 1)))
+ (makunbound 'so-long-mode-enabled))
+ ;; Update to version 1.N:
+ ;; (when (version< so-long-version "1.N") ...)
+ ;;
+ ;; All updates completed.
+ (setq so-long-version so-long--latest-version))
+
(provide 'so-long)
- branch scratch/so-long-updates created (now 781ab5d), Phil, 2019/11/02
- scratch/so-long-updates 0c61fe0 1/6: ; Documentation and spelling, Phil, 2019/11/02
- scratch/so-long-updates 89157bc 4/6: * lisp/so-long.el (so-long-unload-function): Improved feature unload, Phil, 2019/11/02
- scratch/so-long-updates 6712edc 3/6: ; * lisp/so-long.el (so-long-predicate): Custom type consistency, Phil, 2019/11/02
- scratch/so-long-updates 978f37f 5/6: Backwards-compatibility function definitions for so-long.el, Phil, 2019/11/02
- scratch/so-long-updates 781ab5d 6/6: Support loading so-long.el on top of an earlier version,
Phil <=
- scratch/so-long-updates 571b50c 2/6: Defer triggering `so-long' until the buffer is displayed, Phil, 2019/11/02