Mercurial > emacs
changeset 42139:5258f3b81740
(lm-copyright-prefix): Group the leader.
(lm-crack-copyright): Cope with multi-line copyright `lines'.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 18 Dec 2001 16:30:26 +0000 |
parents | 184ca0b7cd7b |
children | 49087a9d073e |
files | lisp/emacs-lisp/lisp-mnt.el |
diffstat | 1 files changed, 35 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/emacs-lisp/lisp-mnt.el Tue Dec 18 16:16:14 2001 +0000 +++ b/lisp/emacs-lisp/lisp-mnt.el Tue Dec 18 16:30:26 2001 +0000 @@ -128,6 +128,9 @@ :prefix "lm-" :group 'maint) +;; At least some of these defcustoms should probably be defconsts, +;; since they define, or are defined by, the header format. -- fx + (defcustom lm-header-prefix "^;+[ \t]+\\(@(#)\\)?[ \t]*\\$?" "Prefix that is ignored before the tag. For example, you can write the 1st line synopsis string and headers like this @@ -142,8 +145,9 @@ :type 'regexp :group 'lisp-mnt) -(defcustom lm-copyright-prefix "^;+[ \t]+Copyright (C) " - "Prefix that is ignored before the dates in a copyright." +(defcustom lm-copyright-prefix "^\\(;+[ \t]\\)+Copyright (C) " + "Prefix that is ignored before the dates in a copyright. +Leading comment characters and whitespace should be in regexp group 1." :type 'regexp :group 'lisp-mnt) @@ -265,6 +269,9 @@ (put 'lm-with-file 'lisp-indent-function 1) (put 'lm-with-file 'edebug-form-spec t) +;; 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. @@ -273,13 +280,33 @@ (goto-char (lm-copyright-mark)) (let ((holder nil) (years nil) + (start (point)) (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)) - ))) + ;; Cope with multi-line copyright `lines'. Assume the second + ;; line is indented (with the same commenting style). + (save-excursion + (beginning-of-line 2) + (let ((str (concat (match-string-no-properties 1) "[ \t]+"))) + (beginning-of-line) + (while (looking-at str) + (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))))) (defun lm-summary (&optional file) "Return the one-line summary of file FILE, or current buffer if FILE is nil."