diff options
Diffstat (limited to 'admin/admin.el')
| -rw-r--r-- | admin/admin.el | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/admin/admin.el b/admin/admin.el index c71e6539413..3e3fbba7202 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 | (defvar cusver-new-version (format "%s.%s" emacs-major-version |
| 446 | ;; group (eg for new files). | 446 | (1+ emacs-minor-version)) |
| 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,16 @@ 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 (list (read-directory-name "New Lisp directory: ") |
| 519 | (read-directory-name "Old Lisp directory: ") | ||
| 520 | (number-to-string | ||
| 521 | (read-number "New version number: " | ||
| 522 | (string-to-number cusver-new-version))))) | ||
| 503 | (or (file-directory-p (setq newdir (expand-file-name newdir))) | 523 | (or (file-directory-p (setq newdir (expand-file-name newdir))) |
| 504 | (error "Directory `%s' not found" newdir)) | 524 | (error "Directory `%s' not found" newdir)) |
| 505 | (or (file-directory-p (setq olddir (expand-file-name olddir))) | 525 | (or (file-directory-p (setq olddir (expand-file-name olddir))) |
| 506 | (error "Directory `%s' not found" olddir)) | 526 | (error "Directory `%s' not found" olddir)) |
| 527 | (setq cusver-new-version version) | ||
| 507 | (let* ((newfiles (progn (message "Finding new files with defcustoms...") | 528 | (let* ((newfiles (progn (message "Finding new files with defcustoms...") |
| 508 | (cusver-find-files newdir))) | 529 | (cusver-find-files newdir))) |
| 509 | (oldfiles (progn (message "Finding old files with defcustoms...") | 530 | (oldfiles (progn (message "Finding old files with defcustoms...") |