Commit | Line | Data |
---|---|---|
55535639 | 1 | ;;; gulp.el --- ask for updates for Lisp packages |
3ecaf18e | 2 | |
ba318903 | 3 | ;; Copyright (C) 1996, 2001-2014 Free Software Foundation, Inc. |
3ecaf18e RS |
4 | |
5 | ;; Author: Sam Shteingold <shteingd@math.ucla.edu> | |
34dc21db | 6 | ;; Maintainer: emacs-devel@gnu.org |
bc3b7853 | 7 | ;; Keywords: maint |
b4aca021 | 8 | ;; Obsolete-since: 24.5 |
3ecaf18e RS |
9 | |
10 | ;; This file is part of GNU Emacs. | |
11 | ||
d6cba7ae | 12 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
3ecaf18e | 13 | ;; it under the terms of the GNU General Public License as published by |
d6cba7ae GM |
14 | ;; the Free Software Foundation, either version 3 of the License, or |
15 | ;; (at your option) any later version. | |
3ecaf18e RS |
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 | |
d6cba7ae | 23 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
3ecaf18e RS |
24 | |
25 | ;;; Commentary: | |
26 | ||
27 | ;; Search the emacs/{version}/lisp directory for *.el files, extract the | |
28 | ;; name of the author or maintainer and send him e-mail requesting | |
29 | ;; update. | |
30 | ||
31 | ;;; Code: | |
666b9413 SE |
32 | (defgroup gulp nil |
33 | "Ask for updates for Lisp packages." | |
34 | :prefix "-" | |
35 | :group 'maint) | |
36 | ||
2ab0ad85 | 37 | (defcustom gulp-discard "^;+ *Maintainer: *\\(FSF\\|emacs-devel@gnu\\.org\\) *$" |
cb711556 | 38 | "The regexp matching the packages not requiring the request for updates." |
2ab0ad85 | 39 | :version "24.4" ; added emacs-devel |
666b9413 SE |
40 | :type 'regexp |
41 | :group 'gulp) | |
42 | ||
cb711556 GM |
43 | (defcustom gulp-tmp-buffer "*gulp*" |
44 | "The name of the temporary buffer." | |
666b9413 SE |
45 | :type 'string |
46 | :group 'gulp) | |
47 | ||
48 | (defcustom gulp-max-len 2000 | |
cb711556 | 49 | "Distance into a Lisp source file to scan for keywords." |
666b9413 SE |
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") |
cb711556 | 59 | "The starting text of a gulp message." |
666b9413 SE |
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.") |
cb711556 | 77 | "The closing text in a gulp message." |
666b9413 SE |
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") | |
9a529312 | 95 | (with-current-buffer (get-buffer-create gulp-tmp-buffer) |
8060ee8f RS |
96 | (let ((m-p-alist (gulp-create-m-p-alist |
97 | (directory-files dir nil "^[^=].*\\.el$" t) | |
98 | dir)) | |
99 | ;; Temporarily inhibit undo in the *gulp* buffer. | |
100 | (buffer-undo-list t) | |
101 | mail-setup-hook msg node) | |
b6030d2f | 102 | (setq m-p-alist |
a4929bfa RS |
103 | (sort m-p-alist |
104 | (function (lambda (a b) | |
105 | (string< (car a) (car b)))))) | |
8060ee8f RS |
106 | (while (setq node (car m-p-alist)) |
107 | (setq msg (gulp-create-message (cdr node) time)) | |
108 | (setq mail-setup-hook | |
a1506d29 | 109 | (lambda () |
811ec3a8 SM |
110 | (mail-subject) |
111 | (insert "It's time for Emacs updates again") | |
112 | (goto-char (point-max)) | |
113 | (insert msg))) | |
8060ee8f | 114 | (mail nil (car node)) |
a4929bfa | 115 | (goto-char (point-min)) |
8060ee8f RS |
116 | (if (y-or-n-p "Send? ") (mail-send) |
117 | (kill-this-buffer) | |
118 | (set-buffer gulp-tmp-buffer) | |
119 | (insert (format "%s\n\n" node))) | |
120 | (setq m-p-alist (cdr m-p-alist)))) | |
121 | (set-buffer gulp-tmp-buffer) | |
122 | (setq buffer-undo-list nil))) | |
123 | ||
124 | ||
125 | (defun gulp-create-message (rec time) | |
3ecaf18e RS |
126 | "Return the message string for REC, which is a list like (FILE TIME)." |
127 | (let (node (str gulp-request-header)) | |
128 | (while (setq node (car rec)) | |
8060ee8f RS |
129 | (setq str (concat str "\t" (car node) |
130 | (if time (concat "\tLast modified:\t" (cdr node))) | |
131 | "\n")) | |
3ecaf18e RS |
132 | (setq rec (cdr rec))) |
133 | (concat str gulp-request-end))) | |
134 | ||
3ecaf18e | 135 | |
8060ee8f RS |
136 | (defun gulp-create-m-p-alist (flist dir) |
137 | "Create the maintainer/package alist for files in FLIST in DIR. | |
138 | That is a list of elements, each of the form (MAINTAINER PACKAGES...)." | |
139 | (save-excursion | |
b6030d2f | 140 | (let (mplist filen node mnt-tm mnt tm fl-tm) |
8060ee8f RS |
141 | (get-buffer-create gulp-tmp-buffer) |
142 | (set-buffer gulp-tmp-buffer) | |
143 | (setq buffer-undo-list t) | |
144 | (while flist | |
145 | (setq fl-tm (gulp-maintainer (setq filen (car flist)) dir)) | |
146 | (if (setq tm (cdr fl-tm) mnt (car fl-tm));; there is a definite maintainer | |
147 | (if (setq node (assoc mnt mplist));; this is not a new maintainer | |
148 | (setq mplist (cons (cons mnt (cons (cons filen tm) (cdr node))) | |
149 | (delete node mplist))) | |
150 | (setq mplist (cons (list mnt (cons filen (cdr fl-tm))) mplist)))) | |
8060ee8f RS |
151 | (setq flist (cdr flist))) |
152 | (erase-buffer) | |
153 | mplist))) | |
154 | ||
155 | (defun gulp-maintainer (filenm dir) | |
156 | "Return a list (MAINTAINER TIMESTAMP) for the package FILENM in directory DIR." | |
3ecaf18e | 157 | (save-excursion |
4f1390ac | 158 | (let* ((fl (expand-file-name filenm dir)) mnt |
3ecaf18e RS |
159 | (timest (format-time-string "%Y-%m-%d %a %T %Z" |
160 | (elt (file-attributes fl) 5)))) | |
161 | (set-buffer gulp-tmp-buffer) | |
162 | (erase-buffer) | |
163 | (insert-file-contents fl nil 0 gulp-max-len) | |
164 | (goto-char 1) | |
165 | (if (re-search-forward gulp-discard nil t) | |
166 | (setq mnt nil) ;; do nothing, return nil | |
167 | (goto-char 1) | |
168 | (if (and (re-search-forward "^;+ *Maintainer: \\(.*\\)$" nil t) | |
169 | (> (length (setq mnt (match-string 1))) 0)) | |
170 | () ;; found! | |
171 | (goto-char 1) | |
172 | (if (re-search-forward "^;+ *Author: \\(.*\\)$" nil t) | |
173 | (setq mnt (match-string 1)))) | |
174 | (if (= (length mnt) 0) (setq mnt nil))) ;; "^;; Author: $" --> nil | |
175 | (cons mnt timest)))) | |
176 | ||
456f0b95 MR |
177 | (provide 'gulp) |
178 | ||
3ecaf18e | 179 | ;;; gulp.el ends here |