Commit 1a316a53 authored by Glenn Morris's avatar Glenn Morris

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.
parent 460042b8
2012-10-06 Glenn Morris <rgm@gnu.org>
* admin.el (cusver-new-version): New variable.
(cusver-scan): Check if containing group has a :version.
(cusver-check): Add VERSION argument.
2012-10-01 David Engster <deng@randomsample.de>
* grammars/bovine-grammar.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...")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment