Commit | Line | Data |
---|---|---|
55535639 | 1 | ;;; gulp.el --- ask for updates for Lisp packages |
3ecaf18e RS |
2 | |
3 | ;; Copyright (C) 1996 Free Software Foundation, Inc. | |
4 | ||
5 | ;; Author: Sam Shteingold <shteingd@math.ucla.edu> | |
6 | ;; Maintainer: FSF | |
7 | ;; Keywords: maintenance | |
8 | ||
9 | ;; This file is part of GNU Emacs. | |
10 | ||
11 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 | ;; it under the terms of the GNU General Public License as published by | |
13 | ;; the Free Software Foundation; either version 2, or (at your option) | |
14 | ;; any later version. | |
15 | ||
16 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | ;; GNU General Public License for more details. | |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
1fb87c77 KH |
22 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 | ;; Boston, MA 02111-1307, USA. | |
3ecaf18e RS |
25 | |
26 | ;;; Commentary: | |
27 | ||
28 | ;; Search the emacs/{version}/lisp directory for *.el files, extract the | |
29 | ;; name of the author or maintainer and send him e-mail requesting | |
30 | ;; update. | |
31 | ||
32 | ;;; Code: | |
666b9413 SE |
33 | (defgroup gulp nil |
34 | "Ask for updates for Lisp packages." | |
35 | :prefix "-" | |
36 | :group 'maint) | |
37 | ||
38 | (defcustom gulp-discard "^;+ *Maintainer: *FSF *$" | |
39 | "*The regexp matching the packages not requiring the request for updates." | |
40 | :type 'regexp | |
41 | :group 'gulp) | |
42 | ||
43 | (defcustom gulp-tmp-buffer "*gulp*" "The name of the temporary buffer." | |
44 | :type 'string | |
45 | :group 'gulp) | |
46 | ||
47 | (defcustom gulp-max-len 2000 | |
48 | "*Distance into a Lisp source file to scan for keywords." | |
49 | :type 'integer | |
50 | :group 'gulp) | |
51 | ||
52 | (defcustom gulp-request-header | |
8060ee8f RS |
53 | (concat |
54 | "This message was created automatically. | |
b6030d2f RS |
55 | I'm going to start pretesting a new version of GNU Emacs soon, so I'd |
56 | like to ask if you have any updates for the Emacs packages you work on. | |
8060ee8f | 57 | You're listed as the maintainer of the following package(s):\n\n") |
666b9413 SE |
58 | "*The starting text of a gulp message." |
59 | :type 'string | |
60 | :group 'gulp) | |
3ecaf18e | 61 | |
666b9413 | 62 | (defcustom gulp-request-end |
8060ee8f RS |
63 | (concat |
64 | "\nIf you have any changes since the version in the previous release (" | |
65 | (format "%d.%d" emacs-major-version emacs-minor-version) | |
66 | "), | |
67 | please send them to me ASAP. | |
3ecaf18e | 68 | |
b6030d2f RS |
69 | Please don't send the whole file. Instead, please send a patch made with |
70 | `diff -c' that shows precisely the changes you would like me to install. | |
71 | Also please include itemized change log entries for your changes; | |
72 | please use lisp/ChangeLog as a guide for the style and for what kinds | |
73 | of information to include. | |
74 | ||
8060ee8f | 75 | Thanks.") |
666b9413 SE |
76 | "*The closing text in a gulp message." |
77 | :type 'string | |
78 | :group 'gulp) | |
8060ee8f RS |
79 | |
80 | (defun gulp-send-requests (dir &optional time) | |
30585116 | 81 | "Send requests for updates to the authors of Lisp packages in directory DIR. |
8060ee8f RS |
82 | For each maintainer, the message consists of `gulp-request-header', |
83 | followed by the list of packages (with modification times if the optional | |
84 | prefix argument TIME is non-nil), concluded with `gulp-request-end'. | |
85 | ||
86 | You can't edit the messages, but you can confirm whether to send each one. | |
87 | ||
88 | The list of addresses for which you decided not to send mail | |
89 | is left in the `*gulp*' buffer at the end." | |
90 | (interactive "DRequest updates for Lisp directory: \nP") | |
91 | (save-excursion | |
92 | (set-buffer (get-buffer-create gulp-tmp-buffer)) | |
93 | (let ((m-p-alist (gulp-create-m-p-alist | |
94 | (directory-files dir nil "^[^=].*\\.el$" t) | |
95 | dir)) | |
96 | ;; Temporarily inhibit undo in the *gulp* buffer. | |
97 | (buffer-undo-list t) | |
98 | mail-setup-hook msg node) | |
b6030d2f | 99 | (setq m-p-alist |
a4929bfa RS |
100 | (sort m-p-alist |
101 | (function (lambda (a b) | |
102 | (string< (car a) (car b)))))) | |
8060ee8f RS |
103 | (while (setq node (car m-p-alist)) |
104 | (setq msg (gulp-create-message (cdr node) time)) | |
105 | (setq mail-setup-hook | |
a1506d29 | 106 | (lambda () |
811ec3a8 SM |
107 | (mail-subject) |
108 | (insert "It's time for Emacs updates again") | |
109 | (goto-char (point-max)) | |
110 | (insert msg))) | |
8060ee8f | 111 | (mail nil (car node)) |
a4929bfa | 112 | (goto-char (point-min)) |
8060ee8f RS |
113 | (if (y-or-n-p "Send? ") (mail-send) |
114 | (kill-this-buffer) | |
115 | (set-buffer gulp-tmp-buffer) | |
116 | (insert (format "%s\n\n" node))) | |
117 | (setq m-p-alist (cdr m-p-alist)))) | |
118 | (set-buffer gulp-tmp-buffer) | |
119 | (setq buffer-undo-list nil))) | |
120 | ||
121 | ||
122 | (defun gulp-create-message (rec time) | |
3ecaf18e RS |
123 | "Return the message string for REC, which is a list like (FILE TIME)." |
124 | (let (node (str gulp-request-header)) | |
125 | (while (setq node (car rec)) | |
8060ee8f RS |
126 | (setq str (concat str "\t" (car node) |
127 | (if time (concat "\tLast modified:\t" (cdr node))) | |
128 | "\n")) | |
3ecaf18e RS |
129 | (setq rec (cdr rec))) |
130 | (concat str gulp-request-end))) | |
131 | ||
3ecaf18e | 132 | |
8060ee8f RS |
133 | (defun gulp-create-m-p-alist (flist dir) |
134 | "Create the maintainer/package alist for files in FLIST in DIR. | |
135 | That is a list of elements, each of the form (MAINTAINER PACKAGES...)." | |
136 | (save-excursion | |
b6030d2f | 137 | (let (mplist filen node mnt-tm mnt tm fl-tm) |
8060ee8f RS |
138 | (get-buffer-create gulp-tmp-buffer) |
139 | (set-buffer gulp-tmp-buffer) | |
140 | (setq buffer-undo-list t) | |
141 | (while flist | |
142 | (setq fl-tm (gulp-maintainer (setq filen (car flist)) dir)) | |
143 | (if (setq tm (cdr fl-tm) mnt (car fl-tm));; there is a definite maintainer | |
144 | (if (setq node (assoc mnt mplist));; this is not a new maintainer | |
145 | (setq mplist (cons (cons mnt (cons (cons filen tm) (cdr node))) | |
146 | (delete node mplist))) | |
147 | (setq mplist (cons (list mnt (cons filen (cdr fl-tm))) mplist)))) | |
8060ee8f RS |
148 | (setq flist (cdr flist))) |
149 | (erase-buffer) | |
150 | mplist))) | |
151 | ||
152 | (defun gulp-maintainer (filenm dir) | |
153 | "Return a list (MAINTAINER TIMESTAMP) for the package FILENM in directory DIR." | |
3ecaf18e | 154 | (save-excursion |
4f1390ac | 155 | (let* ((fl (expand-file-name filenm dir)) mnt |
3ecaf18e RS |
156 | (timest (format-time-string "%Y-%m-%d %a %T %Z" |
157 | (elt (file-attributes fl) 5)))) | |
158 | (set-buffer gulp-tmp-buffer) | |
159 | (erase-buffer) | |
160 | (insert-file-contents fl nil 0 gulp-max-len) | |
161 | (goto-char 1) | |
162 | (if (re-search-forward gulp-discard nil t) | |
163 | (setq mnt nil) ;; do nothing, return nil | |
164 | (goto-char 1) | |
165 | (if (and (re-search-forward "^;+ *Maintainer: \\(.*\\)$" nil t) | |
166 | (> (length (setq mnt (match-string 1))) 0)) | |
167 | () ;; found! | |
168 | (goto-char 1) | |
169 | (if (re-search-forward "^;+ *Author: \\(.*\\)$" nil t) | |
170 | (setq mnt (match-string 1)))) | |
171 | (if (= (length mnt) 0) (setq mnt nil))) ;; "^;; Author: $" --> nil | |
172 | (cons mnt timest)))) | |
173 | ||
456f0b95 MR |
174 | (provide 'gulp) |
175 | ||
ab5796a9 | 176 | ;;; arch-tag: 42750a11-460a-4efc-829f-342d075530e5 |
3ecaf18e | 177 | ;;; gulp.el ends here |