emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lm-maint patch


From: Eric M. Ludlam
Subject: lm-maint patch
Date: Mon, 11 Dec 2000 13:15:07 -0500

In response to Dave Love's recent copyright message, the following
patch lets lm-maint check to make sure that an Emacs Lisp file's
copyright is valid.

Does this quick hack seem ok?
Is Eric Raymond still maintaining this file?

Eric
-------------
*** lisp-mnt.el.~1.28.~ Sat Sep 16 21:00:09 2000
--- lisp-mnt.el Mon Dec 11 13:13:17 2000
***************
*** 134,139 ****
--- 134,144 ----
    :type 'regexp
    :group 'lisp-mnt)
  
+ (defcustom lm-copyright-prefix "^;+[ \t]+Copyright (C) "
+   "Prefix that is ignored before the dates in a copyright."
+   :type 'regexp
+   :group 'lisp-mnt)
+ 
  (defcustom lm-comment-column 16
    "Column used for placing formatted output."
    :type 'integer
***************
*** 196,201 ****
--- 201,215 ----
    "Return the buffer location of the `History' start marker."
    (lm-section-mark lm-history-header))
  
+ (defsubst lm-copyright-mark ()
+   "Return the buffer location of the `Copyright' line."
+   (save-excursion
+     (let ((case-fold-search t))
+       (goto-char (point-min))
+       (if (re-search-forward lm-copyright-prefix nil t)
+         (point))))
+   )
+ 
  (defun lm-header (header)
    "Return the contents of the header named HEADER."
    (goto-char (point-min))
***************
*** 231,236 ****
--- 245,252 ----
  ;; These give us smart access to the header fields and commentary
  
  (defmacro lm-with-file (file &rest body)
+   "Make a buffer with FILE current, and execute BODY.
+ If FILE isn't in a buffer, load it in, and kill it after BODY is executed."
    (let ((filesym (make-symbol "file")))
      `(save-excursion
         (let ((,filesym ,file))
***************
*** 241,246 ****
--- 257,278 ----
  (put 'lm-with-file 'lisp-indent-function 1)
  (put 'lm-with-file 'edebug-form-spec t)
  
+ (defun lm-crack-copyright (&optional file)
+   "Return the copyright holder, and a list of copyright years.
+ Use the current buffer if FILE is nil.
+ Return argument is of the form (\"HOLDER\" \"YEAR1\" ... \"YEARN\")"
+   (lm-with-file file
+     (goto-char (lm-copyright-mark))
+     (let ((holder nil)
+         (years nil)
+         (end (line-end-position)))
+       (while (re-search-forward "\\([0-9]+\\),? +" end t)
+       (setq years (cons (match-string-no-properties 1) years)))
+       (if (looking-at ".*$")
+         (setq holder (match-string-no-properties 0)))
+       (cons holder (nreverse years))
+     )))
+ 
  (defun lm-summary (&optional file)
    "Return the one-line summary of file FILE, or current buffer if FILE is 
nil."
    (lm-with-file file
***************
*** 370,377 ****
  
  (defun lm-verify (&optional file showok verb)
    "Check that the current buffer (or FILE if given) is in proper format.
! If FILE is a directory, recurse on its files and generate a report in
! a temporary buffer."
    (interactive)
    (let* ((verb (or verb (interactive-p)))
         (ret (and verb "Ok."))
--- 402,411 ----
  
  (defun lm-verify (&optional file showok verb)
    "Check that the current buffer (or FILE if given) is in proper format.
! If FILE is a directory, recurse on its files and generate a report in a
! temporary buffer.
! Optional argument SHOWOK indicates that \"OK\" be displayed in the temp 
buffer.
! Optional argument VERB specifies verbosity."
    (interactive)
    (let* ((verb (or verb (interactive-p)))
         (ret (and verb "Ok."))
***************
*** 419,424 ****
--- 453,463 ----
                            "\\|^;;;[ \t]+ End of file[ \t]+" name)
                    nil t)))
                (format "Can't find a footer line for [%s]" name))
+              ((not (and (lm-copyright-mark) (lm-crack-copyright)))
+               "Can't find a valid Copyright")
+              ((not (string-match "Free Software Foundation"
+                                  (car (lm-crack-copyright))))
+               "Copyright Holder is not the Free Software Foundation.")
               (t
                ret)))))
      (if verb



reply via email to

[Prev in Thread] Current Thread [Next in Thread]