Function: lm-crack-copyright

lm-crack-copyright is a byte-compiled function defined in lisp-mnt.el.gz.

Signature

(lm-crack-copyright &optional FILE)

Documentation

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")

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/lisp-mnt.el.gz
;; Fixme: Probably this should be amalgamated with copyright.el; also
;; we need a check for ranges in copyright years.

(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)
	  (start (point))
	  (end (line-end-position)))
      ;; Cope with multi-line copyright `lines'.  Assume the second
      ;; line is indented at least as much as the original, with the
      ;; same commenting style.
      (save-excursion
	(beginning-of-line 2)
	(let ((str (match-string-no-properties 1)))
	  (beginning-of-line)
	  (while (and (looking-at str) (not (looking-at lm-copyright-prefix)))
	    (setq end (line-end-position))
	    (beginning-of-line 2))))
      ;; Make a single line and parse that.
      (let ((buff (current-buffer)))
	(with-temp-buffer
	  (insert-buffer-substring buff start end)
	  (goto-char (point-min))
	  (while (re-search-forward "^;+[ \t]+" nil t)
	    (replace-match ""))
	  (goto-char (point-min))
	  (while (re-search-forward " *\n" nil t)
	    (replace-match " "))
	  (goto-char (point-min))
	  (while (re-search-forward "\\([0-9]+\\),? +" nil t)
	    (setq years (cons (match-string-no-properties 1) years)))
	  (if (looking-at ".*$")
	      (setq holder (match-string-no-properties 0)))))
      (cons holder (nreverse years)))))