diff options
| author | Stefan Monnier | 2000-09-17 01:00:09 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-09-17 01:00:09 +0000 |
| commit | 438cdcdeb04b08aefdc5450d7eddbffa21e44f2d (patch) | |
| tree | 5b3d897825635c5b1460792385283f5ea813e43b | |
| parent | 40716cd9c4d41db83dd06cb88dd087eede602f01 (diff) | |
| download | emacs-438cdcdeb04b08aefdc5450d7eddbffa21e44f2d.tar.gz emacs-438cdcdeb04b08aefdc5450d7eddbffa21e44f2d.zip | |
(lm-get-header-re): Allow spaces between the header and the colon.
(lm-header-prefix): Cleanup the regexp.
(lm-header): Allow $ in non-RCS headers.
(lm-header-multiline): Put the strings back into order.
Stop at an empty line. Don't require two space chars if the
line is clearly not another header line.
| -rw-r--r-- | lisp/emacs-lisp/lisp-mnt.el | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index 2f50541fe6f..c5e61dfbd1e 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el | |||
| @@ -120,7 +120,7 @@ | |||
| 120 | :prefix "lm-" | 120 | :prefix "lm-" |
| 121 | :group 'maint) | 121 | :group 'maint) |
| 122 | 122 | ||
| 123 | (defcustom lm-header-prefix "^;;*[ \t]+\\(@\(#\)\\)?[ \t]*\\([\$]\\)?" | 123 | (defcustom lm-header-prefix "^;+[ \t]+\\(@(#)\\)?[ \t]*\\$?" |
| 124 | "Prefix that is ignored before the tag. | 124 | "Prefix that is ignored before the tag. |
| 125 | For example, you can write the 1st line synopsis string and headers like this | 125 | For example, you can write the 1st line synopsis string and headers like this |
| 126 | in your Lisp package: | 126 | in your Lisp package: |
| @@ -157,10 +157,9 @@ then $identifier: doc string $ is used by GNU ident(1)" | |||
| 157 | "Return regexp for matching HEADER. | 157 | "Return regexp for matching HEADER. |
| 158 | If called with optional MODE and with value `section', | 158 | If called with optional MODE and with value `section', |
| 159 | return section regexp instead." | 159 | return section regexp instead." |
| 160 | (cond ((eq mode 'section) | 160 | (if (eq mode 'section) |
| 161 | (concat "^;;;;* " header ":[ \t]*$")) | 161 | (concat "^;;;;* " header ":[ \t]*$") |
| 162 | (t | 162 | (concat lm-header-prefix header "[ \t]*:[ \t]*"))) |
| 163 | (concat lm-header-prefix header ":[ \t]*")))) | ||
| 164 | 163 | ||
| 165 | (defun lm-get-package-name () | 164 | (defun lm-get-package-name () |
| 166 | "Return package name by looking at the first line." | 165 | "Return package name by looking at the first line." |
| @@ -201,11 +200,14 @@ If AFTER is non-nil, return the location of the next line." | |||
| 201 | "Return the contents of the header named HEADER." | 200 | "Return the contents of the header named HEADER." |
| 202 | (goto-char (point-min)) | 201 | (goto-char (point-min)) |
| 203 | (let ((case-fold-search t)) | 202 | (let ((case-fold-search t)) |
| 204 | (if (and (re-search-forward (lm-get-header-re header) (lm-code-mark) t) | 203 | (when (and (re-search-forward (lm-get-header-re header) (lm-code-mark) t) |
| 205 | ;; RCS ident likes format "$identifier: data$" | 204 | ;; RCS ident likes format "$identifier: data$" |
| 206 | (looking-at "\\([^$\n]+\\)") | 205 | (looking-at |
| 207 | (match-end 1)) | 206 | (if (save-excursion |
| 208 | (match-string-no-properties 1)))) | 207 | (skip-chars-backward "^$" (match-beginning 0)) |
| 208 | (= (point) (match-beginning 0))) | ||
| 209 | "[^\n]+" "[^$\n]+"))) | ||
| 210 | (match-string-no-properties 0)))) | ||
| 209 | 211 | ||
| 210 | (defun lm-header-multiline (header) | 212 | (defun lm-header-multiline (header) |
| 211 | "Return the contents of the header named HEADER, with continuation lines. | 213 | "Return the contents of the header named HEADER, with continuation lines. |
| @@ -216,14 +218,15 @@ The returned value is a list of strings, one per line." | |||
| 216 | (when res | 218 | (when res |
| 217 | (setq res (list res)) | 219 | (setq res (list res)) |
| 218 | (forward-line 1) | 220 | (forward-line 1) |
| 219 | (while (and (looking-at (concat lm-header-prefix "[\t ]+")) | 221 | (while (and (or (looking-at (concat lm-header-prefix "[\t ]+")) |
| 220 | (progn | 222 | (and (not (looking-at |
| 221 | (goto-char (match-end 0)) | 223 | (lm-get-header-re "\\sw\\(\\sw\\|\\s_\\)*"))) |
| 222 | (looking-at "\\(.*\\)")) | 224 | (looking-at lm-header-prefix))) |
| 223 | (match-end 1)) | 225 | (goto-char (match-end 0)) |
| 224 | (setq res (cons (match-string-no-properties 1) res)) | 226 | (looking-at ".+")) |
| 227 | (setq res (cons (match-string-no-properties 0) res)) | ||
| 225 | (forward-line 1))) | 228 | (forward-line 1))) |
| 226 | res))) | 229 | (nreverse res)))) |
| 227 | 230 | ||
| 228 | ;; These give us smart access to the header fields and commentary | 231 | ;; These give us smart access to the header fields and commentary |
| 229 | 232 | ||