aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2001-12-18 16:30:26 +0000
committerDave Love2001-12-18 16:30:26 +0000
commitaf95e0d149d7c4c9ae5674db2bb55d749b371639 (patch)
tree0d28ede551747a868445045f3d58270e30f860b4
parent7c75be3651fd90d159d12c6d7871e0cc6e94a522 (diff)
downloademacs-af95e0d149d7c4c9ae5674db2bb55d749b371639.tar.gz
emacs-af95e0d149d7c4c9ae5674db2bb55d749b371639.zip
(lm-copyright-prefix): Group the leader.
(lm-crack-copyright): Cope with multi-line copyright `lines'.
-rw-r--r--lisp/emacs-lisp/lisp-mnt.el43
1 files changed, 35 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el
index 03d85f5c2d5..bda307198f8 100644
--- a/lisp/emacs-lisp/lisp-mnt.el
+++ b/lisp/emacs-lisp/lisp-mnt.el
@@ -128,6 +128,9 @@
128 :prefix "lm-" 128 :prefix "lm-"
129 :group 'maint) 129 :group 'maint)
130 130
131;; At least some of these defcustoms should probably be defconsts,
132;; since they define, or are defined by, the header format. -- fx
133
131(defcustom lm-header-prefix "^;+[ \t]+\\(@(#)\\)?[ \t]*\\$?" 134(defcustom lm-header-prefix "^;+[ \t]+\\(@(#)\\)?[ \t]*\\$?"
132 "Prefix that is ignored before the tag. 135 "Prefix that is ignored before the tag.
133For example, you can write the 1st line synopsis string and headers like this 136For example, you can write the 1st line synopsis string and headers like this
@@ -142,8 +145,9 @@ then $identifier: doc string $ is used by GNU ident(1)"
142 :type 'regexp 145 :type 'regexp
143 :group 'lisp-mnt) 146 :group 'lisp-mnt)
144 147
145(defcustom lm-copyright-prefix "^;+[ \t]+Copyright (C) " 148(defcustom lm-copyright-prefix "^\\(;+[ \t]\\)+Copyright (C) "
146 "Prefix that is ignored before the dates in a copyright." 149 "Prefix that is ignored before the dates in a copyright.
150Leading comment characters and whitespace should be in regexp group 1."
147 :type 'regexp 151 :type 'regexp
148 :group 'lisp-mnt) 152 :group 'lisp-mnt)
149 153
@@ -265,6 +269,9 @@ If FILE isn't in a buffer, load it in, and kill it after BODY is executed."
265(put 'lm-with-file 'lisp-indent-function 1) 269(put 'lm-with-file 'lisp-indent-function 1)
266(put 'lm-with-file 'edebug-form-spec t) 270(put 'lm-with-file 'edebug-form-spec t)
267 271
272;; Fixme: Probably this should be amalgamated with copyright.el; also
273;; we need a check for ranges in copyright years.
274
268(defun lm-crack-copyright (&optional file) 275(defun lm-crack-copyright (&optional file)
269 "Return the copyright holder, and a list of copyright years. 276 "Return the copyright holder, and a list of copyright years.
270Use the current buffer if FILE is nil. 277Use the current buffer if FILE is nil.
@@ -273,13 +280,33 @@ Return argument is of the form (\"HOLDER\" \"YEAR1\" ... \"YEARN\")"
273 (goto-char (lm-copyright-mark)) 280 (goto-char (lm-copyright-mark))
274 (let ((holder nil) 281 (let ((holder nil)
275 (years nil) 282 (years nil)
283 (start (point))
276 (end (line-end-position))) 284 (end (line-end-position)))
277 (while (re-search-forward "\\([0-9]+\\),? +" end t) 285 ;; Cope with multi-line copyright `lines'. Assume the second
278 (setq years (cons (match-string-no-properties 1) years))) 286 ;; line is indented (with the same commenting style).
279 (if (looking-at ".*$") 287 (save-excursion
280 (setq holder (match-string-no-properties 0))) 288 (beginning-of-line 2)
281 (cons holder (nreverse years)) 289 (let ((str (concat (match-string-no-properties 1) "[ \t]+")))
282 ))) 290 (beginning-of-line)
291 (while (looking-at str)
292 (setq end (line-end-position))
293 (beginning-of-line 2))))
294 ;; Make a single line and parse that.
295 (let ((buff (current-buffer)))
296 (with-temp-buffer
297 (insert-buffer-substring buff start end)
298 (goto-char (point-min))
299 (while (re-search-forward "^;+[ \t]+" nil t)
300 (replace-match ""))
301 (goto-char (point-min))
302 (while (re-search-forward " *\n" nil t)
303 (replace-match " "))
304 (goto-char (point-min))
305 (while (re-search-forward "\\([0-9]+\\),? +" nil t)
306 (setq years (cons (match-string-no-properties 1) years)))
307 (if (looking-at ".*$")
308 (setq holder (match-string-no-properties 0)))))
309 (cons holder (nreverse years)))))
283 310
284(defun lm-summary (&optional file) 311(defun lm-summary (&optional file)
285 "Return the one-line summary of file FILE, or current buffer if FILE is nil." 312 "Return the one-line summary of file FILE, or current buffer if FILE is nil."