annotate lisp/modes/lisp-mnt.el @ 128:13db4aa44a2e

Added tag xemacs-20-1p2 for changeset 7b236889ca3a
author cvs
date Mon, 13 Aug 2007 09:28:11 +0200
parents 131b0175ea99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; lisp-mnt.el --- minor mode for Emacs Lisp maintainers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3 ;; Copyright (C) 1992, 1994 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Maintainer: Eric S. Raymond <esr@snark.thyrsus.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Created: 14 Jul 1992
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 2
diff changeset
8 ;; Version: $Id: lisp-mnt.el,v 1.1.1.1 1996/12/18 22:42:47 steve Exp $
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Keywords: docs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; X-Modified-by: Bob Weiner <weiner@mot.com>, 4/14/95, to support InfoDock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; X-Bogus-Bureaucratic-Cruft: Gruad will get you if you don't watch out!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; along with XEmacs; see the file COPYING. If not, write to the Free
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
28 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
29 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
31 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; This minor mode adds some services to Emacs-Lisp editing mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; First, it knows about the header conventions for library packages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; One entry point supports generating synopses from a library directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; Another can be used to check for missing headers in library files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Another entry point automatically addresses bug mail to a package's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; maintainer or author.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; This file can be loaded by your lisp-mode-hook. Have it (require 'lisp-mnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; This file is an example of the header conventions. Note the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; features:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; * Header line --- makes it possible to extract a one-line summary of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; the package's uses automatically for use in library synopses, KWIC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; indexes and the like.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; Format is three semicolons, followed by the filename, followed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; three dashes, followed by the summary. All fields space-separated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; * Author line --- contains the name and net address of at least
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; the principal author.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; If there are multiple authors, they should be listed on continuation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; lines led by ;;<TAB>, like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; ;; Author: Ashwin Ram <Ram-Ashwin@cs.yale.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; ;; Dave Sill <de5@ornl.gov>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; ;; David Lawrence <tale@pawl.rpi.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; ;; Noah Friedman <friedman@ai.mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; ;; Joe Wells <jbw@maverick.uswest.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; ;; Dave Brennan <brennan@hal.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; ;; Eric Raymond <esr@snark.thyrsus.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; This field may have some special values; notably "FSF", meaning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; "Free Software Foundation".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; * Maintainer line --- should be a single name/address as in the Author
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; line, or an address only, or the string "FSF". If there is no maintainer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; line, the person(s) in the Author field are presumed to be it. The example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; in this file is mildly bogus because the maintainer line is redundant.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
77 ;; The idea behind these two fields is to be able to write a Lisp function
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; that does "send mail to the author" without having to mine the name out by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; hand. Please be careful about surrounding the network address with <> if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; there's also a name in the field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; * Created line --- optional, gives the original creation date of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; file. For historical interest, basically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; * Version line --- intended to give the reader a clue if they're looking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; at a different version of the file than the one they're accustomed to. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; may be an RCS or SCCS header.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; * Adapted-By line --- this is for FSF's internal use. The person named
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; in this field was the one responsible for installing and adapting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; package for the distribution. (This file doesn't have one because the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; author *is* one of the maintainers.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; * Keywords line --- used by the finder code (now under construction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; for finding Emacs Lisp code related to a topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; * X-Bogus-Bureaucratic-Cruft line --- this is a joke and an example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; of a comment header. Headers starting with `X-' should never be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; for any real purpose; this is the way to safely add random headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; without invoking the wrath of any program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
102 ;; * Commentary line --- enables Lisp code to find the developer's and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; maintainers' explanations of the package internals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; * Change log line --- optional, exists to terminate the commentary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; section and start a change-log part, if one exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; * Code line --- exists so Lisp can know where commentary and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; change-log sections end.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; * Footer line --- marks end-of-file so it can be distinguished from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; an expanded formfeed or the results of truncation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; Change Log:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; Tue Jul 14 23:44:17 1992 ESR
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; * Created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (require 'picture) ; provides move-to-column-force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (require 'emacsbug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 ;;; Variables:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
125
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126 (defvar lm-header-prefix "^;;*[ \t]+\\(@\(#\)\\)?[ \t]*\\([\$]\\)?"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
127 "Prefix that is ignored before the tag.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
128 For example, you can write the 1st line synopsis string and headers like this
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
129 in your Lisp package:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
130
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
131 ;; @(#) package.el -- pacakge description
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
132 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 ;; @(#) $Maintainer: Person Foo Bar $
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
134
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
135 The @(#) construct is used by unix what(1) and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
136 then $identifier: doc string $ is used by GNU ident(1)")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
137
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
138 (defvar lm-comment-column 16
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
139 "Column used for placing formatted output.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
140
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
141 (defvar lm-commentary-header "Commentary\\|Documentation"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
142 "Regexp which matches start of documentation section.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
143
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
144 (defvar lm-history-header "Change Log\\|History"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
145 "Regexp which matches the start of code log section.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
146
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
147 ;;; Functions:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
148
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; These functions all parse the headers of the current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
151 (defsubst lm-get-header-re (header &optional mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
152 "Returns regexp for matching HEADER.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
153 If called with optional MODE and with value `section',
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
154 return section regexp instead."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
155 (cond ((eq mode 'section)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
156 (concat "^;;;;* " header ":[ \t]*$"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
157 (t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
158 (concat lm-header-prefix header ":[ \t]*"))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
159
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
160 (defsubst lm-get-package-name ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
161 "Returns package name by looking at the first line."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
162 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
163 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
164 (if (and (looking-at (concat lm-header-prefix))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
165 (progn (goto-char (match-end 0))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
166 (looking-at "\\([^\t ]+\\)")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
167 (match-end 1)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
168 (buffer-substring (match-beginning 1) (match-end 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
169 )))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
170
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
171 (defun lm-section-mark (header &optional after)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
172 "Return the buffer location of a given section start marker.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
173 The HEADER is the section mark string to search for.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
174 If AFTER is non-nil, return the location of the next line."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (goto-char (point-min))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
178 (if (re-search-forward (lm-get-header-re header 'section) nil t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
179 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
180 (beginning-of-line)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
181 (if after (forward-line 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
182 (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
183 nil))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
185 (defsubst lm-code-mark ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
186 "Return the buffer location of the `Code' start marker."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
187 (lm-section-mark "Code"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
188
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
189 (defsubst lm-commentary-mark ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
190 "Return the buffer location of the `Commentary' start marker."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
191 (lm-section-mark lm-commentary-header))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
193 (defsubst lm-history-mark ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
194 "Return the buffer location of the `History' start marker."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
195 (lm-section-mark lm-history-header))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
197 (defun lm-header (header)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
198 "Return the contents of the header named HEADER."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
199 (goto-char (point-min))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
200 (let ((case-fold-search t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
201 (if (and (re-search-forward (lm-get-header-re header) (lm-code-mark) t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
202 ;; RCS ident likes format "$identifier: data$"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
203 (looking-at "\\([^$\n]+\\)")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
204 (match-end 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
205 (buffer-substring (match-beginning 1) (match-end 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
206 nil)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
207
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
208 (defun lm-header-multiline (header)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
209 "Return the contents of the header named HEADER, with continuation lines.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
210 The returned value is a list of strings, one per line."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (goto-char (point-min))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
213 (let ((res (lm-header header)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
214 (cond
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
215 (res
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
216 (setq res (list res))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
217 (forward-line 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
218
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
219 (while (and (looking-at (concat lm-header-prefix "[\t ]+"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
220 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
221 (goto-char (match-end 0))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
222 (looking-at "\\(.*\\)"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
223 (match-end 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
224 (setq res (cons (buffer-substring
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
225 (match-beginning 1)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
226 (match-end 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
227 res))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
228 (forward-line 1))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
229 ))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
230 res
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
231 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;; These give us smart access to the header fields and commentary
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (defun lm-summary (&optional file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
236 "Return the one-line summary of file FILE, or current buffer if FILE is nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (prog1
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
242 (if (and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
243 (looking-at lm-header-prefix)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
244 (progn (goto-char (match-end 0))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
245 (looking-at "[^ ]+[ \t]+--+[ \t]+\\(.*\\)")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun lm-crack-address (x)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
252 "Split up an email address into full name and real email address.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
253 The value is a cons of the form (FULLNAME . ADDRESS)."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (cond ((string-match "\\(.+\\) [(<]\\(\\S-+@\\S-+\\)[>)]" x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (cons (substring x (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (substring x (match-beginning 2) (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ((string-match "\\(\\S-+@\\S-+\\) [(<]\\(.*\\)[>)]" x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (cons (substring x (match-beginning 2) (match-end 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (substring x (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ((string-match "\\S-+@\\S-+" x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (cons nil x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (cons x nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defun lm-authors (&optional file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
266 "Return the author list of file FILE, or current buffer if FILE is nil.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
267 Each element of the list is a cons; the car is the full name,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
268 the cdr is an email address."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (find-file file))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
272 ;; XEmacs change (Is E-MAIL an infodock header? -sb)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (let* ((authorlist (lm-header-multiline "author"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (email-list (lm-header-multiline "E-MAIL"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (authors authorlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (if (null email-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (mapcar 'lm-crack-address authorlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (while (and email-list authors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (setcar authors (cons (car authors) (car email-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (setq email-list (cdr email-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 authors (cdr authors)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 authorlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (if file
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
285 (kill-buffer (current-buffer))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
286 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (defun lm-maintainer (&optional file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
289 "Return the maintainer of file FILE, or current buffer if FILE is nil.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
290 The return value has the form (NAME . ADDRESS)."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (let ((maint (lm-header "maintainer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (if maint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (lm-crack-address maint)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (car (lm-authors))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defun lm-creation-date (&optional file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
303 "Return the created date given in file FILE, or current buffer if FILE is nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (prog1
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
308 ;; XEmacs change (Is ORIG-DATE an Infodock header? -sb)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (or (lm-header "created")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (let ((date-and-time (lm-header "ORIG-DATE")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (if date-and-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (substring date-and-time 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (string-match " " date-and-time)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (if file
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
315 (kill-buffer (current-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
316 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (defun lm-last-modified-date (&optional file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
319 "Return the modify-date given in file FILE, or current buffer if FILE is nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (if (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "\\$Id: [^ ]+ [^ ]+ \\([^/]+\\)/\\([^/]+\\)/\\([^ ]+\\) "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (lm-code-mark) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (format "%s %s %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (buffer-substring (match-beginning 3) (match-end 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (nth (string-to-int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (buffer-substring (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 '("" "Jan" "Feb" "Mar" "Apr" "May" "Jun"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (buffer-substring (match-beginning 1) (match-end 1)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
336 ;; XEmacs change (Infodock change? -sb)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (let ((date-and-time (lm-header "LAST-MOD")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (if date-and-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (substring date-and-time 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (string-match " " date-and-time)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (if file
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
342 (kill-buffer (current-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
343 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (defun lm-version (&optional file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
346 "Return the version listed in file FILE, or current buffer if FILE is nil.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
347 This can befound in an RCS or SCCS header to crack it out of."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (lm-header "version")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (let ((header-max (lm-code-mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;; Look for an RCS header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ((re-search-forward "\\$Id: [^ ]+ \\([^ ]+\\) " header-max t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;; Look for an SCCS header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ((re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (regexp-quote "@(#)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (regexp-quote (file-name-nondirectory (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 "\t\\([012345679.]*\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 header-max t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (t nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (if file
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
372 (kill-buffer (current-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
373 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (defun lm-keywords (&optional file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
376 "Return the keywords given in file FILE, or current buffer if FILE is nil."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (let ((keywords (lm-header "keywords")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (and keywords (downcase keywords)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (if file
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
384 (kill-buffer (current-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
385 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defun lm-adapted-by (&optional file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
388 "Return the adapted-by names in file FILE, or current buffer if FILE is nil.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
389 This is the name of the person who cleaned up this package for
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
390 distribution."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (lm-header "adapted-by")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (if file
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
397 (kill-buffer (current-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
398 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (defun lm-commentary (&optional file)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
401 "Return the commentary in file FILE, or current buffer if FILE is nil.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
402 The value is returned as a string. In the text, the commentary starts
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
403 with tag `Commentary' and ends with tag `Change Log' or `History'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (prog1
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
408 (let ((commentary (lm-commentary-mark))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
409 (change-log (lm-history-mark))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
410 (code (lm-code-mark))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
411 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
412 (cond
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
413 ((and commentary change-log)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
414 (buffer-substring commentary change-log))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
415 ((and commentary code)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
416 (buffer-substring commentary code))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
417 (t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
418 ;; XEmacs change (Infodock headers? -sb)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (setq commentary (lm-section-mark "DESCRIPTION" t)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
420 code (lm-section-mark "DESCRIP-END"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
421 (and commentary end (buffer-substring commentary code)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (if file
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
423 (kill-buffer (current-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
424 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;;; Verification and synopses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
428 (defun lm-insert-at-column (col &rest strings)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
429 "Insert list of STRINGS, at column COL."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (if (> (current-column) col) (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (move-to-column-force col)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
432 (apply 'insert strings))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
433
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
434 (defun lm-verify (&optional file showok &optional verb)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
435 "Check that the current buffer (or FILE if given) is in proper format.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
436 If FILE is a directory, recurse on its files and generate a report in
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
437 a temporary buffer."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
438 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
439 (let* ((verb (or verb (interactive-p)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
440 ret
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
441 name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
442 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
443 (if verb
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
444 (setq ret "Ok.")) ;init value
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
446 (if (and file (file-directory-p file))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
447 (setq
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
448 ret
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
449 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
450 (switch-to-buffer (get-buffer-create "*lm-verify*"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
451 (erase-buffer)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
452 (mapcar
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
453 '(lambda (f)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
454 (if (string-match ".*\\.el$" f)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
455 (let ((status (lm-verify f)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
456 (if status
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
457 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
458 (insert f ":")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
459 (lm-insert-at-column lm-comment-column status "\n"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
460 (and showok
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
461 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
462 (insert f ":")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
463 (lm-insert-at-column lm-comment-column "OK\n")))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
464 (directory-files file))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
465 ))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
466 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
467 (if file
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
468 (find-file file))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
469 (setq name (lm-get-package-name))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
470
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
471 (setq
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
472 ret
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
473 (prog1
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
474 (cond
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
475 ((null name)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
476 "Can't find a package NAME")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
478 ((not (lm-authors))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
479 "Author: tag missing.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
480
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
481 ((not (lm-maintainer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
482 "Maintainer: tag missing.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
483
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
484 ((not (lm-summary))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
485 "Can't find a one-line 'Summary' description")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
486
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
487 ((not (lm-keywords))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
488 "Keywords: tag missing.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
489
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
490 ((not (lm-commentary-mark))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
491 "Can't find a 'Commentary' section marker.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
492
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
493 ((not (lm-history-mark))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
494 "Can't find a 'History' section marker.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
495
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
496 ((not (lm-code-mark))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
497 "Can't find a 'Code' section marker")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
498
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
499 ((progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
500 (goto-char (point-max))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
501 (not
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
502 (re-search-backward
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
503 (concat "^;;;[ \t]+" name "[ \t]+ends here[ \t]*$"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
504 "\\|^;;;[ \t]+ End of file[ \t]+" name)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
505 nil t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
506 )))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
507 (format "Can't find a footer line for [%s]" name))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
508 (t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
509 ret))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
510 (if file
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
511 (kill-buffer (current-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
512 ))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
513 (if verb
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
514 (message ret))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
515 ret
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
516 ))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
517
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
518 (defun lm-synopsis (&optional file showall)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
519 "Generate a synopsis listing for the buffer or the given FILE if given.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
520 If FILE is a directory, recurse on its files and generate a report in
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
521 a temporary buffer. If SHOWALL is non-nil, also generate a line for files
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
522 which do not include a recognizable synopsis."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
523 (interactive
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
524 (list
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
525 (read-file-name "Synopsis for (file or dir): ")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
526
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (if (and file (file-directory-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (switch-to-buffer (get-buffer-create "*lm-verify*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (mapcar
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
532 '(lambda (f)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (if (string-match ".*\\.el$" f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (let ((syn (lm-synopsis f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (if syn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (insert f ":")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
538 (lm-insert-at-column lm-comment-column syn "\n"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (and showall
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (insert f ":")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
542 (lm-insert-at-column lm-comment-column "NA\n")))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
543 (directory-files file))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
544 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (lm-summary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (if file
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
551 (kill-buffer (current-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
552 ))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (defun lm-report-bug (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 "Report a bug in the package currently being visited to its maintainer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 Prompts for bug subject. Leaves you in a mail buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (interactive "sBug Subject: ")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
558 (let ((package (lm-get-package-name))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
559 (addr (lm-maintainer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
560 (version (lm-version)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (mail nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (if addr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (concat (car addr) " <" (cdr addr) ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 bug-gnu-emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (insert "\nIn "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (if version (concat " version " version) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (substitute-command-keys "Type \\[mail-send] to send bug report."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (provide 'lisp-mnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ;;; lisp-mnt.el ends here