summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wohler <wohler@newt.com>2006-04-10 23:43:34 +0000
committerBill Wohler <wohler@newt.com>2006-04-10 23:43:34 +0000
commit4e9c705e50b4e6ee733e0134703b00253cc4cf7c (patch)
tree5d3b92a29d6c6dd057ce3f0605488a22f9ed9119
parent1d22fabd46ebbb3e2af5cdea011b42c7a0331463 (diff)
downloademacs-4e9c705e50b4e6ee733e0134703b00253cc4cf7c.tar.gz
emacs-4e9c705e50b4e6ee733e0134703b00253cc4cf7c.tar.bz2
emacs-4e9c705e50b4e6ee733e0134703b00253cc4cf7c.zip
* custom.el (defcustom, custom-handle-keyword): Add :package-version
keyword. (custom-add-package-version): New function. Sets value of new property 'custom-package-version from :package-version keyword. * cus-edit.el (customize-package-emacs-version-alist): New variable. (customize-changed-options): Add check for custom-package-version. (customize-package-emacs-version): New function to look up Emacs version corresponding to the given package version.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/cus-edit.el46
-rw-r--r--lisp/custom.el12
3 files changed, 67 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 59d12a7f41b..8a205081fa5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,16 @@
2006-04-10 Bill Wohler <wohler@newt.com>
+ * custom.el (defcustom, custom-handle-keyword): Add
+ :package-version keyword.
+ (custom-add-package-version): New function. Sets value of new
+ property 'custom-package-version from :package-version keyword.
+
+ * cus-edit.el (customize-package-emacs-version-alist): New
+ variable.
+ (customize-changed-options): Add check for custom-package-version.
+ (customize-package-emacs-version): New function to look up Emacs
+ version corresponding to the given package version.
+
* emacs-lisp/find-func.el (find-function-regexp): Allow dashes in
defun name, in similar fashion to find-variable-regexp.
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index e2275ce356d..4de2a431392 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -786,7 +786,7 @@ when the action is chosen.")
(if (or (and (= 1 (length children))
(memq (widget-type (car children))
'(custom-variable custom-face)))
- (y-or-n-p "Reset all settings' buffer text to show current values? "))
+ (y-or-n-p "Reset all settings' buffer text to show current values? "))
(mapc (lambda (widget)
(if (memq (widget-get widget :custom-state)
'(modified changed))
@@ -1079,6 +1079,18 @@ Show the buffer in another window, but don't select it."
(defvar customize-changed-options-previous-release "21.1"
"Version for `customize-changed-options' to refer back to by default.")
+;; Packages will update this variable, so make it available.
+;;;###autoload
+(defvar customize-package-emacs-version-alist nil
+ "Alist that maps packages to alists of package to Emacs versions.
+The value alists map all package versions used with
+the :package-version keyword to Emacs versions. Packages are
+symbols and versions are strings.
+
+For example:
+ '((MH-E (\"7.4\" \"22.1\") (\"8.0\" \"22.1\"))
+ (Gnus (\"5.11\" \"22.1\")))")
+
;;;###autoload
(defalias 'customize-changed 'customize-changed-options)
@@ -1119,7 +1131,12 @@ that were added or redefined since that version."
(let (found)
(mapatoms
(lambda (symbol)
- (let ((version (get symbol 'custom-version)))
+ (let* ((package-version (get symbol 'custom-package-version))
+ (version
+ (or (and package-version
+ (customize-package-emacs-version symbol
+ package-version))
+ (get symbol 'custom-version))))
(if version
(when (customize-version-lessp since-version version)
(if (or (get symbol 'custom-group)
@@ -1135,6 +1152,31 @@ that were added or redefined since that version."
(error "No user option defaults have been changed since Emacs %s"
since-version))))
+(defun customize-package-emacs-version (symbol package-version)
+ "Return Emacs version of SYMBOL.
+PACKAGE-VERSION has the form (PACKAGE VERSION). The VERSION of
+PACKAGE is looked up in the associated list
+`customize-package-emacs-version-alist' to find the version of
+Emacs that is associated with it."
+ (let (package-versions emacs-version)
+ ;; Use message instead of error since we want user to be able to
+ ;; see the rest of the symbols even if a package author has
+ ;; botched things up.
+ (cond ((not (listp package-version))
+ (message "Invalid package-version value for %s" symbol))
+ ((setq package-versions (assq (car package-version)
+ customize-package-emacs-version-alist))
+ (setq emacs-version
+ (cadr (assoc (cadr package-version) package-versions)))
+ (unless emacs-version
+ (message "Package version of %s not found in %s" symbol
+ "customize-package-emacs-version-alist")))
+ (t
+ (message "Package %s neglected to update %s"
+ (car package-version)
+ "customize-package-emacs-version-alist")))
+ emacs-version))
+
(defun customize-version-lessp (version1 version2)
;; Why are the versions strings, and given that they are, why aren't
;; they converted to numbers and compared as such here? -- fx
diff --git a/lisp/custom.el b/lisp/custom.el
index c67f3b06272..42872ca761c 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -268,6 +268,12 @@ The following keywords are meaningful:
VALUE should be a string specifying that the variable was
first introduced, or its default value was changed, in Emacs
version VERSION.
+:package-version
+ VALUE should be a list with the form (PACKAGE VERSION)
+ specifying that the variable was first introduced, or its
+ default value was changed, in PACKAGE version VERSION. This
+ keyword takes priority over :version. The PACKAGE and VERSION
+ must appear in the alist `customize-package-emacs-version-alist'.
:tag LABEL
Use LABEL, a string, instead of the item's name, to label the item
in customization menus and buffers.
@@ -489,6 +495,8 @@ Fourth argument TYPE is the custom option type."
(custom-add-to-group value symbol type))
((eq keyword :version)
(custom-add-version symbol value))
+ ((eq keyword :package-version)
+ (custom-add-package-version symbol value))
((eq keyword :link)
(custom-add-link symbol value))
((eq keyword :load)
@@ -540,6 +548,10 @@ For other custom types, this has no effect."
"To the custom option SYMBOL add the version VERSION."
(put symbol 'custom-version (purecopy version)))
+(defun custom-add-package-version (symbol version)
+ "To the custom option SYMBOL add the package version VERSION."
+ (put symbol 'custom-package-version (purecopy version)))
+
(defun custom-add-load (symbol load)
"To the custom option SYMBOL add the dependency LOAD.
LOAD should be either a library file name, or a feature name."