diff options
| author | Gerd Moellmann | 2001-01-02 10:35:00 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-01-02 10:35:00 +0000 |
| commit | 13c40e2fec410c2b6db620815da694a6df122d03 (patch) | |
| tree | e6758146047db9d8b72f098ff9b03537edc74a89 | |
| parent | 0cffd9d8daf06fbe811cec61e5b3b958e396c2a9 (diff) | |
| download | emacs-13c40e2fec410c2b6db620815da694a6df122d03.tar.gz emacs-13c40e2fec410c2b6db620815da694a6df122d03.zip | |
(lm-copyright-prefix): New Variable.
(lm-copyright-mark): New function.
(lm-crack-copyright): New function.
(lm-verify): Check that the file has a copyright.
Check that the file is copyright Free Software Foundation.
| -rw-r--r-- | lisp/emacs-lisp/lisp-mnt.el | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index b8f622defca..e7ea13e2cde 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; lisp-mnt.el --- minor mode for Emacs Lisp maintainers | 1 | ;;; lisp-mnt.el --- minor mode for Emacs Lisp maintainers |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1992, 1994, 1997, 2000 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1992, 1994, 1997, 2000, 2001 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> | 5 | ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -134,6 +134,11 @@ then $identifier: doc string $ is used by GNU ident(1)" | |||
| 134 | :type 'regexp | 134 | :type 'regexp |
| 135 | :group 'lisp-mnt) | 135 | :group 'lisp-mnt) |
| 136 | 136 | ||
| 137 | (defcustom lm-copyright-prefix "^;+[ \t]+Copyright (C) " | ||
| 138 | "Prefix that is ignored before the dates in a copyright." | ||
| 139 | :type 'regexp | ||
| 140 | :group 'lisp-mnt) | ||
| 141 | |||
| 137 | (defcustom lm-comment-column 16 | 142 | (defcustom lm-comment-column 16 |
| 138 | "Column used for placing formatted output." | 143 | "Column used for placing formatted output." |
| 139 | :type 'integer | 144 | :type 'integer |
| @@ -196,6 +201,15 @@ If AFTER is non-nil, return the location of the next line." | |||
| 196 | "Return the buffer location of the `History' start marker." | 201 | "Return the buffer location of the `History' start marker." |
| 197 | (lm-section-mark lm-history-header)) | 202 | (lm-section-mark lm-history-header)) |
| 198 | 203 | ||
| 204 | (defsubst lm-copyright-mark () | ||
| 205 | "Return the buffer location of the `Copyright' line." | ||
| 206 | (save-excursion | ||
| 207 | (let ((case-fold-search t)) | ||
| 208 | (goto-char (point-min)) | ||
| 209 | (if (re-search-forward lm-copyright-prefix nil t) | ||
| 210 | (point)))) | ||
| 211 | ) | ||
| 212 | |||
| 199 | (defun lm-header (header) | 213 | (defun lm-header (header) |
| 200 | "Return the contents of the header named HEADER." | 214 | "Return the contents of the header named HEADER." |
| 201 | (goto-char (point-min)) | 215 | (goto-char (point-min)) |
| @@ -231,6 +245,8 @@ The returned value is a list of strings, one per line." | |||
| 231 | ;; These give us smart access to the header fields and commentary | 245 | ;; These give us smart access to the header fields and commentary |
| 232 | 246 | ||
| 233 | (defmacro lm-with-file (file &rest body) | 247 | (defmacro lm-with-file (file &rest body) |
| 248 | "Make a buffer with FILE current, and execute BODY. | ||
| 249 | If FILE isn't in a buffer, load it in, and kill it after BODY is executed." | ||
| 234 | (let ((filesym (make-symbol "file"))) | 250 | (let ((filesym (make-symbol "file"))) |
| 235 | `(save-excursion | 251 | `(save-excursion |
| 236 | (let ((,filesym ,file)) | 252 | (let ((,filesym ,file)) |
| @@ -241,6 +257,22 @@ The returned value is a list of strings, one per line." | |||
| 241 | (put 'lm-with-file 'lisp-indent-function 1) | 257 | (put 'lm-with-file 'lisp-indent-function 1) |
| 242 | (put 'lm-with-file 'edebug-form-spec t) | 258 | (put 'lm-with-file 'edebug-form-spec t) |
| 243 | 259 | ||
| 260 | (defun lm-crack-copyright (&optional file) | ||
| 261 | "Return the copyright holder, and a list of copyright years. | ||
| 262 | Use the current buffer if FILE is nil. | ||
| 263 | Return argument is of the form (\"HOLDER\" \"YEAR1\" ... \"YEARN\")" | ||
| 264 | (lm-with-file file | ||
| 265 | (goto-char (lm-copyright-mark)) | ||
| 266 | (let ((holder nil) | ||
| 267 | (years nil) | ||
| 268 | (end (line-end-position))) | ||
| 269 | (while (re-search-forward "\\([0-9]+\\),? +" end t) | ||
| 270 | (setq years (cons (match-string-no-properties 1) years))) | ||
| 271 | (if (looking-at ".*$") | ||
| 272 | (setq holder (match-string-no-properties 0))) | ||
| 273 | (cons holder (nreverse years)) | ||
| 274 | ))) | ||
| 275 | |||
| 244 | (defun lm-summary (&optional file) | 276 | (defun lm-summary (&optional file) |
| 245 | "Return the one-line summary of file FILE, or current buffer if FILE is nil." | 277 | "Return the one-line summary of file FILE, or current buffer if FILE is nil." |
| 246 | (lm-with-file file | 278 | (lm-with-file file |
| @@ -370,8 +402,10 @@ tags `Code', `Change Log' or `History'." | |||
| 370 | 402 | ||
| 371 | (defun lm-verify (&optional file showok verb) | 403 | (defun lm-verify (&optional file showok verb) |
| 372 | "Check that the current buffer (or FILE if given) is in proper format. | 404 | "Check that the current buffer (or FILE if given) is in proper format. |
| 373 | If FILE is a directory, recurse on its files and generate a report in | 405 | If FILE is a directory, recurse on its files and generate a report in a |
| 374 | a temporary buffer." | 406 | temporary buffer. |
| 407 | Optional argument SHOWOK indicates that \"OK\" be displayed in the temp buffer. | ||
| 408 | Optional argument VERB specifies verbosity." | ||
| 375 | (interactive) | 409 | (interactive) |
| 376 | (let* ((verb (or verb (interactive-p))) | 410 | (let* ((verb (or verb (interactive-p))) |
| 377 | (ret (and verb "Ok.")) | 411 | (ret (and verb "Ok.")) |
| @@ -419,6 +453,11 @@ a temporary buffer." | |||
| 419 | "\\|^;;;[ \t]+ End of file[ \t]+" name) | 453 | "\\|^;;;[ \t]+ End of file[ \t]+" name) |
| 420 | nil t))) | 454 | nil t))) |
| 421 | (format "Can't find a footer line for [%s]" name)) | 455 | (format "Can't find a footer line for [%s]" name)) |
| 456 | ((not (and (lm-copyright-mark) (lm-crack-copyright))) | ||
| 457 | "Can't find a valid Copyright") | ||
| 458 | ((not (string-match "Free Software Foundation" | ||
| 459 | (car (lm-crack-copyright)))) | ||
| 460 | "Copyright Holder is not the Free Software Foundation.") | ||
| 422 | (t | 461 | (t |
| 423 | ret))))) | 462 | ret))))) |
| 424 | (if verb | 463 | (if verb |