comparison lisp/cus-edit.el @ 69922:dc1f0ab7e276

* 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.
author Bill Wohler <wohler@newt.com>
date Mon, 10 Apr 2006 23:43:34 +0000
parents efd1add5bedf
children 8991a6461375
comparison
equal deleted inserted replaced
69921:055c0dc190ac 69922:dc1f0ab7e276
784 (interactive) 784 (interactive)
785 (let ((children custom-options)) 785 (let ((children custom-options))
786 (if (or (and (= 1 (length children)) 786 (if (or (and (= 1 (length children))
787 (memq (widget-type (car children)) 787 (memq (widget-type (car children))
788 '(custom-variable custom-face))) 788 '(custom-variable custom-face)))
789 (y-or-n-p "Reset all settings' buffer text to show current values? ")) 789 (y-or-n-p "Reset all settings' buffer text to show current values? "))
790 (mapc (lambda (widget) 790 (mapc (lambda (widget)
791 (if (memq (widget-get widget :custom-state) 791 (if (memq (widget-get widget :custom-state)
792 '(modified changed)) 792 '(modified changed))
793 (widget-apply widget :custom-reset-current))) 793 (widget-apply widget :custom-reset-current)))
794 children) 794 children)
1077 (message "`%s' is an alias for `%s'" symbol basevar)))) 1077 (message "`%s' is an alias for `%s'" symbol basevar))))
1078 1078
1079 (defvar customize-changed-options-previous-release "21.1" 1079 (defvar customize-changed-options-previous-release "21.1"
1080 "Version for `customize-changed-options' to refer back to by default.") 1080 "Version for `customize-changed-options' to refer back to by default.")
1081 1081
1082 ;; Packages will update this variable, so make it available.
1083 ;;;###autoload
1084 (defvar customize-package-emacs-version-alist nil
1085 "Alist that maps packages to alists of package to Emacs versions.
1086 The value alists map all package versions used with
1087 the :package-version keyword to Emacs versions. Packages are
1088 symbols and versions are strings.
1089
1090 For example:
1091 '((MH-E (\"7.4\" \"22.1\") (\"8.0\" \"22.1\"))
1092 (Gnus (\"5.11\" \"22.1\")))")
1093
1082 ;;;###autoload 1094 ;;;###autoload
1083 (defalias 'customize-changed 'customize-changed-options) 1095 (defalias 'customize-changed 'customize-changed-options)
1084 1096
1085 ;;;###autoload 1097 ;;;###autoload
1086 (defun customize-changed-options (since-version) 1098 (defun customize-changed-options (since-version)
1117 (put 'custom-versions-load-alist 'custom-loads nil) 1129 (put 'custom-versions-load-alist 'custom-loads nil)
1118 1130
1119 (let (found) 1131 (let (found)
1120 (mapatoms 1132 (mapatoms
1121 (lambda (symbol) 1133 (lambda (symbol)
1122 (let ((version (get symbol 'custom-version))) 1134 (let* ((package-version (get symbol 'custom-package-version))
1135 (version
1136 (or (and package-version
1137 (customize-package-emacs-version symbol
1138 package-version))
1139 (get symbol 'custom-version))))
1123 (if version 1140 (if version
1124 (when (customize-version-lessp since-version version) 1141 (when (customize-version-lessp since-version version)
1125 (if (or (get symbol 'custom-group) 1142 (if (or (get symbol 'custom-group)
1126 (get symbol 'group-documentation)) 1143 (get symbol 'group-documentation))
1127 (push (list symbol 'custom-group) found)) 1144 (push (list symbol 'custom-group) found))
1132 (if found 1149 (if found
1133 (custom-buffer-create (custom-sort-items found t 'first) 1150 (custom-buffer-create (custom-sort-items found t 'first)
1134 "*Customize Changed Options*") 1151 "*Customize Changed Options*")
1135 (error "No user option defaults have been changed since Emacs %s" 1152 (error "No user option defaults have been changed since Emacs %s"
1136 since-version)))) 1153 since-version))))
1154
1155 (defun customize-package-emacs-version (symbol package-version)
1156 "Return Emacs version of SYMBOL.
1157 PACKAGE-VERSION has the form (PACKAGE VERSION). The VERSION of
1158 PACKAGE is looked up in the associated list
1159 `customize-package-emacs-version-alist' to find the version of
1160 Emacs that is associated with it."
1161 (let (package-versions emacs-version)
1162 ;; Use message instead of error since we want user to be able to
1163 ;; see the rest of the symbols even if a package author has
1164 ;; botched things up.
1165 (cond ((not (listp package-version))
1166 (message "Invalid package-version value for %s" symbol))
1167 ((setq package-versions (assq (car package-version)
1168 customize-package-emacs-version-alist))
1169 (setq emacs-version
1170 (cadr (assoc (cadr package-version) package-versions)))
1171 (unless emacs-version
1172 (message "Package version of %s not found in %s" symbol
1173 "customize-package-emacs-version-alist")))
1174 (t
1175 (message "Package %s neglected to update %s"
1176 (car package-version)
1177 "customize-package-emacs-version-alist")))
1178 emacs-version))
1137 1179
1138 (defun customize-version-lessp (version1 version2) 1180 (defun customize-version-lessp (version1 version2)
1139 ;; Why are the versions strings, and given that they are, why aren't 1181 ;; Why are the versions strings, and given that they are, why aren't
1140 ;; they converted to numbers and compared as such here? -- fx 1182 ;; they converted to numbers and compared as such here? -- fx
1141 1183