From: Stefan Kangas Date: Wed, 3 Mar 2021 18:54:37 +0000 (+0100) Subject: Make inversion.el obsolete (Bug#46841) X-Git-Tag: emacs-28.0.90~3456 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=356636c6a1ebba3e95d0e6609ae0401992008ccf;p=emacs.git Make inversion.el obsolete (Bug#46841) * lisp/cedet/inversion.el: * test/lisp/cedet/inversion-tests.el: Move from here... * lisp/obsolete/inversion.el: * test/lisp/obsolete/inversion-tests.el: ...to here. * lisp/cedet/cedet.el (cedet-version): Make obsolete. * lisp/cedet/cedet-cscope.el (cedet-cscope-version-check): * lisp/cedet/cedet-global.el (cedet-gnu-global-version-check): * lisp/cedet/cedet-idutils.el (cedet-idutils-version-check): * lisp/cedet/ede/make.el (ede-make-check-version): Use 'version<' instead of 'inversion-check-version'. * lisp/cedet/semantic/db-file.el (semanticdb-load-database): Don't use 'inversion-test'. * lisp/cedet/semantic/ede-grammar.el (ede-proj-makefile-insert-variables): Don't add inversion to loadpath. * lisp/speedbar.el: Remove stale comment. --- diff --git a/etc/NEWS b/etc/NEWS index 73f136cfa7a..6babbbf5a7b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2259,7 +2259,10 @@ This is no longer supported, and setting this variable has no effect. Use macro 'with-current-buffer-window' with action alist entry 'body-function'. --- -** The metamail.el library is now marked obsolete. +** The inversion.el library is now obsolete. + +--- +** The metamail.el library is now obsolete. --- ** Some obsolete variable and function aliases in dbus.el have been removed. diff --git a/lisp/cedet/cedet-cscope.el b/lisp/cedet/cedet-cscope.el index 75a69db0a8c..4d4a9f78d5d 100644 --- a/lisp/cedet/cedet-cscope.el +++ b/lisp/cedet/cedet-cscope.el @@ -26,8 +26,6 @@ ;;; Code: -(declare-function inversion-check-version "inversion") - (defvar cedet-cscope-min-version "15.7" "Minimum version of CScope required.") @@ -139,7 +137,6 @@ If optional programmatic argument NOERROR is non-nil, then instead of throwing an error if CScope isn't available, return nil." (interactive) - (require 'inversion) (let ((b (condition-case nil (cedet-cscope-call (list "-V")) (error nil))) @@ -153,7 +150,7 @@ return nil." (goto-char (point-min)) (re-search-forward "cscope: version \\([0-9.]+\\)" nil t) (setq rev (match-string 1)) - (if (inversion-check-version rev nil cedet-cscope-min-version) + (if (version< rev cedet-cscope-min-version) (if noerror nil (error "Version of CScope is %s. Need at least %s" diff --git a/lisp/cedet/cedet-global.el b/lisp/cedet/cedet-global.el index 5878ec1f485..77b44744399 100644 --- a/lisp/cedet/cedet-global.el +++ b/lisp/cedet/cedet-global.el @@ -24,8 +24,6 @@ ;; ;; Basic support for calling GNU Global, and testing version numbers. -(declare-function inversion-check-version "inversion") - (defvar cedet-global-min-version "5.0" "Minimum version of GNU Global required.") @@ -143,7 +141,6 @@ If optional programmatic argument NOERROR is non-nil, then instead of throwing an error if Global isn't available, return nil." (interactive) - (require 'inversion) (let ((b (condition-case nil (cedet-gnu-global-call (list "--version")) (error nil))) @@ -157,7 +154,7 @@ return nil." (goto-char (point-min)) (re-search-forward "(?GNU GLOBAL)? \\([0-9.]+\\)" nil t) (setq rev (match-string 1)) - (if (inversion-check-version rev nil cedet-global-min-version) + (if (version< rev cedet-global-min-version) (if noerror nil (error "Version of GNU Global is %s. Need at least %s" diff --git a/lisp/cedet/cedet-idutils.el b/lisp/cedet/cedet-idutils.el index fc5e05af88e..3e3d6a5e949 100644 --- a/lisp/cedet/cedet-idutils.el +++ b/lisp/cedet/cedet-idutils.el @@ -29,8 +29,6 @@ ;;; Code: -(declare-function inversion-check-version "inversion") - (defvar cedet-idutils-min-version "4.0" "Minimum version of ID Utils required.") @@ -167,7 +165,6 @@ If optional programmatic argument NOERROR is non-nil, then instead of throwing an error if Global isn't available, return nil." (interactive) - (require 'inversion) (let ((b (condition-case nil (cedet-idutils-fnid-call (list "--version")) (error nil))) @@ -182,7 +179,7 @@ return nil." (if (re-search-forward "fnid - \\([0-9.]+\\)" nil t) (setq rev (match-string 1)) (setq rev "0")) - (if (inversion-check-version rev nil cedet-idutils-min-version) + (if (version< rev cedet-idutils-min-version) (if noerror nil (error "Version of ID Utils is %s. Need at least %s" diff --git a/lisp/cedet/cedet.el b/lisp/cedet/cedet.el index caaec473a2c..5d98a1939d7 100644 --- a/lisp/cedet/cedet.el +++ b/lisp/cedet/cedet.el @@ -85,6 +85,7 @@ for the specified PACKAGE. LOADED VERSION is the version of PACKAGE currently loaded in Emacs memory and (presumably) running in this Emacs instance. Value is X if the package has not been loaded." + (declare (obsolete emacs-version "28.1")) (interactive) (require 'inversion) (with-output-to-temp-buffer "*CEDET*" diff --git a/lisp/cedet/ede/make.el b/lisp/cedet/ede/make.el index 4f86558c626..d9811ce52f9 100644 --- a/lisp/cedet/ede/make.el +++ b/lisp/cedet/ede/make.el @@ -30,8 +30,6 @@ ;;; Code: -(declare-function inversion-check-version "inversion") - (defsubst ede--find-executable (exec) "Return an expanded file name for a program EXEC on the exec path." (declare (obsolete locate-file "28.1")) @@ -60,8 +58,7 @@ If NOERROR is nil, then throw an error on failure. Return t otherwise." (let ((b (get-buffer-create "*EDE Make Version*")) (cd default-directory) (rev nil) - (ans nil) - ) + (ans nil)) (with-current-buffer b ;; Setup, and execute make. (setq default-directory cd) @@ -70,18 +67,18 @@ If NOERROR is nil, then throw an error on failure. Return t otherwise." "--version") ;; Check the buffer for the string (goto-char (point-min)) - (when (looking-at "GNU Make\\(?: version\\)? \\([0-9][^,]+\\),") + (when (looking-at "GNU Make\\(?: version\\)? \\([0-9][^,[:space:]]+\\),?") (setq rev (match-string 1)) - (require 'inversion) - (setq ans (not (inversion-check-version rev nil ede-make-min-version)))) + (setq ans (not (version< rev ede-make-min-version)))) ;; Answer reporting. (when (and (called-interactively-p 'interactive) ans) (message "GNU Make version %s. Good enough for CEDET." rev)) (when (and (not noerror) (not ans)) - (error "EDE requires GNU Make version %s or later. Configure `ede-make-command' to fix" - ede-make-min-version)) + (error "EDE requires GNU Make version %s or later (found %s). Configure `ede-make-command' to fix" + ede-make-min-version + rev)) ans))) (provide 'ede/make) diff --git a/lisp/cedet/inversion.el b/lisp/cedet/inversion.el deleted file mode 100644 index 2ef7e0df961..00000000000 --- a/lisp/cedet/inversion.el +++ /dev/null @@ -1,554 +0,0 @@ -;;; inversion.el --- When you need something in version XX.XX - -;;; Copyright (C) 2002-2003, 2005-2021 Free Software Foundation, Inc. - -;; Author: Eric M. Ludlam -;; Version: 1.3 -;; Keywords: OO, lisp - -;; This file is part of GNU Emacs. - -;; GNU Emacs is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; GNU Emacs is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . - -;;; Commentary: -;; -;; Keeping track of rapidly developing software is a tough thing to -;; do, especially if you want to have co-dependent packages which all -;; move at different rates. -;; -;; This library provides a framework for specifying version numbers -;; and (as side effect) have a flexible way of getting a desired feature set. -;; -;; If you would like to use this package to satisfy dependency replace this: -;; -;; (require 'spiffy) -;; -;; with this: -;; -;; (require 'inversion) -;; (inversion-require 'spiffy "1.0") -;; -;; If you feel the need to not throw errors, you can do this instead: -;; -;; (let ((err (inversion-test 'spiffy "1.0"))) -;; (if err (your-stuff-here))) -;; -;; If you new package (2.0) needs to make sure a load file from your -;; package is compatible, use this test: -;; -;; (if (not (inversion-reverse-test 'spiffy version-from-file)) -;; ;; Everything ok -;; (do stuff) -;; ;; Out of date -;; (import-old-code)) -;; -;; If you would like to make inversion optional, do this: -;; -;; (or (require 'inversion nil t) -;; (defun inversion-test (p v) -;; (string= v (symbol-value -;; (intern-soft (concat (symbol-string p) "-version")))))) -;; -;; Or modify to specify `inversion-require' instead. -;; -;; TODO: -;; Offer to download newer versions of a package. - -;;; History: -;; -;; Sept 3, 2002: First general publication. - -;;; Code: - -(defvar inversion-version "1.3" - "Current version of InVersion.") - -(defvar inversion-incompatible-version "0.1alpha1" - "An earlier release which is incompatible with this release.") - -(defconst inversion-decoders - '( - (alpha "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]*\\)\\s-*\\.?alpha\\([0-9]+\\)?$" 4) - (beta "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]*\\)\\s-*\\.?beta\\([0-9]+\\)?$" 4) - (beta "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]*\\)\\s-*\\.?(beta\\([0-9]+\\)?)$" 4) - (beta "^[^/]+/\\w+--\\w+--\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)--patch-\\([0-9]+\\)" 4) - (beta "^\\w+: v\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)-\\([0-9]+\\)-\\(.*\\)" 5) - (prerelease "^\\([0-9]+\\)\\.\\([0-9]+\\)\\s-*\\.?pre\\([0-9]+\\)?$" 3) - (full "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?$" 3) - (fullsingle "^\\([0-9]+\\)$" 1) - (patch "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?\\s-*(patch \\([0-9]+\\))" 4) - (point "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)$" 3) - (point "^\\w+: v\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)-\\(0\\)-\\(.*\\)" 5) - (build "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\).\\([0-9]+\\)$" 4) - (full "^[^/]+/\\w+--\\w+--\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)--version-\\([0-9]+\\)" 4) - (full "^\\w+: v\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" 5) - ) - "List of decoders for version strings. -Each decoder is of the form: - - ( RELEASE-TYPE REGEXP MAX ) - -RELEASE-TYPE is a symbol specifying something like `beta' or `alpha'. -REGEXP is the regular expression to match a version string. -MAX is the maximum number of match-numbers in the release number. -Decoders must be ordered to decode least stable versions before the -more stable ones.") - -;;; Version Checking -;; -(defun inversion-decode-version (version-string) - "Decode VERSION-STRING into an encoded list. -Return value is of the form: - (RELEASE MAJOR MINOR ...) -where RELEASE is a symbol such as `full', or `beta'." - (let ((decoders inversion-decoders) - (result nil)) - (while (and decoders (not result)) - (if (string-match (nth 1 (car decoders)) version-string) - (let ((ver nil) - (num-left (nth 2 (car decoders))) - (count 1)) - (while (<= count num-left) - (setq ver (cons - (if (match-beginning count) - (string-to-number - (substring version-string - (match-beginning count) - (match-end count))) - 1) - ver) - count (1+ count))) - (setq result (cons (caar decoders) (nreverse ver)))) - (setq decoders (cdr decoders)))) - result)) - -(defun inversion-package-version (package) - "Return the decoded version for PACKAGE." - (let ((ver (symbol-value - (intern-soft - (concat (symbol-name package) - "-version")))) - (code nil)) - (unless ver - (error "Package %S does not define %S-version" package package)) - ;; Decode the code - (setq code (inversion-decode-version ver)) - (unless code - (error "%S-version value (%s) cannot be decoded" package ver)) - code)) - -(defun inversion-package-incompatibility-version (package) - "Return the decoded incompatibility version for PACKAGE. -The incompatibility version is specified by the programmer of -a package when a package is not backward compatible. It is -not an indication of new features or bug fixes." - (let ((ver (symbol-value - (intern-soft - (concat (symbol-name package) - "-incompatible-version"))))) - (if (not ver) - nil - ;; Decode the code - (inversion-decode-version ver)))) - -(defun inversion-recode (code) - "Convert CODE into a string." - (let ((r (nth 0 code)) ; release-type - (n (nth 1 code)) ; main number - (i (nth 2 code)) ; first increment - (p (nth 3 code))) ; second increment - (cond - ((eq r 'full) - (setq r "" p "")) - ((eq r 'point) - (setq r "."))) - (format "%s.%s%s%s" n i r p))) - -(defun inversion-release-to-number (release-symbol) - "Convert RELEASE-SYMBOL into a number." - (let* ((ra (assoc release-symbol inversion-decoders)) - (rn (- (length inversion-decoders) - (length (member ra inversion-decoders))))) - rn)) - -(defun inversion-= (ver1 ver2) - "Return non-nil if VER1 is equal to VER2." - (equal ver1 ver2)) - -(defun inversion-< (ver1 ver2) - "Return non-nil if VER1 is less than VER2." - (let ((v1-0 (inversion-release-to-number (nth 0 ver1))) - (v1-1 (nth 1 ver1)) - (v1-2 (nth 2 ver1)) - (v1-3 (nth 3 ver1)) - (v1-4 (nth 4 ver1)) - ;; v2 - (v2-0 (inversion-release-to-number (nth 0 ver2))) - (v2-1 (nth 1 ver2)) - (v2-2 (nth 2 ver2)) - (v2-3 (nth 3 ver2)) - (v2-4 (nth 4 ver2)) - ) - - (cond ((and (equal (list v1-1 v1-2 v1-3 v1-4) - (list v2-1 v2-2 v2-3 v2-4)) - v1-0 v2-0) - (< v1-0 v2-0)) - ((and (equal v1-1 v2-1) - (equal v1-2 v2-2) - (equal v1-3 v2-3) - v1-4 v2-4) ; all or nothing if elt - is = - (< v1-4 v2-4)) - ((and (equal v1-1 v2-1) - (equal v1-2 v2-2) - v1-3 v2-3) ; all or nothing if elt - is = - (< v1-3 v2-3)) - ((and (equal v1-1 v2-1) - v1-2 v2-2) - (< v1-2 v2-2)) - ((and v1-1 v2-1) - (< v1-1 v2-1)) - ))) - -(defun inversion-check-version (version incompatible-version - minimum &rest reserved) - "Check that a given version meets the minimum requirement. -VERSION, INCOMPATIBLE-VERSION and MINIMUM are of similar format to -return entries of `inversion-decode-version', or a classic version -string. INCOMPATIBLE-VERSION can be nil. -RESERVED arguments are kept for a later use. -Return: -- nil if everything is ok. -- `outdated' if VERSION is less than MINIMUM. -- `incompatible' if VERSION is not backward compatible with MINIMUM. -- t if the check failed." - (let ((code (if (stringp version) - (inversion-decode-version version) - version)) - (req (if (stringp minimum) - (inversion-decode-version minimum) - minimum)) - ) - ;; Perform a test. - (cond - ((inversion-= code req) - ;; Same version.. Yay! - nil) - ((inversion-< code req) - ;; Version is too old! - 'outdated) - ((inversion-< req code) - ;; Newer is installed. What to do? - (let ((incompatible - (if (stringp incompatible-version) - (inversion-decode-version incompatible-version) - incompatible-version))) - (cond - ((not incompatible) nil) - ((or (inversion-= req incompatible) - (inversion-< req incompatible)) - ;; The requested version is = or < than what the package - ;; maintainer says is incompatible. - 'incompatible) - ;; Things are ok. - (t nil)))) - ;; Check failed - (t t)))) - -(defun inversion-test (package minimum &rest reserved) - "Test that PACKAGE meets the MINIMUM version requirement. -PACKAGE is a symbol, similar to what is passed to `require'. -MINIMUM is of similar format to return entries of -`inversion-decode-version', or a classic version string. -RESERVED arguments are kept for a later user. -This depends on the symbols `PACKAGE-version' and optionally -`PACKAGE-incompatible-version' being defined in PACKAGE. -Return nil if everything is ok. Return an error string otherwise." - (let ((check (inversion-check-version - (inversion-package-version package) - (inversion-package-incompatibility-version package) - minimum reserved))) - (cond - ((null check) - ;; Same version.. Yay! - nil) - ((eq check 'outdated) - ;; Version is too old! - (format "You need to upgrade package %s to %s" package minimum)) - ((eq check 'incompatible) - ;; Newer is installed but the requested version is = or < than - ;; what the package maintainer says is incompatible, then throw - ;; that error. - (format "Package %s version is not backward compatible with %s" - package minimum)) - ;; Check failed - (t "Inversion version check failed.")))) - -(defun inversion-reverse-test (package oldversion &rest reserved) - "Test that PACKAGE at OLDVERSION is still compatible. -If something like a save file is loaded at OLDVERSION, this -test will identify if OLDVERSION is compatible with the current version -of PACKAGE. -PACKAGE is a symbol, similar to what is passed to `require'. -OLDVERSION is of similar format to return entries of -`inversion-decode-version', or a classic version string. -RESERVED arguments are kept for a later user. -This depends on the symbols `PACKAGE-version' and optionally -`PACKAGE-incompatible-version' being defined in PACKAGE. -Return nil if everything is ok. Return an error string otherwise." - (let ((check (inversion-check-version - (inversion-package-version package) - (inversion-package-incompatibility-version package) - oldversion reserved))) - (cond - ((null check) - ;; Same version.. Yay! - nil) - ((eq check 'outdated) - ;; Version is too old! - (format "Package %s version %s is not compatible with current version" - package oldversion)) - ((eq check 'incompatible) - ;; Newer is installed but the requested version is = or < than - ;; what the package maintainer says is incompatible, then throw - ;; that error. - (format "Package %s version is not backward compatible with %s" - package oldversion)) - ;; Check failed - (t "Inversion version check failed.")))) - -(defun inversion-require (package version &optional file directory - &rest reserved) - "Declare that you need PACKAGE with at least VERSION. -PACKAGE might be found in FILE. (See `require'.) -Throws an error if VERSION is incompatible with what is installed. -Optional argument DIRECTORY is a location where new versions of -this tool can be located. If there is a versioning problem and -DIRECTORY is provided, inversion will offer to download the file. -Optional argument RESERVED is saved for later use." - (require package file) - (let ((err (inversion-test package version))) - (when err - (if directory - (inversion-download-package-ask err package directory version) - (error err))) - ;; Return the package symbol that was required. - package)) - -;;;###autoload -(defun inversion-require-emacs (emacs-ver xemacs-ver sxemacs-ver) - "Declare that you need either EMACS-VER, XEMACS-VER or SXEMACS-ver. -Only checks one based on which kind of Emacs is being run. - -This function is obsolete; do this instead: - (when (version<= \"28.1\" emacs-version) ...)" - (declare (obsolete nil "28.1")) - (let ((err (inversion-test 'emacs - (cond ((featurep 'sxemacs) - sxemacs-ver) - ((featurep 'xemacs) - xemacs-ver) - (t - emacs-ver))))) - (if err (error err) - ;; Something nice... - t))) - -(defconst inversion-find-data - '("(def\\(var\\|const\\)\\s-+%s-%s\\s-+\"\\([^\"]+\\)" 2) - "Regexp template and match data index of a version string.") - -(defun inversion-find-version (package) - "Search for the version and incompatible version of PACKAGE. -Does not load PACKAGE nor requires that it has been previously loaded. -Search in the directories in `load-path' for a PACKAGE.el library. -Visit the file found and search for the declarations of variables or -constants `PACKAGE-version' and `PACKAGE-incompatible-version'. The -value of these variables must be a version string. - -Return a pair (VERSION-STRING . INCOMPATIBLE-VERSION-STRING) where -INCOMPATIBLE-VERSION-STRING can be nil. -Return nil when VERSION-STRING was not found." - (let* ((file (locate-library (format "%s.el" package) t)) - (tag (car inversion-find-data)) - (idx (nth 1 inversion-find-data)) - version) - (when file - (with-temp-buffer - ;; The 3000 is a bit arbitrary, but should cut down on - ;; fileio as version info usually is at the very top - ;; of a file. After a long commentary could be bad. - (insert-file-contents-literally file nil 0 3000) - (goto-char (point-min)) - (when (re-search-forward (format tag package 'version) nil t) - (setq version (list (match-string idx))) - (goto-char (point-min)) - (when (re-search-forward - (format tag package 'incompatible-version) nil t) - (setcdr version (match-string idx)))))) - version)) - -(defun inversion-add-to-load-path (package minimum - &optional installdir - &rest subdirs) - "Add the PACKAGE path to `load-path' if necessary. -MINIMUM is the minimum version requirement of PACKAGE. -Optional argument INSTALLDIR is the base directory where PACKAGE is -installed. It defaults to `default-directory'/PACKAGE. -SUBDIRS are sub-directories to add to `load-path', following the main -INSTALLDIR path." - (let ((ver (inversion-find-version package))) - ;; If PACKAGE not found or a bad version already in `load-path', - ;; prepend the new PACKAGE path, so it will be loaded first. - (when (or (not ver) - (and - (inversion-check-version (car ver) (cdr ver) minimum) - (message "Outdated %s %s shadowed to meet minimum version %s" - package (car ver) minimum) - t)) - (let* ((default-directory - (or installdir - (expand-file-name (format "./%s" package)))) - subdir) - (when (file-directory-p default-directory) - ;; Add SUBDIRS - (while subdirs - (setq subdir (expand-file-name (car subdirs)) - subdirs (cdr subdirs)) - (when (file-directory-p subdir) - ;;(message "%S added to `load-path'" subdir) - (add-to-list 'load-path subdir))) - ;; Add the main path - ;;(message "%S added to `load-path'" default-directory) - (add-to-list 'load-path default-directory)) - ;; We get to this point iff we do not accept or there is no - ;; system file. Let's check the version of what we just - ;; installed... just to be safe. - (let ((newver (inversion-find-version package))) - (if (not newver) - (error "Failed to find version for newly installed %s" - package)) - (if (inversion-check-version (car newver) (cdr newver) minimum) - (error "Outdated %s %s just installed" package (car newver))) - ))))) - -;;; URL and downloading code -;; -(defun inversion-locate-package-files (package directory &optional version) - "Get a list of distributions of PACKAGE from DIRECTORY. -DIRECTORY can be an ange-ftp compatible filename, such as: - \"/ftp@ftp1.sourceforge.net/pub/sourceforge/PACKAGE\" -If it is a URL, wget will be used for download. -Optional argument VERSION will restrict the list of available versions -to the file matching VERSION exactly, or nil." -;;DIRECTORY should also allow a URL: -;; \"http://ftp1.sourceforge.net/PACKAGE\" -;; but then I can get file listings easily. - (if (symbolp package) (setq package (symbol-name package))) - (directory-files directory t - (if version - (concat "^" package "-" version "\\>") - package))) - -(defvar inversion-package-common-tails '( ".tar.gz" - ".tar" - ".zip" - ".gz" - ) - "Common distribution mechanisms for Emacs Lisp packages.") - -(defun inversion-locate-package-files-and-split (package directory &optional version) - "Use `inversion-locate-package-files' to get a list of PACKAGE files. -DIRECTORY is the location where distributions of PACKAGE are. -VERSION is an optional argument specifying a version to restrict to. -The return list is an alist with the version string in the CAR, -and the full path name in the CDR." - (if (symbolp package) (setq package (symbol-name package))) - (let ((f (inversion-locate-package-files package directory version)) - (out nil)) - (while f - (let* ((file (car f)) - (dist (file-name-nondirectory file)) - (tails inversion-package-common-tails) - (verstring nil)) - (while (and tails (not verstring)) - (when (string-match (concat (car tails) "$") dist) - (setq verstring - (substring dist (1+ (length package)) (match-beginning 0)))) - (setq tails (cdr tails))) - (if (not verstring) - (error "Cannot decode version for %s" dist)) - (setq out - (cons - (cons verstring file) - out)) - (setq f (cdr f)))) - out)) - -(defun inversion-download-package-ask (err package directory version) - "Due to ERR, offer to download PACKAGE from DIRECTORY. -The package should have VERSION available for download." - (if (symbolp package) (setq package (symbol-name package))) - (let ((files (inversion-locate-package-files-and-split - package directory version))) - (if (not files) - (error err) - (if (not (y-or-n-p (concat err ": Download update? "))) - (error err) - (let ((dest (read-directory-name (format "Download %s to: " - package) - t))) - (if (> (length files) 1) - (setq files - (list - "foo" ;; ignored - (read-file-name "Version to download: " - directory - files - t - (concat - (file-name-as-directory directory) - package) - nil)))) - - (copy-file (cdr (car files)) dest)))))) - -;;; How we upgrade packages in Emacs has yet to be ironed out. - -;; (defun inversion-upgrade-package (package &optional directory) -;; "Try to upgrade PACKAGE in DIRECTORY is available." -;; (interactive "sPackage to upgrade: ") -;; (if (stringp package) (setq package (intern package))) -;; (if (not directory) -;; ;; Hope that the package maintainer specified. -;; (setq directory (symbol-value (or (intern-soft -;; (concat (symbol-name package) -;; "-url")) -;; (intern-soft -;; (concat (symbol-name package) -;; "-directory")))))) -;; (let ((files (inversion-locate-package-files-and-split -;; package directory)) -;; (cver (inversion-package-version package)) -;; (newer nil)) -;; (mapc (lambda (f) -;; (if (inversion-< cver (inversion-decode-version (car f))) -;; (setq newer (cons f newer)))) -;; files) -;; newer -;; )) - -(provide 'inversion) - -;;; inversion.el ends here diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el index 44bd4b0cd82..797ff753a6c 100644 --- a/lisp/cedet/semantic.el +++ b/lisp/cedet/semantic.el @@ -57,6 +57,7 @@ excluded if a released version is required. It is assumed that if the current version is newer than that specified, everything passes. Exceptions occur when known incompatibilities are introduced." + (declare (obsolete emacs-version "28.1")) (require 'inversion) (inversion-test 'semantic (concat major "." minor diff --git a/lisp/cedet/semantic/db-file.el b/lisp/cedet/semantic/db-file.el index 59e9db9cc0a..d99b94f49eb 100644 --- a/lisp/cedet/semantic/db-file.el +++ b/lisp/cedet/semantic/db-file.el @@ -154,8 +154,6 @@ If DIRECTORY doesn't exist, create a new one." ;;; File IO -(declare-function inversion-test "inversion") - (defun semanticdb-load-database (filename) "Load the database FILENAME." (condition-case foo @@ -163,32 +161,19 @@ If DIRECTORY doesn't exist, create a new one." 'semanticdb-project-database-file)) (c (semanticdb-get-database-tables r)) (tv (oref r semantic-tag-version)) - (fv (oref r semanticdb-version)) - ) + (fv (oref r semanticdb-version))) ;; Restore the parent-db connection (while c (oset (car c) parent-db r) (setq c (cdr c))) (unless (and (equal semanticdb-file-version fv) (equal semantic-tag-version tv)) - ;; Try not to load inversion unless we need it: - (require 'inversion) - (if (not (inversion-test 'semanticdb-file fv)) - (when (inversion-test 'semantic-tag tv) - ;; Incompatible version. Flush tables. - (semanticdb-flush-database-tables r) - ;; Reset the version to new version. - (oset r semantic-tag-version semantic-tag-version) - ;; Warn user - (message "Semanticdb file is old. Starting over for %s" - filename)) - ;; Version is not ok. Flush whole system - (message "semanticdb file is old. Starting over for %s" - filename) - ;; This database is so old, we need to replace it. - ;; We also need to delete it from the instance tracker. - (delete-instance r) - (setq r nil))) + ;; Version is not ok. Flush whole system + (message "semanticdb file is old. Starting over for %s" filename) + ;; This database is so old, we need to replace it. + ;; We also need to delete it from the instance tracker. + (delete-instance r) + (setq r nil)) r) (error (message "Cache Error: [%s] %s, Restart" filename foo) diff --git a/lisp/cedet/semantic/ede-grammar.el b/lisp/cedet/semantic/ede-grammar.el index bd0795acbd6..64fc07fe1bb 100644 --- a/lisp/cedet/semantic/ede-grammar.el +++ b/lisp/cedet/semantic/ede-grammar.el @@ -162,10 +162,9 @@ Lays claim to all -by.el, and -wy.el files." "Insert variables needed by target THIS." (ede-proj-makefile-insert-loadpath-items (ede-proj-elisp-packages-to-loadpath - (list "eieio" "semantic" "inversion" "ede"))) + (list "eieio" "semantic" "ede"))) ;; eieio for object system needed in ede ;; semantic because it is - ;; Inversion for versioning system. ;; ede for project regeneration (ede-pmake-insert-variable-shared (concat (ede-pmake-varname this) "_SEMANTIC_GRAMMAR_EL") @@ -174,8 +173,7 @@ Lays claim to all -by.el, and -wy.el files." (with-current-buffer (find-file-noselect src) (concat (semantic-grammar-package) ".el"))) (oref this source) - " "))) - ) + " ")))) (cl-defmethod ede-proj-makefile-insert-rules :after ((this semantic-ede-proj-target-grammar)) "Insert rules needed by THIS target. diff --git a/lisp/obsolete/inversion.el b/lisp/obsolete/inversion.el new file mode 100644 index 00000000000..f192d888681 --- /dev/null +++ b/lisp/obsolete/inversion.el @@ -0,0 +1,530 @@ +;;; inversion.el --- When you need something in version XX.XX + +;;; Copyright (C) 2002-2003, 2005-2021 Free Software Foundation, Inc. + +;; Author: Eric M. Ludlam +;; Version: 1.3 +;; Keywords: OO, lisp +;; Obsolete-since: 28.1 + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: +;; +;; Keeping track of rapidly developing software is a tough thing to +;; do, especially if you want to have co-dependent packages which all +;; move at different rates. +;; +;; This library provides a framework for specifying version numbers +;; and (as side effect) have a flexible way of getting a desired feature set. +;; +;; If you would like to use this package to satisfy dependency replace this: +;; +;; (require 'spiffy) +;; +;; with this: +;; +;; (require 'inversion) +;; (inversion-require 'spiffy "1.0") +;; +;; If you feel the need to not throw errors, you can do this instead: +;; +;; (let ((err (inversion-test 'spiffy "1.0"))) +;; (if err (your-stuff-here))) +;; +;; If you new package (2.0) needs to make sure a load file from your +;; package is compatible, use this test: +;; +;; (if (not (inversion-reverse-test 'spiffy version-from-file)) +;; ;; Everything ok +;; (do stuff) +;; ;; Out of date +;; (import-old-code)) +;; +;; If you would like to make inversion optional, do this: +;; +;; (or (require 'inversion nil t) +;; (defun inversion-test (p v) +;; (string= v (symbol-value +;; (intern-soft (concat (symbol-string p) "-version")))))) +;; +;; Or modify to specify `inversion-require' instead. +;; +;; TODO: +;; Offer to download newer versions of a package. + +;;; History: +;; +;; Sept 3, 2002: First general publication. + +;;; Code: + +(defvar inversion-version "1.3" + "Current version of InVersion.") + +(defvar inversion-incompatible-version "0.1alpha1" + "An earlier release which is incompatible with this release.") + +(defconst inversion-decoders + '( + (alpha "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]*\\)\\s-*\\.?alpha\\([0-9]+\\)?$" 4) + (beta "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]*\\)\\s-*\\.?beta\\([0-9]+\\)?$" 4) + (beta "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]*\\)\\s-*\\.?(beta\\([0-9]+\\)?)$" 4) + (beta "^[^/]+/\\w+--\\w+--\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)--patch-\\([0-9]+\\)" 4) + (beta "^\\w+: v\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)-\\([0-9]+\\)-\\(.*\\)" 5) + (prerelease "^\\([0-9]+\\)\\.\\([0-9]+\\)\\s-*\\.?pre\\([0-9]+\\)?$" 3) + (full "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?$" 3) + (fullsingle "^\\([0-9]+\\)$" 1) + (patch "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?\\s-*(patch \\([0-9]+\\))" 4) + (point "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)$" 3) + (point "^\\w+: v\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)-\\(0\\)-\\(.*\\)" 5) + (build "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\).\\([0-9]+\\)$" 4) + (full "^[^/]+/\\w+--\\w+--\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)--version-\\([0-9]+\\)" 4) + (full "^\\w+: v\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" 5) + ) + "List of decoders for version strings. +Each decoder is of the form: + + ( RELEASE-TYPE REGEXP MAX ) + +RELEASE-TYPE is a symbol specifying something like `beta' or `alpha'. +REGEXP is the regular expression to match a version string. +MAX is the maximum number of match-numbers in the release number. +Decoders must be ordered to decode least stable versions before the +more stable ones.") + +;;; Version Checking +;; +(defun inversion-decode-version (version-string) + "Decode VERSION-STRING into an encoded list. +Return value is of the form: + (RELEASE MAJOR MINOR ...) +where RELEASE is a symbol such as `full', or `beta'." + (let ((decoders inversion-decoders) + (result nil)) + (while (and decoders (not result)) + (if (string-match (nth 1 (car decoders)) version-string) + (let ((ver nil) + (num-left (nth 2 (car decoders))) + (count 1)) + (while (<= count num-left) + (setq ver (cons + (if (match-beginning count) + (string-to-number + (substring version-string + (match-beginning count) + (match-end count))) + 1) + ver) + count (1+ count))) + (setq result (cons (caar decoders) (nreverse ver)))) + (setq decoders (cdr decoders)))) + result)) + +(defun inversion-package-version (package) + "Return the decoded version for PACKAGE." + (let ((ver (symbol-value + (intern-soft + (concat (symbol-name package) + "-version")))) + (code nil)) + (unless ver + (error "Package %S does not define %S-version" package package)) + ;; Decode the code + (setq code (inversion-decode-version ver)) + (unless code + (error "%S-version value (%s) cannot be decoded" package ver)) + code)) + +(defun inversion-package-incompatibility-version (package) + "Return the decoded incompatibility version for PACKAGE. +The incompatibility version is specified by the programmer of +a package when a package is not backward compatible. It is +not an indication of new features or bug fixes." + (let ((ver (symbol-value + (intern-soft + (concat (symbol-name package) + "-incompatible-version"))))) + (if (not ver) + nil + ;; Decode the code + (inversion-decode-version ver)))) + +(defun inversion-recode (code) + "Convert CODE into a string." + (let ((r (nth 0 code)) ; release-type + (n (nth 1 code)) ; main number + (i (nth 2 code)) ; first increment + (p (nth 3 code))) ; second increment + (cond + ((eq r 'full) + (setq r "" p "")) + ((eq r 'point) + (setq r "."))) + (format "%s.%s%s%s" n i r p))) + +(defun inversion-release-to-number (release-symbol) + "Convert RELEASE-SYMBOL into a number." + (let* ((ra (assoc release-symbol inversion-decoders)) + (rn (- (length inversion-decoders) + (length (member ra inversion-decoders))))) + rn)) + +(defun inversion-= (ver1 ver2) + "Return non-nil if VER1 is equal to VER2." + (equal ver1 ver2)) + +(defun inversion-< (ver1 ver2) + "Return non-nil if VER1 is less than VER2." + (let ((v1-0 (inversion-release-to-number (nth 0 ver1))) + (v1-1 (nth 1 ver1)) + (v1-2 (nth 2 ver1)) + (v1-3 (nth 3 ver1)) + (v1-4 (nth 4 ver1)) + ;; v2 + (v2-0 (inversion-release-to-number (nth 0 ver2))) + (v2-1 (nth 1 ver2)) + (v2-2 (nth 2 ver2)) + (v2-3 (nth 3 ver2)) + (v2-4 (nth 4 ver2)) + ) + + (cond ((and (equal (list v1-1 v1-2 v1-3 v1-4) + (list v2-1 v2-2 v2-3 v2-4)) + v1-0 v2-0) + (< v1-0 v2-0)) + ((and (equal v1-1 v2-1) + (equal v1-2 v2-2) + (equal v1-3 v2-3) + v1-4 v2-4) ; all or nothing if elt - is = + (< v1-4 v2-4)) + ((and (equal v1-1 v2-1) + (equal v1-2 v2-2) + v1-3 v2-3) ; all or nothing if elt - is = + (< v1-3 v2-3)) + ((and (equal v1-1 v2-1) + v1-2 v2-2) + (< v1-2 v2-2)) + ((and v1-1 v2-1) + (< v1-1 v2-1)) + ))) + +(defun inversion-check-version (version incompatible-version + minimum &rest reserved) + "Check that a given version meets the minimum requirement. +VERSION, INCOMPATIBLE-VERSION and MINIMUM are of similar format to +return entries of `inversion-decode-version', or a classic version +string. INCOMPATIBLE-VERSION can be nil. +RESERVED arguments are kept for a later use. +Return: +- nil if everything is ok. +- `outdated' if VERSION is less than MINIMUM. +- `incompatible' if VERSION is not backward compatible with MINIMUM. +- t if the check failed." + (let ((code (if (stringp version) + (inversion-decode-version version) + version)) + (req (if (stringp minimum) + (inversion-decode-version minimum) + minimum)) + ) + ;; Perform a test. + (cond + ((inversion-= code req) + ;; Same version.. Yay! + nil) + ((inversion-< code req) + ;; Version is too old! + 'outdated) + ((inversion-< req code) + ;; Newer is installed. What to do? + (let ((incompatible + (if (stringp incompatible-version) + (inversion-decode-version incompatible-version) + incompatible-version))) + (cond + ((not incompatible) nil) + ((or (inversion-= req incompatible) + (inversion-< req incompatible)) + ;; The requested version is = or < than what the package + ;; maintainer says is incompatible. + 'incompatible) + ;; Things are ok. + (t nil)))) + ;; Check failed + (t t)))) + +(defun inversion-test (package minimum &rest reserved) + "Test that PACKAGE meets the MINIMUM version requirement. +PACKAGE is a symbol, similar to what is passed to `require'. +MINIMUM is of similar format to return entries of +`inversion-decode-version', or a classic version string. +RESERVED arguments are kept for a later user. +This depends on the symbols `PACKAGE-version' and optionally +`PACKAGE-incompatible-version' being defined in PACKAGE. +Return nil if everything is ok. Return an error string otherwise." + (let ((check (inversion-check-version + (inversion-package-version package) + (inversion-package-incompatibility-version package) + minimum reserved))) + (cond + ((null check) + ;; Same version.. Yay! + nil) + ((eq check 'outdated) + ;; Version is too old! + (format "You need to upgrade package %s to %s" package minimum)) + ((eq check 'incompatible) + ;; Newer is installed but the requested version is = or < than + ;; what the package maintainer says is incompatible, then throw + ;; that error. + (format "Package %s version is not backward compatible with %s" + package minimum)) + ;; Check failed + (t "Inversion version check failed.")))) + +(defun inversion-reverse-test (package oldversion &rest reserved) + "Test that PACKAGE at OLDVERSION is still compatible. +If something like a save file is loaded at OLDVERSION, this +test will identify if OLDVERSION is compatible with the current version +of PACKAGE. +PACKAGE is a symbol, similar to what is passed to `require'. +OLDVERSION is of similar format to return entries of +`inversion-decode-version', or a classic version string. +RESERVED arguments are kept for a later user. +This depends on the symbols `PACKAGE-version' and optionally +`PACKAGE-incompatible-version' being defined in PACKAGE. +Return nil if everything is ok. Return an error string otherwise." + (let ((check (inversion-check-version + (inversion-package-version package) + (inversion-package-incompatibility-version package) + oldversion reserved))) + (cond + ((null check) + ;; Same version.. Yay! + nil) + ((eq check 'outdated) + ;; Version is too old! + (format "Package %s version %s is not compatible with current version" + package oldversion)) + ((eq check 'incompatible) + ;; Newer is installed but the requested version is = or < than + ;; what the package maintainer says is incompatible, then throw + ;; that error. + (format "Package %s version is not backward compatible with %s" + package oldversion)) + ;; Check failed + (t "Inversion version check failed.")))) + +(defun inversion-require (package version &optional file directory + &rest reserved) + "Declare that you need PACKAGE with at least VERSION. +PACKAGE might be found in FILE. (See `require'.) +Throws an error if VERSION is incompatible with what is installed. +Optional argument DIRECTORY is a location where new versions of +this tool can be located. If there is a versioning problem and +DIRECTORY is provided, inversion will offer to download the file. +Optional argument RESERVED is saved for later use." + (require package file) + (let ((err (inversion-test package version))) + (when err + (if directory + (inversion-download-package-ask err package directory version) + (error err))) + ;; Return the package symbol that was required. + package)) + +;;;###autoload +(defun inversion-require-emacs (emacs-ver xemacs-ver sxemacs-ver) + "Declare that you need either EMACS-VER, XEMACS-VER or SXEMACS-ver. +Only checks one based on which kind of Emacs is being run. + +This function is obsolete; do this instead: + (when (version<= \"28.1\" emacs-version) ...)" + (declare (obsolete nil "28.1")) + (let ((err (inversion-test 'emacs + (cond ((featurep 'sxemacs) + sxemacs-ver) + ((featurep 'xemacs) + xemacs-ver) + (t + emacs-ver))))) + (if err (error err) + ;; Something nice... + t))) + +(defconst inversion-find-data + '("(def\\(var\\|const\\)\\s-+%s-%s\\s-+\"\\([^\"]+\\)" 2) + "Regexp template and match data index of a version string.") + +(defun inversion-find-version (package) + "Search for the version and incompatible version of PACKAGE. +Does not load PACKAGE nor requires that it has been previously loaded. +Search in the directories in `load-path' for a PACKAGE.el library. +Visit the file found and search for the declarations of variables or +constants `PACKAGE-version' and `PACKAGE-incompatible-version'. The +value of these variables must be a version string. + +Return a pair (VERSION-STRING . INCOMPATIBLE-VERSION-STRING) where +INCOMPATIBLE-VERSION-STRING can be nil. +Return nil when VERSION-STRING was not found." + (let* ((file (locate-library (format "%s.el" package) t)) + (tag (car inversion-find-data)) + (idx (nth 1 inversion-find-data)) + version) + (when file + (with-temp-buffer + ;; The 3000 is a bit arbitrary, but should cut down on + ;; fileio as version info usually is at the very top + ;; of a file. After a long commentary could be bad. + (insert-file-contents-literally file nil 0 3000) + (goto-char (point-min)) + (when (re-search-forward (format tag package 'version) nil t) + (setq version (list (match-string idx))) + (goto-char (point-min)) + (when (re-search-forward + (format tag package 'incompatible-version) nil t) + (setcdr version (match-string idx)))))) + version)) + +(defun inversion-add-to-load-path (package minimum + &optional installdir + &rest subdirs) + "Add the PACKAGE path to `load-path' if necessary. +MINIMUM is the minimum version requirement of PACKAGE. +Optional argument INSTALLDIR is the base directory where PACKAGE is +installed. It defaults to `default-directory'/PACKAGE. +SUBDIRS are sub-directories to add to `load-path', following the main +INSTALLDIR path." + (let ((ver (inversion-find-version package))) + ;; If PACKAGE not found or a bad version already in `load-path', + ;; prepend the new PACKAGE path, so it will be loaded first. + (when (or (not ver) + (and + (inversion-check-version (car ver) (cdr ver) minimum) + (message "Outdated %s %s shadowed to meet minimum version %s" + package (car ver) minimum) + t)) + (let* ((default-directory + (or installdir + (expand-file-name (format "./%s" package)))) + subdir) + (when (file-directory-p default-directory) + ;; Add SUBDIRS + (while subdirs + (setq subdir (expand-file-name (car subdirs)) + subdirs (cdr subdirs)) + (when (file-directory-p subdir) + ;;(message "%S added to `load-path'" subdir) + (add-to-list 'load-path subdir))) + ;; Add the main path + ;;(message "%S added to `load-path'" default-directory) + (add-to-list 'load-path default-directory)) + ;; We get to this point iff we do not accept or there is no + ;; system file. Let's check the version of what we just + ;; installed... just to be safe. + (let ((newver (inversion-find-version package))) + (if (not newver) + (error "Failed to find version for newly installed %s" + package)) + (if (inversion-check-version (car newver) (cdr newver) minimum) + (error "Outdated %s %s just installed" package (car newver))) + ))))) + +;;; URL and downloading code +;; +(defun inversion-locate-package-files (package directory &optional version) + "Get a list of distributions of PACKAGE from DIRECTORY. +DIRECTORY can be an ange-ftp compatible filename, such as: + \"/ftp@ftp1.sourceforge.net/pub/sourceforge/PACKAGE\" +If it is a URL, wget will be used for download. +Optional argument VERSION will restrict the list of available versions +to the file matching VERSION exactly, or nil." +;;DIRECTORY should also allow a URL: +;; \"http://ftp1.sourceforge.net/PACKAGE\" +;; but then I can get file listings easily. + (if (symbolp package) (setq package (symbol-name package))) + (directory-files directory t + (if version + (concat "^" package "-" version "\\>") + package))) + +(defvar inversion-package-common-tails '( ".tar.gz" + ".tar" + ".zip" + ".gz" + ) + "Common distribution mechanisms for Emacs Lisp packages.") + +(defun inversion-locate-package-files-and-split (package directory &optional version) + "Use `inversion-locate-package-files' to get a list of PACKAGE files. +DIRECTORY is the location where distributions of PACKAGE are. +VERSION is an optional argument specifying a version to restrict to. +The return list is an alist with the version string in the CAR, +and the full path name in the CDR." + (if (symbolp package) (setq package (symbol-name package))) + (let ((f (inversion-locate-package-files package directory version)) + (out nil)) + (while f + (let* ((file (car f)) + (dist (file-name-nondirectory file)) + (tails inversion-package-common-tails) + (verstring nil)) + (while (and tails (not verstring)) + (when (string-match (concat (car tails) "$") dist) + (setq verstring + (substring dist (1+ (length package)) (match-beginning 0)))) + (setq tails (cdr tails))) + (if (not verstring) + (error "Cannot decode version for %s" dist)) + (setq out + (cons + (cons verstring file) + out)) + (setq f (cdr f)))) + out)) + +(defun inversion-download-package-ask (err package directory version) + "Due to ERR, offer to download PACKAGE from DIRECTORY. +The package should have VERSION available for download." + (if (symbolp package) (setq package (symbol-name package))) + (let ((files (inversion-locate-package-files-and-split + package directory version))) + (if (not files) + (error err) + (if (not (y-or-n-p (concat err ": Download update? "))) + (error err) + (let ((dest (read-directory-name (format "Download %s to: " + package) + t))) + (if (> (length files) 1) + (setq files + (list + "foo" ;; ignored + (read-file-name "Version to download: " + directory + files + t + (concat + (file-name-as-directory directory) + package) + nil)))) + + (copy-file (cdr (car files)) dest)))))) + +(provide 'inversion) + +;;; inversion.el ends here diff --git a/lisp/speedbar.el b/lisp/speedbar.el index 0e2a3749bef..4a785623805 100644 --- a/lisp/speedbar.el +++ b/lisp/speedbar.el @@ -141,25 +141,6 @@ ;;; Code: -;; Note: `inversion-test' requires parts of the CEDET package that are -;; not included with Emacs. -;; -;; (defun speedbar-require-version (major minor &optional beta) -;; "Non-nil if this version of SPEEDBAR does not satisfy a specific version. -;; Arguments can be: -;; -;; (MAJOR MINOR &optional BETA) -;; -;; Values MAJOR and MINOR must be integers. BETA can be an integer, or -;; excluded if a released version is required. -;; -;; It is assumed that if the current version is newer than that specified, -;; everything passes. Exceptions occur when known incompatibilities are -;; introduced." -;; (inversion-test 'speedbar -;; (concat major "." minor -;; (when beta (concat "beta" beta))))) - (defvar speedbar-initial-expansion-mode-alist '(("buffers" speedbar-buffer-easymenu-definition speedbar-buffers-key-map speedbar-buffer-buttons) diff --git a/test/lisp/cedet/inversion-tests.el b/test/lisp/cedet/inversion-tests.el deleted file mode 100644 index c8b45d67ea1..00000000000 --- a/test/lisp/cedet/inversion-tests.el +++ /dev/null @@ -1,81 +0,0 @@ -;;; inversion-tests.el --- Tests for inversion.el -*- lexical-binding:t -*- - -;; Copyright (C) 2008-2021 Free Software Foundation, Inc. - -;; Author: Eric M. Ludlam - -;; This file is part of GNU Emacs. - -;; GNU Emacs is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; GNU Emacs is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs. If not, see . - -;;; Commentary: - -;; Moved here from test/manual/cedet/cedet-utests.el - -;;; Code: - -(require 'inversion) -(require 'ert) - -(ert-deftest inversion-unit-test () - "Test inversion to make sure it can identify different version strings." - (interactive) - (let ((c1 (inversion-package-version 'inversion)) - (c1i (inversion-package-incompatibility-version 'inversion)) - (c2 (inversion-decode-version "1.3alpha2")) - (c3 (inversion-decode-version "1.3beta4")) - (c4 (inversion-decode-version "1.3 beta5")) - (c5 (inversion-decode-version "1.3.4")) - (c6 (inversion-decode-version "2.3alpha")) - (c7 (inversion-decode-version "1.3")) - (c8 (inversion-decode-version "1.3pre1")) - (c9 (inversion-decode-version "2.4 (patch 2)")) - (c10 (inversion-decode-version "2.4 (patch 3)")) - (c11 (inversion-decode-version "2.4.2.1")) - (c12 (inversion-decode-version "2.4.2.2"))) - (should (inversion-= c1 c1)) - (should (inversion-< c1i c1)) - (should (inversion-< c2 c3)) - (should (inversion-< c3 c4)) - (should (inversion-< c4 c5)) - (should (inversion-< c5 c6)) - (should (inversion-< c2 c4)) - (should (inversion-< c2 c5)) - (should (inversion-< c2 c6)) - (should (inversion-< c3 c5)) - (should (inversion-< c3 c6)) - (should (inversion-< c7 c6)) - (should (inversion-< c4 c7)) - (should (inversion-< c2 c7)) - (should (inversion-< c8 c6)) - (should (inversion-< c8 c7)) - (should (inversion-< c4 c8)) - (should (inversion-< c2 c8)) - (should (inversion-< c9 c10)) - (should (inversion-< c10 c11)) - (should (inversion-< c11 c12)) - ;; Negatives - (should-not (inversion-< c3 c2)) - (should-not (inversion-< c4 c3)) - (should-not (inversion-< c5 c4)) - (should-not (inversion-< c6 c5)) - (should-not (inversion-< c7 c2)) - (should-not (inversion-< c7 c8)) - (should-not (inversion-< c12 c11)) - ;; Test the tester on inversion - (should-not (inversion-test 'inversion inversion-version)) - (should (stringp (inversion-test 'inversion "0.0.0"))) - (should (stringp (inversion-test 'inversion "1000.0"))))) - -;;; inversion-tests.el ends here diff --git a/test/lisp/obsolete/inversion-tests.el b/test/lisp/obsolete/inversion-tests.el new file mode 100644 index 00000000000..c8b45d67ea1 --- /dev/null +++ b/test/lisp/obsolete/inversion-tests.el @@ -0,0 +1,81 @@ +;;; inversion-tests.el --- Tests for inversion.el -*- lexical-binding:t -*- + +;; Copyright (C) 2008-2021 Free Software Foundation, Inc. + +;; Author: Eric M. Ludlam + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; Moved here from test/manual/cedet/cedet-utests.el + +;;; Code: + +(require 'inversion) +(require 'ert) + +(ert-deftest inversion-unit-test () + "Test inversion to make sure it can identify different version strings." + (interactive) + (let ((c1 (inversion-package-version 'inversion)) + (c1i (inversion-package-incompatibility-version 'inversion)) + (c2 (inversion-decode-version "1.3alpha2")) + (c3 (inversion-decode-version "1.3beta4")) + (c4 (inversion-decode-version "1.3 beta5")) + (c5 (inversion-decode-version "1.3.4")) + (c6 (inversion-decode-version "2.3alpha")) + (c7 (inversion-decode-version "1.3")) + (c8 (inversion-decode-version "1.3pre1")) + (c9 (inversion-decode-version "2.4 (patch 2)")) + (c10 (inversion-decode-version "2.4 (patch 3)")) + (c11 (inversion-decode-version "2.4.2.1")) + (c12 (inversion-decode-version "2.4.2.2"))) + (should (inversion-= c1 c1)) + (should (inversion-< c1i c1)) + (should (inversion-< c2 c3)) + (should (inversion-< c3 c4)) + (should (inversion-< c4 c5)) + (should (inversion-< c5 c6)) + (should (inversion-< c2 c4)) + (should (inversion-< c2 c5)) + (should (inversion-< c2 c6)) + (should (inversion-< c3 c5)) + (should (inversion-< c3 c6)) + (should (inversion-< c7 c6)) + (should (inversion-< c4 c7)) + (should (inversion-< c2 c7)) + (should (inversion-< c8 c6)) + (should (inversion-< c8 c7)) + (should (inversion-< c4 c8)) + (should (inversion-< c2 c8)) + (should (inversion-< c9 c10)) + (should (inversion-< c10 c11)) + (should (inversion-< c11 c12)) + ;; Negatives + (should-not (inversion-< c3 c2)) + (should-not (inversion-< c4 c3)) + (should-not (inversion-< c5 c4)) + (should-not (inversion-< c6 c5)) + (should-not (inversion-< c7 c2)) + (should-not (inversion-< c7 c8)) + (should-not (inversion-< c12 c11)) + ;; Test the tester on inversion + (should-not (inversion-test 'inversion inversion-version)) + (should (stringp (inversion-test 'inversion "0.0.0"))) + (should (stringp (inversion-test 'inversion "1000.0"))))) + +;;; inversion-tests.el ends here