aboutsummaryrefslogtreecommitdiffstats
path: root/admin/admin.el
diff options
context:
space:
mode:
authorGlenn Morris <[email protected]>2012-10-06 14:15:03 -0700
committerGlenn Morris <[email protected]>2012-10-06 14:15:03 -0700
commit1a316a53933885ed963f758c6463368cfe472d8f (patch)
tree8f83265cf82f0b629d158162b69ec7cf101fb227 /admin/admin.el
parent460042b854a0b89b445725e046dd4947481c43ce (diff)
Handle group :version in cusver-check
* admin/admin.el (cusver-new-version): New variable. (cusver-scan): Check if containing group has a :version. (cusver-check): Add VERSION argument.
Diffstat (limited to 'admin/admin.el')
-rw-r--r--admin/admin.el35
1 files changed, 26 insertions, 9 deletions
diff --git a/admin/admin.el b/admin/admin.el
index c71e653941..60a09a1e2f 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -442,8 +442,12 @@ If optional OLD is non-nil, also include defvars."
))
"{}" "+"))
-;; TODO if a defgroup with a version tag, apply to all customs in that
-;; group (eg for new files).
+; FIXME Calculate default based on running emacs-version.
+(defvar cusver-new-version nil
+ "Version number that new defcustoms should have.")
+
+;; TODO do something about renamed variables with aliases to the old name?
+;; Scan old cus-start.el to find variables moved from C to lisp?
(defun cusver-scan (file &optional old)
"Scan FILE for `defcustom' calls.
Return a list with elements of the form (VAR . VER),
@@ -452,8 +456,8 @@ a :version tag having value VER (may be nil).
If optional argument OLD is non-nil, also scan for defvars."
(let ((m (format "Scanning %s..." file))
(re (format "^[ \t]*\\((def%s\\)[ \t\n]"
- (if old "\\(?:custom\\|var\\)" "custom")))
- alist var ver form)
+ (if old "\\(custom\\|var\\)" "\\(custom\\|group\\)")))
+ alist var ver form glist grp)
(message "%s" m)
(with-temp-buffer
(insert-file-contents file)
@@ -461,11 +465,23 @@ If optional argument OLD is non-nil, also scan for defvars."
(while (re-search-forward re nil t)
(goto-char (match-beginning 1))
(if (and (setq form (ignore-errors (read (current-buffer))))
- (setq var (car-safe (cdr-safe form)))
+ (setq var (car-safe (cdr-safe form)))
;; Exclude macros, eg (defcustom ,varname ...).
(symbolp var))
- (setq ver (car (cdr-safe (memq :version form)))
- alist (cons (cons var ver) alist))
+ (progn
+ (setq ver (car (cdr-safe (memq :version form))))
+ (if (equal "group" (match-string 2))
+ ;; Group :version could be old.
+ (if (equal ver cusver-new-version)
+ (setq glist (cons (cons var ver) glist)))
+ ;; If it specifies a group and the whole group has a
+ ;; version. use that.
+ (unless ver
+ (setq grp (car (cdr-safe (memq :group form))))
+ (and grp
+ (setq grp (car (cdr-safe grp))) ; (quote foo) -> foo
+ (setq ver (assq grp glist))))
+ (setq alist (cons (cons var ver) alist))))
(if form (message "Malformed defcustom: `%s'" form)))))
(message "%sdone" m)
alist))
@@ -490,7 +506,7 @@ If optional argument OLD is non-nil, also scan for defvars."
;; TODO handle renamed things with aliases to the old names.
;; What to do about new files? Does everything in there need a :version,
;; or eg just the defgroup?
-(defun cusver-check (newdir olddir)
+(defun cusver-check (newdir olddir version)
"Check that defcustoms have :version tags where needed.
NEWDIR is the current lisp/ directory, OLDDIR is that from the previous
release. A defcustom that is only in NEWDIR should have a :version
@@ -499,11 +515,12 @@ just converting a defvar to a defcustom does not require a :version bump.
Note that a :version tag should also be added if the value of a defcustom
changes (in a non-trivial way). This function does not check for that."
- (interactive "DNew Lisp directory: \nDOld Lisp directory: ")
+ (interactive "DNew Lisp directory: \nDOld Lisp directory: \nsNew version number: ")
(or (file-directory-p (setq newdir (expand-file-name newdir)))
(error "Directory `%s' not found" newdir))
(or (file-directory-p (setq olddir (expand-file-name olddir)))
(error "Directory `%s' not found" olddir))
+ (setq cusver-new-version version)
(let* ((newfiles (progn (message "Finding new files with defcustoms...")
(cusver-find-files newdir)))
(oldfiles (progn (message "Finding old files with defcustoms...")