[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/so-long-updates 622f53f 6/7: Support loading so-long.el on top o
From: |
Phil |
Subject: |
scratch/so-long-updates 622f53f 6/7: Support loading so-long.el on top of an earlier version |
Date: |
Sat, 9 Nov 2019 03:23:30 -0500 (EST) |
branch: scratch/so-long-updates
commit 622f53f7d3ce57c854858d9b516bdc54bbad3307
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 a96f2af..326d8fe 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 d696338), Phil, 2019/11/09
- scratch/so-long-updates 486fb50 3/7: ; * lisp/so-long.el (so-long-predicate): Custom type consistency, Phil, 2019/11/09
- scratch/so-long-updates d1ea18e 4/7: * lisp/so-long.el (so-long-unload-function): Improved feature unload, Phil, 2019/11/09
- scratch/so-long-updates b5f3225 5/7: Backwards-compatibility function definitions for so-long.el, Phil, 2019/11/09
- scratch/so-long-updates 622f53f 6/7: Support loading so-long.el on top of an earlier version,
Phil <=
- scratch/so-long-updates 929573b 1/7: ; Documentation and spelling, Phil, 2019/11/09
- scratch/so-long-updates d696338 7/7: Make so-long disable flymake, flyspell, flycheck, Phil, 2019/11/09
- scratch/so-long-updates a017364 2/7: Defer triggering `so-long' until the buffer is displayed, Phil, 2019/11/09