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