diff options
| author | Glenn Morris | 2012-10-06 14:15:03 -0700 |
|---|---|---|
| committer | Glenn Morris | 2012-10-06 14:15:03 -0700 |
| commit | 1a316a53933885ed963f758c6463368cfe472d8f (patch) | |
| tree | 8f83265cf82f0b629d158162b69ec7cf101fb227 /admin | |
| parent | 460042b854a0b89b445725e046dd4947481c43ce (diff) | |
| download | emacs-1a316a53933885ed963f758c6463368cfe472d8f.tar.gz emacs-1a316a53933885ed963f758c6463368cfe472d8f.zip | |
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')
| -rw-r--r-- | admin/ChangeLog | 6 | ||||
| -rw-r--r-- | admin/admin.el | 35 |
2 files changed, 32 insertions, 9 deletions
diff --git a/admin/ChangeLog b/admin/ChangeLog index 8fe82ca36cb..82a01887b57 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-10-06 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * admin.el (cusver-new-version): New variable. | ||
| 4 | (cusver-scan): Check if containing group has a :version. | ||
| 5 | (cusver-check): Add VERSION argument. | ||
| 6 | |||
| 1 | 2012-10-01 David Engster <deng@randomsample.de> | 7 | 2012-10-01 David Engster <deng@randomsample.de> |
| 2 | 8 | ||
| 3 | * grammars/bovine-grammar.el: | 9 | * grammars/bovine-grammar.el: |
diff --git a/admin/admin.el b/admin/admin.el index c71e6539413..60a09a1e2f2 100644 --- a/admin/admin.el +++ b/admin/admin.el | |||
| @@ -442,8 +442,12 @@ If optional OLD is non-nil, also include defvars." | |||
| 442 | )) | 442 | )) |
| 443 | "{}" "+")) | 443 | "{}" "+")) |
| 444 | 444 | ||
| 445 | ;; TODO if a defgroup with a version tag, apply to all customs in that | 445 | ; FIXME Calculate default based on running emacs-version. |
| 446 | ;; group (eg for new files). | 446 | (defvar cusver-new-version nil |
| 447 | "Version number that new defcustoms should have.") | ||
| 448 | |||
| 449 | ;; TODO do something about renamed variables with aliases to the old name? | ||
| 450 | ;; Scan old cus-start.el to find variables moved from C to lisp? | ||
| 447 | (defun cusver-scan (file &optional old) | 451 | (defun cusver-scan (file &optional old) |
| 448 | "Scan FILE for `defcustom' calls. | 452 | "Scan FILE for `defcustom' calls. |
| 449 | Return a list with elements of the form (VAR . VER), | 453 | Return a list with elements of the form (VAR . VER), |
| @@ -452,8 +456,8 @@ a :version tag having value VER (may be nil). | |||
| 452 | If optional argument OLD is non-nil, also scan for defvars." | 456 | If optional argument OLD is non-nil, also scan for defvars." |
| 453 | (let ((m (format "Scanning %s..." file)) | 457 | (let ((m (format "Scanning %s..." file)) |
| 454 | (re (format "^[ \t]*\\((def%s\\)[ \t\n]" | 458 | (re (format "^[ \t]*\\((def%s\\)[ \t\n]" |
| 455 | (if old "\\(?:custom\\|var\\)" "custom"))) | 459 | (if old "\\(custom\\|var\\)" "\\(custom\\|group\\)"))) |
| 456 | alist var ver form) | 460 | alist var ver form glist grp) |
| 457 | (message "%s" m) | 461 | (message "%s" m) |
| 458 | (with-temp-buffer | 462 | (with-temp-buffer |
| 459 | (insert-file-contents file) | 463 | (insert-file-contents file) |
| @@ -461,11 +465,23 @@ If optional argument OLD is non-nil, also scan for defvars." | |||
| 461 | (while (re-search-forward re nil t) | 465 | (while (re-search-forward re nil t) |
| 462 | (goto-char (match-beginning 1)) | 466 | (goto-char (match-beginning 1)) |
| 463 | (if (and (setq form (ignore-errors (read (current-buffer)))) | 467 | (if (and (setq form (ignore-errors (read (current-buffer)))) |
| 464 | (setq var (car-safe (cdr-safe form))) | 468 | (setq var (car-safe (cdr-safe form))) |
| 465 | ;; Exclude macros, eg (defcustom ,varname ...). | 469 | ;; Exclude macros, eg (defcustom ,varname ...). |
| 466 | (symbolp var)) | 470 | (symbolp var)) |
| 467 | (setq ver (car (cdr-safe (memq :version form))) | 471 | (progn |
| 468 | alist (cons (cons var ver) alist)) | 472 | (setq ver (car (cdr-safe (memq :version form)))) |
| 473 | (if (equal "group" (match-string 2)) | ||
| 474 | ;; Group :version could be old. | ||
| 475 | (if (equal ver cusver-new-version) | ||
| 476 | (setq glist (cons (cons var ver) glist))) | ||
| 477 | ;; If it specifies a group and the whole group has a | ||
| 478 | ;; version. use that. | ||
| 479 | (unless ver | ||
| 480 | (setq grp (car (cdr-safe (memq :group form)))) | ||
| 481 | (and grp | ||
| 482 | (setq grp (car (cdr-safe grp))) ; (quote foo) -> foo | ||
| 483 | (setq ver (assq grp glist)))) | ||
| 484 | (setq alist (cons (cons var ver) alist)))) | ||
| 469 | (if form (message "Malformed defcustom: `%s'" form))))) | 485 | (if form (message "Malformed defcustom: `%s'" form))))) |
| 470 | (message "%sdone" m) | 486 | (message "%sdone" m) |
| 471 | alist)) | 487 | alist)) |
| @@ -490,7 +506,7 @@ If optional argument OLD is non-nil, also scan for defvars." | |||
| 490 | ;; TODO handle renamed things with aliases to the old names. | 506 | ;; TODO handle renamed things with aliases to the old names. |
| 491 | ;; What to do about new files? Does everything in there need a :version, | 507 | ;; What to do about new files? Does everything in there need a :version, |
| 492 | ;; or eg just the defgroup? | 508 | ;; or eg just the defgroup? |
| 493 | (defun cusver-check (newdir olddir) | 509 | (defun cusver-check (newdir olddir version) |
| 494 | "Check that defcustoms have :version tags where needed. | 510 | "Check that defcustoms have :version tags where needed. |
| 495 | NEWDIR is the current lisp/ directory, OLDDIR is that from the previous | 511 | NEWDIR is the current lisp/ directory, OLDDIR is that from the previous |
| 496 | release. A defcustom that is only in NEWDIR should have a :version | 512 | 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. | |||
| 499 | 515 | ||
| 500 | Note that a :version tag should also be added if the value of a defcustom | 516 | Note that a :version tag should also be added if the value of a defcustom |
| 501 | changes (in a non-trivial way). This function does not check for that." | 517 | changes (in a non-trivial way). This function does not check for that." |
| 502 | (interactive "DNew Lisp directory: \nDOld Lisp directory: ") | 518 | (interactive "DNew Lisp directory: \nDOld Lisp directory: \nsNew version number: ") |
| 503 | (or (file-directory-p (setq newdir (expand-file-name newdir))) | 519 | (or (file-directory-p (setq newdir (expand-file-name newdir))) |
| 504 | (error "Directory `%s' not found" newdir)) | 520 | (error "Directory `%s' not found" newdir)) |
| 505 | (or (file-directory-p (setq olddir (expand-file-name olddir))) | 521 | (or (file-directory-p (setq olddir (expand-file-name olddir))) |
| 506 | (error "Directory `%s' not found" olddir)) | 522 | (error "Directory `%s' not found" olddir)) |
| 523 | (setq cusver-new-version version) | ||
| 507 | (let* ((newfiles (progn (message "Finding new files with defcustoms...") | 524 | (let* ((newfiles (progn (message "Finding new files with defcustoms...") |
| 508 | (cusver-find-files newdir))) | 525 | (cusver-find-files newdir))) |
| 509 | (oldfiles (progn (message "Finding old files with defcustoms...") | 526 | (oldfiles (progn (message "Finding old files with defcustoms...") |