128 |
:prefix "lm-" |
:prefix "lm-" |
129 |
:group 'maint) |
:group 'maint) |
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 |
|
|
134 |
(defcustom lm-header-prefix "^;+[ \t]+\\(@(#)\\)?[ \t]*\\$?" |
(defcustom lm-header-prefix "^;+[ \t]+\\(@(#)\\)?[ \t]*\\$?" |
135 |
"Prefix that is ignored before the tag. |
"Prefix that is ignored before the tag. |
136 |
For example, you can write the 1st line synopsis string and headers like this |
For example, you can write the 1st line synopsis string and headers like this |
145 |
:type 'regexp |
:type 'regexp |
146 |
:group 'lisp-mnt) |
:group 'lisp-mnt) |
147 |
|
|
148 |
(defcustom lm-copyright-prefix "^;+[ \t]+Copyright (C) " |
(defcustom lm-copyright-prefix "^\\(;+[ \t]\\)+Copyright (C) " |
149 |
"Prefix that is ignored before the dates in a copyright." |
"Prefix that is ignored before the dates in a copyright. |
150 |
|
Leading comment characters and whitespace should be in regexp group 1." |
151 |
:type 'regexp |
:type 'regexp |
152 |
:group 'lisp-mnt) |
:group 'lisp-mnt) |
153 |
|
|
269 |
(put 'lm-with-file 'lisp-indent-function 1) |
(put 'lm-with-file 'lisp-indent-function 1) |
270 |
(put 'lm-with-file 'edebug-form-spec t) |
(put 'lm-with-file 'edebug-form-spec t) |
271 |
|
|
272 |
|
;; Fixme: Probably this should be amalgamated with copyright.el; also |
273 |
|
;; we need a check for ranges in copyright years. |
274 |
|
|
275 |
(defun lm-crack-copyright (&optional file) |
(defun lm-crack-copyright (&optional file) |
276 |
"Return the copyright holder, and a list of copyright years. |
"Return the copyright holder, and a list of copyright years. |
277 |
Use the current buffer if FILE is nil. |
Use the current buffer if FILE is nil. |
280 |
(goto-char (lm-copyright-mark)) |
(goto-char (lm-copyright-mark)) |
281 |
(let ((holder nil) |
(let ((holder nil) |
282 |
(years nil) |
(years nil) |
283 |
|
(start (point)) |
284 |
(end (line-end-position))) |
(end (line-end-position))) |
285 |
(while (re-search-forward "\\([0-9]+\\),? +" end t) |
;; Cope with multi-line copyright `lines'. Assume the second |
286 |
(setq years (cons (match-string-no-properties 1) years))) |
;; line is indented (with the same commenting style). |
287 |
(if (looking-at ".*$") |
(save-excursion |
288 |
(setq holder (match-string-no-properties 0))) |
(beginning-of-line 2) |
289 |
(cons holder (nreverse years)) |
(let ((str (concat (match-string-no-properties 1) "[ \t]+"))) |
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))))) |
310 |
|
|
311 |
(defun lm-summary (&optional file) |
(defun lm-summary (&optional file) |
312 |
"Return the one-line summary of file FILE, or current buffer if FILE is nil." |
"Return the one-line summary of file FILE, or current buffer if FILE is nil." |